Vixen
02b45cc4
csharp
public sealed class FoliageChunk

Every instance of one type inside one cell, and the bounds they occupy.

Read the guide page for this →

Remarks

What the instancing feature draws as one object. The bounds are maintained as instances arrive and are recomputed when one leaves, because a cull is only as good as the box it tests — and a cell whose bounds never shrank would keep a whole forest's worth of extent after an artist erased all but one tree.

⚠ One chunk per type per cell, not one per cell. A cell holding three kinds of tree is three batches, because a batch is one mesh — folding them together would mean a draw that has to switch mesh mid-instance, which is not a thing.

Fields and properties (6)

  • public FoliageCellKey Cell

    Which cell it is in.

  • public int Type

    Which type's instances it holds.

  • public IReadOnlyList<FoliageInstance> Instances

    The instances.

  • public int Count

    How many there are.

  • public bool IsEmpty

    Whether there are none.

  • public BoundingBox Bounds

    Where they are, as one box.

Methods (6)

  • public FoliageChunk(FoliageCellKey cell, int type)

    Creates an empty chunk.

  • public void Add(in FoliageInstance instance, float reach = 1)

    Adds an instance.

  • public void RemoveAt(int index, float reach = 1)

    Removes the instance at an index.

  • public int RemoveAll(Predicate<FoliageInstance> accept, float reach = 1)

    Removes every instance a predicate accepts.

  • public void Replace(int index, in FoliageInstance instance, float reach = 1)

    Replaces the instance at an index.

  • public void Clear()

    Empties it.

Used by (12)

  • FoliageBlockerTestsVixen.Rendering.Terrain.Tests
  • FoliageCullPassVixen.Rendering.Terrain
  • FoliageGrowthTestsVixen.Foliage.Tests
  • FoliageRendererVixen.Rendering.Terrain
  • FoliageScatterTestsVixen.Foliage.Tests
  • FoliageStoreVixen.Foliage
  • FoliageStreamerVixen.Rendering.Terrain
  • FoliageVolumeVixen.Foliage
  • FoliageVolumeTestsVixen.Foliage.Tests
  • PaletteRemovalTestsVixen.Foliage.Tests
  • FoliageModeTestsVixen.Editor.Terrain.Tests
  • FoliageStrokeCommandVixen.Editor.Terrain