Vixen
02b45cc4
csharp
public sealed class TerrainEditLayer

One non-destructive container of height deltas.

Read the guide page for this →

Remarks

[docs/plan/31 § D4], and the reason it is the storage model rather than a feature on top of one. Unreal added edit layers seven years after Landscape shipped, which is why they are still opt-in per landscape there: everything written against the flat heightmap had to keep working. Building the composite in from the first commit means no tool ever has a flat-heightmap path to preserve, and the reserved-layer mechanism splines and scatter need is the same mechanism an author's own layers use.

Sparse, in chunks that are not tiles. A layer that touched three tiles stores three tiles' worth, and the allocation granularity is a fixed ChunkSize-square block of the global sample grid rather than a tile — deliberately, because chunks tile the grid without overlapping and tiles share their boundary rows. A chunk grid aligned to tiles would put the shared row in two chunks, which is [§ D2]'s seam bug reintroduced one level down.

Signed deltas in the same units as the samples. A delta of ±32 767 is half the height range, which is as much as any one layer has ever needed to move the ground, and it keeps a layer the same size as the base rather than twice it.

⚠ HeightAlpha is signed, and a negative one subtracts. That is Unreal's semantic and it is genuinely useful — the same sculpt inverted is a valley — but it means the composite has to clamp, and that the identity value is one rather than zero.

Fields and properties (12)

  • public const int ChunkSize

    How many samples a sparse chunk is along each axis.

  • public TerrainDescription Description

    The terrain's shape.

  • public string Name

    What the layer is called.

  • public TerrainLayerKind Kind

    Who owns its contents.

  • public float HeightAlpha

    How much of its height deltas reach the composite. Signed; 1 is unchanged.

  • public float WeightAlpha

    How much of its paint reaches the composite, 0…1.

  • public bool IsVisible

    Whether it contributes at all.

  • public bool IsLocked

    Whether it refuses edits.

  • public bool AcceptsBrush

    Whether a tool may sculpt or paint into it by hand.

  • public int ChunkCount

    How many chunks hold anything.

  • public long Bytes

    How many bytes its deltas occupy.

  • public bool IsEmpty

    Whether it has nothing in it.

Methods (8)

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

    Creates an empty layer over a terrain's shape.

  • public TerrainEditLayer Clone()

    A copy of the layer, deltas and all.

  • public short DeltaAt(int x, int z)

    What this layer moves one sample by, before its alpha.

  • public void SetDelta(int x, int z, short delta)

    Sets what this layer moves one sample by.

  • public void AddDelta(int x, int z, int delta)

    Adds to what this layer moves one sample by, saturating rather than wrapping.

  • public void Clear()

    Forgets everything the layer holds.

  • public void Clear(TerrainRect rect)

    Forgets what the layer holds inside a rectangle.

  • public IEnumerable<(int X, int Z)> OccupiedChunks()

    Which chunks hold anything, as their low corners in sample indices.

Used by (35)

  • TerrainVixen.Terrain
  • TerrainHeightmapVixen.Terrain
  • TerrainHeightmapPngTestsVixen.Terrain.Tests
  • TerrainHeightmapTestsVixen.Terrain.Tests
  • TerrainLayerTestsVixen.Terrain.Tests
  • TerrainLodTestsVixen.Terrain.Tests
  • TerrainMipTestsVixen.Terrain.Tests
  • TerrainPickTestsVixen.Terrain.Tests
  • TerrainRendererTestsVixen.Rendering.Terrain.Tests
  • TerrainResizeVixen.Terrain
  • TerrainResizeTestsVixen.Terrain.Tests
  • TerrainSculptVixen.Terrain
  • TerrainSculptTestsVixen.Terrain.Tests
  • TerrainSplineVixen.Terrain
  • TerrainSplineTestsVixen.Terrain.Tests
  • TerrainStoreVixen.Terrain
  • TerrainStoreTestsVixen.Terrain.Tests
  • TerrainStrokeVixen.Terrain
  • TerrainStrokeRedoVixen.Terrain
  • TerrainStrokeTestsVixen.Terrain.Tests
  • TerrainSurfaceTestsVixen.Rendering.Terrain.Tests
  • CollapseLayerCommandVixen.Editor.Terrain
  • InsertLayerCommandVixen.Editor.Terrain
  • LayerPropertyCommandVixen.Editor.Terrain
  • RemoveLayerCommandVixen.Editor.Terrain
  • ReplaceLayerCommandVixen.Editor.Terrain
  • SculptSessionTestsVixen.Editor.Terrain.Tests
  • TerrainEditVixen.Editor.Terrain
  • TerrainEditTestsVixen.Editor.Terrain.Tests
  • TerrainLayerCommandTestsVixen.Editor.Terrain.Tests
  • TerrainLayerCommandsVixen.Editor.Terrain
  • TerrainModeVixen.Editor.Terrain
  • TerrainModuleVixen.Editor.Terrain
  • TerrainPaintModeTestsVixen.Editor.Terrain.Tests
  • TerrainStrokeCommandVixen.Editor.Terrain