03-27-2012, 10:13 PM
Ran into a roadblock with this scheme: generating trees and overhangs kind of collides together: Overhangs are "added" on top of generated HeightMap when generating a chunk. So the tree generator, being a structure generator, sees the overhang for the current chunk. But trees need to "see" into the neighboring chunks as well - we don't want a tree "hugging" a wall - its trunk being right next to a wall.
So it seems we'll still need two kinds of structure generators - ones that needn't see neighbor chunks (e. g. caves, ores) and ones that generate only after the neighbor is generated (trees, villages). The second type I've dubbed "delayed structures". They'll work by splitting their work into quarter-chunk-sized pieces. The chunk will generate only with the normal structures, but then it will check its neighbors and for each neighbor it will generate the corresponding quarter - for the northeast quarter to generate, the chunk will need its north, east and northeast neighbors already generated.
I believe the Notchian generator uses a similar technique - there are no trees on the edge of a map, all the tree trunks stop 1/2 chunk before the map's edge. Similarly villages and even abandoned mineshafts don't generate closer than 8 blocks to the edge.
This might actually produce slightly buggy lighting. Since lighting is applied 1-chunk-delayed from the generation, it means the neighbors of the currently lit chunk needn't have all their delayed-structures generated yet. They are guaranteed to have an 8-block wide final data along the neighboring edge, but lighting can spread as far as 15 blocks. So in a dense forest areas lighting could "shine through" the not-yet-delay-generated area and make it into the chunk being lit.
This should not be a problem for trees, since light shines through the leaves anyway. I'm not sure if villages will suffer from it, though. They might, as houses can be larger than 8 blocks across.
So it seems we'll still need two kinds of structure generators - ones that needn't see neighbor chunks (e. g. caves, ores) and ones that generate only after the neighbor is generated (trees, villages). The second type I've dubbed "delayed structures". They'll work by splitting their work into quarter-chunk-sized pieces. The chunk will generate only with the normal structures, but then it will check its neighbors and for each neighbor it will generate the corresponding quarter - for the northeast quarter to generate, the chunk will need its north, east and northeast neighbors already generated.
I believe the Notchian generator uses a similar technique - there are no trees on the edge of a map, all the tree trunks stop 1/2 chunk before the map's edge. Similarly villages and even abandoned mineshafts don't generate closer than 8 blocks to the edge.
This might actually produce slightly buggy lighting. Since lighting is applied 1-chunk-delayed from the generation, it means the neighbors of the currently lit chunk needn't have all their delayed-structures generated yet. They are guaranteed to have an 8-block wide final data along the neighboring edge, but lighting can spread as far as 15 blocks. So in a dense forest areas lighting could "shine through" the not-yet-delay-generated area and make it into the chunk being lit.
This should not be a problem for trees, since light shines through the leaves anyway. I'm not sure if villages will suffer from it, though. They might, as houses can be larger than 8 blocks across.