public sealed class StreamingGridA regular grid of pages over the XZ plane, and the policy that decides which are resident.
Remarks
The policy half of [docs/plan/31 § D13], and no more than that. PageResidency already knows how to load, place, refresh and evict a page, and it deliberately does not interpret Source — its own remarks say the source is "assigned by whoever registered it" and "never interpreted". What was missing was anything that decides which pages a frame wants. This is that decision for the one shape a terrain has: a grid.
⚠ This is not world streaming, and the difference is worth being exact about. [docs/plan/31 § B6] records that there is no distance-based level streaming — no cells of entities, no data layers, no HLOD — and declines to invent one. What is here makes the bytes of a tiled thing stream: terrain heights, terrain weights, and anything else that is a grid of blobs. A scene with ten thousand tree instances in it still loads all ten thousand, because they are entities and this does not know what an entity is.
A lead ring, because a page that arrives when it is needed arrives late. Pages within a source's radius are touched — they are being used, so they must not be the first evicted — and pages within the radius plus Lead are requested. Without the lead, a source moving at any speed crosses into a cell at the same moment the cell is asked for, and the first frames of it are drawn from whatever coarser thing was resident.
Distance to the cell, not to its centre. A source standing in the corner of a large cell is zero metres from that cell and one cell-width from its centre; measuring to the centre makes the radius mean different things depending on where in a cell somebody stands, which shows up as a load boundary that moves when the player strafes.
Fields and properties (8)
public int SourceWhich page source these cells belong to.
public float CellSizeHow wide a cell is, in metres.
public int CountXHow many cells along X.
public int CountZHow many cells along Z.
public int CellCountHow many cells there are.
public float LeadHow far beyond a source's radius pages are requested but not yet used, in metres.
public int TouchedCellsHow many cells the last Update touched.
public int RequestedCellsHow many cells the last Update requested.
Methods (6)
public StreamingGrid(int source, Vector2 origin, float cellSize, int countX, int countZ)Describes a grid of pages.
public PageKey KeyOf(int x, int z)The page a cell is.
public (int X, int Z) CellOf(int index)Which cell a page index is.
public (Vector2 Minimum, Vector2 Maximum) BoundsOf(int x, int z)Where a cell is, in world XZ.
public float DistanceTo(int x, int z, Vector3 position)The shortest distance from a place to a cell, in world XZ. Zero inside it.
public int Update(ReadOnlySpan<StreamingSource> sources, PageResidency residency)Tells a residency service what this frame's sources want.
Used by (4)
- FoliageStreamerVixen.Rendering.Terrain
- FoliageStreamingTestsVixen.Rendering.Terrain.Tests
- StreamingGridTestsVixen.Rendering.Tests
- TerrainStreamerVixen.Rendering.Terrain