Vixen
02b45cc4
csharp
public static class FoliageStore

Instances on disk, beside the scene rather than inside it.

Read the guide page for this →

Remarks

[docs/plan/31 § What the scene sees]: stored beside the scene for the merge-conflict reason a heightfield is. A .vxscene is the file two people touch every day, and fifty thousand transforms in it is a file nobody can merge — one artist thinning a wood and another moving a rock produce a conflict across every line.

Binary, and it is the one place in this subsystem where that is not a shortcut. Fifty thousand instances is 1.4 MB of packed floats and about 12 MB of YAML that takes a second and a half to parse. What is not binary is the palette, which is names and numbers an author edits and a diff should show.

⚠ Grouped by cell, and the cell key is written rather than derived. Deriving it on load from the position would be one fewer field and would silently re-cell every instance if the grid size ever changed — a saved forest that moves when somebody edits a setting. Written, a mismatch is detectable; Read re-cells deliberately and says so.

Fields and properties (3)

  • public static ReadOnlySpan<byte> Magic

    What the first four bytes of a foliage file are.

  • public const int Version

    Which layout the bytes are in.

  • public const int InstanceBytes

    How many bytes one instance occupies.

Methods (4)

  • public static long ByteCount(FoliageVolume volume)

    How many bytes a volume's instances would occupy.

  • public static IEnumerable<FoliageChunk> Persisted(FoliageVolume volume)

    The chunks a file holds: non-empty, and of a type that is stored.

  • public static int Write(FoliageVolume volume, Span<byte> destination)

    Writes a volume's instances.

  • public static int Read(FoliageVolume volume, ReadOnlySpan<byte> bytes)

    Reads instances into a volume.

Used by (6)

  • FoliageCullPassTestsVixen.Rendering.Terrain.Tests
  • FoliageVolumeTestsVixen.Foliage.Tests
  • GrassCostsNothingTestsVixen.Foliage.Tests
  • GrassDispatchTestsVixen.Rendering.Terrain.Tests
  • FoliageModeTestsVixen.Editor.Terrain.Tests
  • TerrainModuleVixen.Editor.Terrain