Vixen
02b45cc4
csharp
public sealed class Terrain

A terrain: a base heightfield, a stack of edit layers over it, paint channels and holes.

Read the guide page for this →

Remarks

The composite is derived, always, and never stored as the truth. [docs/plan/31 § D4]. Base plus each visible layer's delta times its alpha is what the world is; Composite is a cache of that answer and Invalidate is how it stops being trusted. Nothing may write to the composite, because the next invalidation would discard the write and the tool that made it would appear to work until somebody toggled a layer.

Per tile, because that is the unit of everything else. A stroke marks the tiles it touched, and only those tiles recompute, re-upload and rebuild their collider — [§ D2]. Invalidating the whole terrain on every stamp would make a 4 km² terrain unusable at the first drag.

Fields and properties (7)

  • public TerrainDescription Description

    Its shape.

  • public TerrainSamples Base

    The heights before any layer touches them.

  • public TerrainSamples Composite

    The heights the world actually has. Derived; do not write.

  • public TerrainWeights Weights

    The paint channels.

  • public TerrainHoles Holes

    Which samples are not there.

  • public IReadOnlyList<TerrainEditLayer> Layers

    The edit layers, bottom first.

  • public int DirtyTileCount

    How many tiles are waiting to be recomposited.

Methods (14)

  • public Terrain(TerrainDescription description, float height = 0)

    Creates a flat terrain at a height.

  • public TerrainEditLayer AddLayer(string name, TerrainLayerKind kind = Manual)

    Adds an edit layer on top of the stack.

  • public int IndexOf(TerrainEditLayer layer)

    Where a layer sits in the stack.

  • public void InsertLayer(int index, TerrainEditLayer layer)

    Puts a layer back into the stack at a given height.

  • public bool RemoveLayer(TerrainEditLayer layer)

    Removes an edit layer and everything it held.

  • public void MoveLayer(int from, int to)

    Moves a layer up or down the stack.

  • public void Collapse(int index)

    Adds a layer's deltas into the one below it and drops the layer.

  • public void Invalidate(TerrainRect rect)

    Marks a rectangle of samples as needing recompositing.

  • public void InvalidateAll()

    Marks every tile as needing recompositing.

  • public bool IsTileDirty(int tileX, int tileZ)

    Whether a tile's composite is stale.

  • public int Resolve()

    Recomposites every stale tile.

  • public (float Minimum, float Maximum) HeightRangeOf(int tileX, int tileZ)

    The lowest and highest composited sample of a tile.

  • public (float Minimum, float Maximum) HeightRangeOf(TerrainRect rect)

    The lowest and highest composited sample over a rectangle of samples.

  • public ushort CompositeAt(int x, int z)

    What the composite would be at one sample, computed rather than read.

Used by (70, showing 40)

  • ITerrainSceneVixen.Rendering.Terrain
  • TerrainHeightmapVixen.Terrain
  • TerrainHeightmapPngVixen.Terrain
  • TerrainHeightmapPngTestsVixen.Terrain.Tests
  • TerrainHeightmapTestsVixen.Terrain.Tests
  • TerrainLayerTestsVixen.Terrain.Tests
  • TerrainLodTestsVixen.Terrain.Tests
  • TerrainLodTreeVixen.Terrain
  • TerrainMipTestsVixen.Terrain.Tests
  • TerrainMipsVixen.Terrain
  • TerrainPaintVixen.Terrain
  • TerrainPaintTestsVixen.Terrain.Tests
  • TerrainPickVixen.Terrain
  • TerrainPickTestsVixen.Terrain.Tests
  • TerrainRendererVixen.Rendering.Terrain
  • TerrainRendererTestsVixen.Rendering.Terrain.Tests
  • TerrainResizeVixen.Terrain
  • TerrainResizeTestsVixen.Terrain.Tests
  • TerrainSculptVixen.Terrain
  • TerrainSculptTestsVixen.Terrain.Tests
  • TerrainSplatTestsVixen.Rendering.Terrain.Tests
  • TerrainSplineVixen.Terrain
  • TerrainSplineTestsVixen.Terrain.Tests
  • TerrainStoreVixen.Terrain
  • TerrainStoreTestsVixen.Terrain.Tests
  • TerrainStreamingTestsVixen.Rendering.Terrain.Tests
  • TerrainStrokeVixen.Terrain
  • TerrainStrokeRedoVixen.Terrain
  • TerrainStrokeTestsVixen.Terrain.Tests
  • TerrainSurfaceVixen.Rendering.Terrain
  • TerrainSurfaceTestsVixen.Rendering.Terrain.Tests
  • TerrainTileSourceVixen.Rendering.Terrain
  • TerrainWeightRedoVixen.Terrain
  • TerrainWeightStrokeVixen.Terrain
  • TerrainWeightTestsVixen.Terrain.Tests
  • TerrainWeightmapVixen.Terrain
  • TerrainWeightmapTestsVixen.Terrain.Tests
  • AssignTargetCommandVixen.Editor.Terrain
  • CollapseLayerCommandVixen.Editor.Terrain
  • GroundVixen.Editor.Terrain.Tests