Vixen
caa30e12
csharp
public sealed class PatchSelector

The CDLOD descent, over any square of ground that can answer IPatchSource.

Read the guide page for this →

Remarks

One quadtree, not two ([35 § D4](../../docs/plan/35-water.md#d4-the-surface-is-the-terrains-quadtree-with-a-different-height-source), and [31 § D3](../../docs/plan/31-terrain-grass-and-trees.md#d3-a-quadtree-with-a-morph-not-a-clipmap) for the scheme itself). Unreal has a landscape LOD system and a water LOD system, with two morphs, two sets of bias cvars and two ways to get a crack. The selection, the morph, the no-crack property and the continuity property are all functions of the node's extent and the view's distance, and none of them is a function of what the height came from — so there is one implementation and the tests are written once.

Arithmetic, deliberately, with no device. 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, and [35 § Part 4] says they are written before the renderer.

⚠ The node coordinates are quads from the root's origin, and the source places them. A terrain's origin is its own corner and a water zone's is a sliding window that moved this frame; making the selector carry a world origin would give it an opinion about which, and the two answers differ by whether the origin snaps. BoundsOf is where that is decided.

Fields and properties (4)

  • public const int DefaultGridQuads

    How many quads the shared grid patch spans, by default.

  • public int RootQuads

    How many quads the root node spans.

  • public int DepthCount

    How deep the descent goes, which may be fewer levels than the ranges describe.

  • public TerrainLodRanges Ranges

    Where each level takes over.

Methods (5)

  • public PatchSelector(int rootQuads, int depthCount, TerrainLodRanges ranges)

    Builds a selector over a square root node.

  • public static (int RootQuads, int LevelCount) RootFor(int quads, int gridQuads = 32)

    How many quads a root has to span to hold a given number, at a given patch size.

  • public int Select<TSource>(Vector3 viewPosition, in BoundingFrustum frustum, TSource source, ICollection<TerrainLodNode> nodes) where TSource : IPatchSource

    Chooses the patches a view draws.

  • public static float MorphIndex(int index, float morph)

    A grid index after morphing: odd indices slide back onto their even neighbour.

  • public static float DistanceTo(in BoundingBox bounds, Vector3 point)

    How far a point is from a box, and zero inside it.

Used by (5)

  • TerrainLodTreeVixen.Terrain
  • WaterMeshRendererVixen.Rendering.Water
  • WaterSurfaceAssetVixen.Rendering.Water
  • WaterSurfaceMeshVixen.Water
  • WaterSurfacePassVixen.Rendering.Water