public static class TerrainSplineRoads, rivers and paths: a spline that deforms the terrain, paints along its width and places meshes along its length.
Remarks
[docs/plan/31 § T8]'s terrain half. Three operations over one curve, and all three are re-runnable: the deformation goes into a reserved Splines layer that is regenerated wholesale, the painting goes into the weightmap through the same redistribution every brush uses, and the mesh placement returns a list rather than writing one.
⚠ The deformation is non-destructive because of where it goes, not because of what it does. [§ D4]'s reserved layer is the whole mechanism: moving the road, changing its width or deleting it re-runs into the same layer and the author's own sculpting underneath is untouched. A road written into the base heightfield is a road that can never be moved.
⚠ Every sample within reach is visited once, from the curve's own bounding box. The alternative — walking the curve and stamping a brush at intervals — double-counts wherever two stamps overlap, which on a tight bend is most of the inside of the corner. A road stamped that way is deeper round its corners than along its straights.
Fields and properties (1)
public const float LocateStepHow many metres apart the deformation samples the curve when locating a point.
Methods (6)
public static TerrainRect Deform(Terrain terrain, TerrainEditLayer layer, Spline spline, in TerrainSplineProfile profile)Deforms the ground under a spline into an edit layer.
public static TerrainRect PaintAlong(Terrain terrain, Spline spline, int layer, in TerrainSplineProfile profile, float strength = 1)Paints a layer along the width of a spline.
public static IReadOnlyList<TerrainSplineMesh> PlaceAlong(Spline spline, IReadOnlyList<string> meshes, float spacing, uint seed = 2654435769, float jitter = 0)Places meshes along the length of a spline.
public static TerrainRect Regenerate(Terrain terrain, TerrainEditLayer layer, IEnumerable<(Spline Spline, TerrainSplineProfile Profile)> roads)Empties the spline layer and lays every road down again.
public static TerrainEditLayer LayerOf(Terrain terrain, string name = "Splines")The layer a terrain reserves for its splines, adding it if there is not one.
public static float Nearest(Spline spline, Vector2 ground, out float parameter)The nearest point of a curve to a place on the ground, measured horizontally.
Used by (2)
- TerrainSplineTestsVixen.Terrain.Tests
- TerrainModuleVixen.Editor.Terrain