Happy holidays, and less-happy graphics glitches

Happy holidays everyone!  I’ve had a quiet couple of days (at least, in terms of development!), but now that boxing day has come and gone, I’m back to poking around with MMORPG Tycoon.  In the screenshot here, you’re looking at a couple of mountainous districts, separated by a couple of dead flat districts.

And I’ve pretty clearly got a bug in my “terrain blending” code, which I’m pointing at in the screenshot above; precisely halfway through the blend from flat ground to mountains, there’s a steep ridge, just over the border between districts.  (You can see a similar ridge on the mountainous district in the background).  I’m kind of baffled about what’s causing this.  When things like this baffle me, I find that the best thing to do is to stop thinking about them, and work on something else instead;  the answer will eventually come, as long as I’m not banging my head against the problem.

Instead, I worked on my main concern;  editable terrain.  Here’s the problem:  MMORPG Tycoon’s terrain is handled in chunks;  basically large squares of terrain, each currently about a hundred meters on a side.  The problem is that regenerating terrain is extremely computationally expensive, especially with the new blending between districts;  regenerating just one of them currently takes about 60 milliseconds;  enough to make the frame rate stutter quite noticably (basically a frame rate drop from 60fps to about 15 fps).  If that happened every time a player made a terrain modification, then crafting your world would quickly become extremely unpleasant.

So what I did today was to set up terrain calculations as a background process, more like how regular video game streaming works;  the game registers a request for a bit of terrain to be generated, and then several frames later, the terrain generation process informs the game that the data has been generated and can now be used.  This makes the code a good deal more complicated, but it does smooth out those jumps in frame rate.  (In fact, on my computer, I’m now able to hold 60fps, even when regenerating terrain, even in unoptimised debugging builds of the game..)

Anyhow, that’s all for me for today.  I’m going to distract my brain a bit with a book, and hopefully it’ll work out the weird terrain blending problem on its own.  :)