Editor Tool Utilities – Riverbed Terraforming
Terraforms terrain beneath a spline to create riverbeds. Modifies terrain heightmap using cross-sectional depth profiles with bank sharpness, smoothing, and revert support.
Terraforms terrain beneath a spline to create riverbeds. Modifies terrain heightmap using cross-sectional depth profiles with bank sharpness, smoothing, and revert support.
Public API
| Function | Signature | Description |
|---|---|---|
M.terraform | (spline) | Terraforms a riverbed under the spline using bedDepth, bankSharpness, excess, and smoothingLevel properties. Stores undo data in the spline |
M.revert | (spline) | Reverts the terrain to its pre-terraformed state using stored undo data |
M.revertAll | (splines) | Reverts all splines' riverbed terraforming |
Code Examples
local riverbed = require('editor/toolUtilities/riverbed')
-- Configure the spline's riverbed parameters
mySpline.bedDepth = 3.0 -- depth at center (meters)
mySpline.bankSharpness = 2.0 -- exponent for bank profile (higher = steeper banks)
mySpline.excess = 5.0 -- extra margin beyond spline width (meters)
mySpline.smoothingLevel = 3 -- blur passes for smoothing
-- Also need empty storage arrays
mySpline.riverbedDataX = {}
mySpline.riverbedDataY = {}
mySpline.riverbedDataVals = {}
-- Terraform the riverbed
riverbed.terraform(mySpline)
-- Revert to original terrain
riverbed.revert(mySpline)
-- Revert all splines at once
riverbed.revertAll(allSplines)
-- The algorithm:
-- 1. Computes a polygon outline around the spline + excess margin
-- 2. Rasterises the polygon to terrain grid using scanline spans
-- 3. For each grid point, finds nearest spline point via spatial hash
-- 4. Applies cross-sectional carving: depth * (1 - t^bankSharpness)
-- 5. Tapers carving near spline endpoints (smoothstep ramp)
-- 6. Applies blur passes with lateral fade weighting
-- 7. Stores all old Z values for undo/revertSee Also
- Tool Utilities - Fit Polyline - Related reference
- Editor Tool Utilities – Geometry - Related reference
- Editor Tool Utilities – Gizmo - Related reference
- World Editor Guide - Guide
Editor Tool Utilities – Ribbon Input
Handles mouse and keyboard interaction for ribbon splines (paired L-R node structures). Supports adding node pairs, dragging nodes, deleting pairs, gizmo control, and cursor-segment tracking.
Editor Tool Utilities – Road Design Standards
Provides preset road design standards for homologation analysis. Each preset defines maximum slope, minimum curve radius, maximum banking, and width gradient tolerances.