Road Spline Import
Handles importing DecalRoad objects into road spline groups - supports both direct selection and polygon-based selection, computing reference splines and relative layer properties.
Handles importing DecalRoad objects into road spline groups - supports both direct selection and polygon-based selection, computing reference splines and relative layer properties.
Public API
| Function | Signature | Description |
|---|---|---|
M.importSelectedIntoNewGroup | (decalRoads) | Imports selected DecalRoad objects into a new road spline group |
M.importFromPolygon | (polygon) | Finds all DecalRoads with nodes inside the polygon and imports them |
Import Pipeline
- Backup selected DecalRoads for undo restoration
- Compute reference spline - estimates the centerline by finding edges of the combined DecalRoad selection using exponential + binary search
- Create layers from each DecalRoad relative to the reference spline (lateral offset, width tracking, flip detection)
- Simplify the reference spline using RDP algorithm
- Delete the original DecalRoad objects (restoreable via undo)
Key Internal Functions
| Function | Purpose |
|---|---|
computeReferenceSpline(decalRoads) | Computes centerline by edge-finding along the longest road's polyline |
createLayersFromDecalRoads(decalRoads, refNodes, refWidths) | Creates layers with computed lateral offset, flip, and track-width flags |
findEdgeDistance(origin, dir, numDecalRoads) | Binary search for polygon edge distance along a direction |
backupDecalRoads(decalRoads) | Creates restorable backup data for undo operations |
Usage Example
-- Import via polygon selection (used by the road spline tool's polygon mode):
local polygon = { vec3(0,0,0), vec3(100,0,0), vec3(100,100,0), vec3(0,100,0) }
extensions.editor_roadSpline_import.importFromPolygon(polygon)
-- Import specific DecalRoad objects:
local roads = { scenetree.findObject("myRoad1"), scenetree.findObject("myRoad2") }
extensions.editor_roadSpline_import.importSelectedIntoNewGroup(roads)Notes
- Uses exponential expansion + binary refinement (8 iterations) for edge finding
- Maximum search distance: 50m laterally
- Flip detection uses majority-vote dot product comparison
- Width tracking tolerance: 0.1m
Functions
importFromPolygon(polygon)
Imports from polygon.
polygon(any)
Returns: self
importFromPolygon(polygon)
Imports from polygon.
polygon(any)
Returns: self
Functions
importFromPolygon(polygon)
Imports from polygon.
polygon(any)
Returns: self
importFromPolygon(polygon)
Imports from polygon.
polygon(any)
Returns: self
See Also
- Road Spline Group Manager - Related reference
- Road Spline Layer Manager - Related reference
- World Editor Guide - Guide
Road Spline Group Manager
Backend manager for road spline groups - handles creation, removal, splitting, joining, serialization, terrain painting, and undo/redo operations.
Road Spline Layer Manager
Manages the DecalRoad layers within road spline groups - handles layer creation, removal, duplication, chunking for long splines, and all auto-generated detail layer types.