Posts: 952
Threads: 16
Joined: May 2013
Thanks: 66
Given 105 thank(s) in 89 post(s)
That's very helpful, and quite promising. Didn't know Java has all the Worlds ticking on one thread.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
Being single-threaded actually made sense in the beginning days of Minecraft. The game logic is much simpler that way, no need to lock and unlock data, no problems with deadlocks, no out-of-order packets (like the ones we still have with invisible mobs) etc.
Posts: 952
Threads: 16
Joined: May 2013
Thanks: 66
Given 105 thank(s) in 89 post(s)
xoft, do you recall why the terrain generator has a cache?
I can see it being used during tree placement, where trees attempt to generate chunks around them when they cross chunk borders.
As well during village generation, apparently so roads follow the lay of the original land, before any finishers changed the heightmap?
If we do need to preserve the original heightmap, I'm only seeing one call to UpdateHeightmap before the chunk concludes generation, in the tree generator. If this can be removed the heightmap in ChunkDesc should serve the purpose for village roads well.
Tree generation seems like it could be made to use the strategy of ore pocket features (that can also cross borders, but don't need to generate extra chunks to place properly), though the density of trees might make this difficult? If this is possible then we can eliminate the need to touch other chunks during tree generation.
I think achieving both of these would allow removal of the cache? Especially with the village road heightmap, it looks like we're regenerating an entire chunk just to get the height at one position; even with a cache there's still memcpy costs to consider, and it precludes threadpooling the terrain generator.