Vixen
caa30e12
csharp
public interface IPatchSource

What a quadtree descent asks about a square of ground it is considering.

Read the guide page for this →

Remarks

The two questions, and only the two — how tall is it, and is there anything there. Everything else a descent needs is arithmetic on the node's own extent, which is why PatchSelector can be shared between a terrain and a water zone ([35 § D4](../../docs/plan/35-water.md#d4-the-surface-is-the-terrains-quadtree-with-a-different-height-source)): the only difference between the two consumers is what the vertex stage samples for height.

Implement it as a readonly struct. Select``1 takes it as a generic parameter rather than as an interface reference, so a source that is a struct is called through a constrained call and a selection allocates nothing — which matters because this runs once per frame per zone over a few hundred nodes.

Methods (2)

  • BoundingBox BoundsOf(int x, int z, int quads)

    Everything a node occupies, in world units.

  • bool Covers(int x, int z, int quads)

    Whether a node has anything in it worth drawing.

Used by (3)

  • PatchSelectorVixen.Terrain
  • TerrainPatchSourceVixen.Terrain
  • WaterPatchSourceVixen.Water