Vixen
02b45cc4
csharp
public readonly record struct FoliageCellGrid

A fixed-size square of world, and the unit of everything foliage does.

Read the guide page for this →

Remarks

[docs/plan/31 § D9]: the cell is the batch. It holds every instance of one type within it, its bounds are tight, and it is what the instancing feature sees as one object — which is what makes [§ B2]'s contract satisfiable. A forest is a few thousand cells, each culled by the existing frustum and Hi-Z path.

It is also the unit of streaming — PageKey(Source, Index) addresses a foliage cell exactly as it addresses a terrain tile — and of collision, where the same grid maintains which instances are near enough to have a body.

⚠ Thirty-two metres by default, and it is a compromise with two failure modes. Larger cells cull worse — the far half of a big cell of grass is behind a hill and is drawn anyway — and smaller ones cost a draw each. Per type-group rather than global, because a cell of trees and a cell of grass want different answers.

Fields and properties (3)

  • public float Size

    How many metres a cell spans on a side.

  • public const float MinimumSize

    The smallest cell that is a cell.

  • public float CellSize

    The size, guarded.

Methods (4)

  • public FoliageCellGrid(float Size = 32)

    A fixed-size square of world, and the unit of everything foliage does.

  • public FoliageCellKey CellOf(Vector3 position)

    Which cell a world position is in.

  • public Vector3 OriginOf(FoliageCellKey cell)

    Where a cell's low corner is.

  • public IEnumerable<FoliageCellKey> Touching(Vector2 centre, float radius)

    Every cell a circle touches.

Used by (15)

  • FoliageStoreVixen.Foliage
  • FoliageStreamerVixen.Rendering.Terrain
  • FoliageStreamingTestsVixen.Rendering.Terrain.Tests
  • FoliageVolumeVixen.Foliage
  • FoliageVolumeTestsVixen.Foliage.Tests
  • GrassDispatchVixen.Rendering.Terrain
  • GrassDispatchTestsVixen.Rendering.Terrain.Tests
  • GrassDrawPassTestsVixen.Rendering.Terrain.Tests
  • GrassRendererVixen.Rendering.Terrain
  • GrassResidencyVixen.Foliage
  • GrassScatterVixen.Foliage
  • GrassScatterParityTestsVixen.Rendering.Terrain.Tests
  • GrassScatterTestsVixen.Foliage.Tests
  • PaletteRemovalTestsVixen.Foliage.Tests
  • FoliageStrokeCommandVixen.Editor.Terrain