Vixen
02b45cc4
csharp
public sealed class TerrainStroke

One brush stroke, recorded so it can be undone.

Read the guide page for this →

Remarks

[docs/plan/31 § D11]: a stroke is one command and it stores a rect. Pointer down, drag, pointer up is one entry holding the layer it targeted, the union of the rectangles it touched, and that rectangle's deltas before and after. A 256-square rectangle of deltas is 128 KB each way; a typical stroke is a fraction of one tile.

The layer's deltas, not the composite. Restoring the composite would restore a derived value and leave the layer holding what the stroke wrote, so the next recompositing would put the stroke back. It is the same reason the sculpt kernels write the layer and read the composite.

Intra-stroke updates merge; two strokes do not. A drag is one command being extended rather than four hundred commands, and "undo that" means the stroke — which is what every paint application does and what an artist means. So the before image is captured lazily as the rectangle grows, never recaptured for ground already covered.

⚠ The recorded rectangle has to be the one the kernel read, not the one it wrote. Smoothing and erosion read a sample beyond their footprint, so a record sized to the write restores a rectangle whose border still holds post-stroke values — and the next smooth over the same place pulls them back in. Extend grows by NeighbourMargin for that reason.

Fields and properties (5)

  • public TerrainRect Rect

    Everything the stroke has touched.

  • public TerrainEditLayer Layer

    Which layer it wrote.

  • public int RecordedSamples

    How many samples the record holds.

  • public long Bytes

    How many bytes the record occupies, both images together.

  • public bool IsEmpty

    Whether anything has been recorded.

Methods (5)

  • public TerrainStroke(Terrain terrain, TerrainEditLayer layer)

    Begins recording a stroke on a layer.

  • public TerrainRect Record(in TerrainBrush brush, in BrushStamp stamp)

    Records the ground a stamp is about to change, and says which samples those are.

  • public void Extend(TerrainRect rect)

    Records the ground a rectangle covers. Call before applying the kernel.

  • public TerrainRect Undo()

    Puts the layer back the way it was before the stroke.

  • public TerrainStrokeRedo Capture()

    Captures what the stroke left, so it can be redone.

Used by (4)

  • TerrainLayerTestsVixen.Terrain.Tests
  • TerrainStrokeTestsVixen.Terrain.Tests
  • TerrainEditVixen.Editor.Terrain
  • TerrainStrokeCommandVixen.Editor.Terrain