Vixen
02b45cc4
csharp
public sealed class TerrainStreamer

Which tiles of a terrain a frame keeps loaded, and at what level the rest draw.

Read the guide page for this →

Remarks

[docs/plan/31 § D13]'s consumer, which was the piece that did not exist. StreamingGrid decides which cells a frame's sources want and PageResidency loads, places and evicts them; both were built, tested and reachable from nothing. This is the terrain that asks.

⚠ The coarse tail of every tile is pinned, and that is what makes a non-resident tile a coarse tile rather than a hole. A chain's last levels are a few hundred bytes — a 128 tile reduced to 16 is a 256th of it — so every tile in the world can afford its tail, and nothing has to be dropped from the selection. What streaming decides is whether a tile has its fine levels, and LevelOf is where that becomes a number the vertex stage reads. Dropping the node instead would put a hole in the distance on the frame a camera turned, which is the failure this arrangement exists to rule out.

⚠ The radius is a distance in metres and the grid is in tiles, so a small terrain streams nothing. That is correct rather than a degenerate case: a terrain whose every tile is within the near radius is one that fits, and paying for the machinery would be paying for a decision with one answer.

Fields and properties (6)

  • public const int PageSource

    What page source a terrain's tiles are filed under.

  • public PageResidency Residency

    The residency service, for anything that wants its counters.

  • public StreamingGrid Grid

    The grid the cells are decided on, for its lead and its bounds.

  • public TerrainTilePages Pages

    The pool, for its pending hand-over.

  • public int CoarseLevel

    The finest level a tile with no fine data may be drawn at.

  • public int TouchedTiles

    How many tiles the last Update counted as in use.

Methods (6)

  • public TerrainStreamer(in TerrainDescription description, ITerrainTileSource source, long budget = 67108864)

    Streams a terrain's tiles around whatever moves through it.

  • public bool IsResident(int tileX, int tileZ)

    Whether a tile's fine levels are loaded.

  • public float LevelOf(int tileX, int tileZ, float level)

    The finest level a node over a tile may be drawn at.

  • public (int X, int Z) TileAt(Vector2 position)

    Which tile a world position on the terrain's XZ plane is in.

  • public int Update(ReadOnlySpan<StreamingSource> sources, int maxLoads = 8)

    Tells the pool what this frame's sources want, and services what it can.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (2)

  • TerrainRendererVixen.Rendering.Terrain
  • TerrainStreamingTestsVixen.Rendering.Terrain.Tests