trackBuilder/obstaclePlacer - Track Obstacle Placement
Reference for `extensions/util/trackBuilder/obstaclePlacer.lua`. Places static and procedural obstacles (rocks, ramps, rings, etc.) along track segments.
Reference for extensions/util/trackBuilder/obstaclePlacer.lua. Places static and procedural obstacles (rocks, ramps, rings, etc.) along track segments.
Exports
| Key | Signature | Description |
|---|---|---|
placeObstacles | (track) | Places all obstacles for the entire track |
placeProceduralObstacles | (segment) | Creates/updates procedural mesh obstacles for one segment |
clearReferences | () | Clears all cached obstacle object references |
Internals
- Static obstacles use predefined
.daeshapes:sharp1,sharp2,obstacle1,obstacle2(rocks and sharp angles from GridMap). - Procedural obstacles use
proceduralPrimitivesto generate:ring,cube,cylinder,cone,bump,ramp. - Object pooling: Static obstacles are pooled per type via
expandTruncateList. Excess objects are deleted; missing objects are created on demand. - Positioning:
getAdjustedPosRotWidth(o, piece)computes the world position/rotation by interpolating along the segment's points based ono.offset(0–1 normalized position along the piece). - Anchoring: Each obstacle has an
anchorvalue that offsets it laterally relative to the track width. - All objects are rotated 90° via
turn90quaternion to match the track coordinate system.
How It Works
placeObstacles(track)iterates all pieces, collecting static obstacle placement data.- For each obstacle type, the object pool is resized and objects are positioned/scaled/rotated.
- For each segment,
placeProceduralObstacleshandles procedural meshes:- Counts how many procedural obstacles the segment needs
- Creates/destroys
ProceduralMeshobjects to match - Generates the mesh geometry (ring, cube, etc.) and sets position/rotation
- The
obstaclesChangedflag on segments prevents unnecessary rebuilds.
-- Place all obstacles on the track
obstaclePlacer.placeObstacles(track)
-- Obstacle data structure on a piece:
piece.obstacles = {
{value = 'ring', variant = '', offset = 0.5, position = vec3(0,0,1),
rotation = quat(0,0,0,1), scale = vec3(2,0.5,1), anchor = 0,
material = 'track_editor_A_border'}
}Additional Exports
M.clearReferences- (undocumented)M.placeObstacles- (undocumented)M.placeProceduralObstacles- (undocumented)
trackBuilder/multiTrackMerger - Track Intersection Merging
Reference for `extensions/util/trackBuilder/multiTrackMerger.lua`. Creates procedural meshes at intersection points where multiple track segments meet, filling the gaps with bezier-interpolated surfac
trackBuilder/pieces - Track Piece Geometry Generation
Reference for `extensions/util/trackBuilder/pieces.lua`. Converts abstract track piece descriptions (forward, curve, spiral, loop, bezier) into concrete segment data with positions, headings, and cont