public sealed class TerrainLodTreeThe quadtree a frame descends to decide which patches to draw, and the morph that joins them.
Remarks
CDLOD (Strugar, 2010), for the reasons in [docs/plan/31 § D3]: the node is simultaneously the LOD unit, the cull unit and the draw, and it aligns with the tile — a clipmap's rings align with nothing, because they are centred on the camera and everything else is a rectangle in terrain space.
No skirts, and that is the return on the morph. A finer node has degenerated onto its parent's grid by the time the parent takes over, so a boundary between two levels has no gap to hide. Skirts are what a renderer grows when the morph is wrong, and then keeps.
Arithmetic, deliberately. This assembly has no device — [§ D1] — and the two properties that matter are exactly the ones a device cannot be asked about: whether the shared edge of two adjacent nodes agrees, and whether a vertex moves continuously as the camera does. Both are functions, so both are unit tests. [§ Part 4] says the no-crack test must be written before the renderer, not after it.
Fields and properties (5)
public const int DefaultGridQuadsHow many quads the shared grid patch spans, by default.
public TerrainLodRanges RangesWhere each level takes over.
public int GridQuadsHow many quads the shared grid patch spans.
public int RootQuadsHow many quads the root node spans.
public int DepthCountHow deep the tree is, which may be fewer levels than the ranges describe.
Methods (6)
public TerrainLodTree(TerrainDescription description, TerrainLodRanges ranges, int gridQuads = 32)Builds a tree over a terrain's shape.
public int Select(Vector3 viewPosition, in BoundingFrustum frustum, Terrain terrain, ICollection<TerrainLodNode> nodes)Chooses the patches a view draws.
public BoundingBox BoundsOf(int x, int z, int quads, Terrain terrain)Everything a node occupies, in the terrain's own space.
public Vector2 SampleOf(in TerrainLodNode node, int gridX, int gridZ)Where one vertex of the shared grid patch lands, in sample coordinates, after morphing.
public Vector3 PositionOf(in TerrainLodNode node, int gridX, int gridZ, Terrain terrain)Where one vertex of a patch lands in the terrain's own space, after morphing.
public static float MorphIndex(int index, float morph)A grid index after morphing: odd indices slide back onto their even neighbour.
Used by (3)
- TerrainLodTestsVixen.Terrain.Tests
- TerrainRendererVixen.Rendering.Terrain
- TerrainShaderParityTestsVixen.Rendering.Terrain.Tests