API ReferenceGE ExtensionseditortoolUtilities
Editor Tool Utilities – Terrain Painter
Paints terrain materials underneath a spline by rasterising the spline polygon to the terrain grid. Supports revertable operations with stored undo data.
Paints terrain materials underneath a spline by rasterising the spline polygon to the terrain grid. Supports revertable operations with stored undo data.
Public API
| Function | Signature | Description |
|---|---|---|
M.paint | (group) | Paints the terrain under the spline using group.paintMaterialIdx and group.paintMargin. Stores undo data in the group |
M.revert | (group) | Reverts terrain materials to pre-paint state using stored undo data |
M.revertAll | (groups) | Reverts all groups' terrain painting |
Code Examples
local terrainPainter = require('editor/toolUtilities/terrainPainter')
-- Configure the spline group for painting
myGroup.paintMaterialIdx = 3 -- terrain material index to paint
myGroup.paintMargin = 2.0 -- extra margin beyond spline width (meters)
myGroup.paintedDataX = {} -- storage for undo X coords
myGroup.paintedDataY = {} -- storage for undo Y coords
myGroup.paintedDataVals = {} -- storage for original material indices
-- Paint the terrain under the spline
terrainPainter.paint(myGroup)
-- Revert to original materials
terrainPainter.revert(myGroup)
-- Revert all groups at once (e.g., on tool deactivation)
terrainPainter.revertAll(allGroups)
-- The paint algorithm:
-- 1. Computes AABB of spline division points + paint margin
-- 2. Builds polygon from left/right edge points (binormals * half width)
-- 3. Rasterises polygon using scanline spans
-- 4. For each grid point inside the polygon:
-- - Stores the old material index for undo
-- - Sets the new material index
-- - Marks the point in a set-mask to avoid double-writes
-- 5. Updates terrain grid materials and heightmap
-- 6. Stores all undo data in the group tableSee 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 – Style
Centralised style configuration for spline-editing tools. Provides debug-draw colours, line thicknesses, sphere scales, pulse animation parameters, and ImGui colour theme palettes.
Editor Tool Utilities – Util
Common utility functions shared across spline-editing tools. Provides mouse interaction, raycasting, unit conversions, colour generation, spline helpers, GLTF export, and PNG debug output.