Vixen
02b45cc4
csharp
public sealed class TerrainEdit

The terrain being sculpted, and the drag in flight over it.

Read the guide page for this →

Remarks

What MeshEdit is to a blockout mesh. The mode owns keys, a toolbar and a claim on the viewport; this owns the terrain, the layer being written and the stroke — which is the split that lets a test drive a whole stroke with world points and assert the ground, with no shell and no window.

Pointer down, drag, pointer up is one command — [§ D11]. Begin starts a TerrainStroke, every Extend records before it writes and applies the kernel immediately, and Commit hands back one IEditorCommand. The composite is resolved as the drag goes, so the viewport shows the ground moving under the brush rather than at pointer-up.

⚠ The brush is snapshotted at Begin and not read again. The panel can change while a drag is in flight — a pen with a barrel wheel, a key press, another window — and a stroke whose radius changed halfway through has an undo record sized to a footprint that no longer matches what it wrote.

⚠ The colliders are rebuilt at Commit, not per stamp. A stroke marks one or two tiles over and over; building a Jolt height field per stamp is the version of this that makes the brush stutter. What is per stamp is the composite, because that is what the artist is looking at.

Fields and properties (11)

  • public Terrain? Terrain

    The terrain being edited, or while none is.

  • public TerrainEditLayer? Layer

    Which edit layer the tools write, or for none.

  • public TerrainBrushSettings Brush

    The brush every tool in both modes shares.

  • public TerrainToolSettings Tools

    What each tool does beyond what the brush says.

  • public ITerrainColliders? Colliders

    What rebuilds collision when the ground moves, or null for a scene with no physics.

  • public bool IsStroking

    Whether a drag is in flight.

  • public TerrainTool HeldTool

    Which tool the drag in flight is running.

  • public TerrainCategory HeldCategory

    Which half of the toolset the drag in flight belongs to.

  • public int Target

    Which paint layer the paint tools write, or −1 for none.

  • public string? Refusal

    What the last Begin refused for, or .

  • public bool CanStroke

    Whether the terrain and layer are in a state a stroke could start from.

Events (1)

  • public Action<TerrainRect>? Changed

    Told which samples moved, whenever any do. Where a renderer hangs its upload.

Methods (4)

  • public bool Begin(Vector2 ground, bool invert = false)

    Starts a stroke at a point on the ground.

  • public void Extend(Vector2 ground)

    Carries the stroke to a point.

  • public IEditorCommand? Commit(bool rebuildColliders = true)

    Ends the stroke and hands back the entry that undoes it.

  • public void Cancel()

    Abandons the stroke, putting the ground back the way it was.

Used by (7)

  • GroundVixen.Editor.Terrain.Tests
  • SculptSessionTestsVixen.Editor.Terrain.Tests
  • TerrainEditTestsVixen.Editor.Terrain.Tests
  • TerrainModeVixen.Editor.Terrain
  • TerrainModeTestsVixen.Editor.Terrain.Tests
  • TerrainModuleVixen.Editor.Terrain
  • TerrainPaintModeTestsVixen.Editor.Terrain.Tests