Rally Driveline V3
Third-generation driveline system for rally stages. Loads recorded driveline data from recce sessions, simplifies it using RDP algorithm, generates smooth Catmull-Rom splines, and produces final drive
Third-generation driveline system for rally stages. Loads recorded driveline data from recce sessions, simplifies it using RDP algorithm, generates smooth Catmull-Rom splines, and produces final driveline points. Supports editing, rendering, and saving.
Constructor
local DrivelineV3 = require('/lua/ge/extensions/gameplay/rally/driveline/drivelineV3')
local dv3 = DrivelineV3(missionDir)Public API
| Method | Signature | Returns | Description |
|---|---|---|---|
init | (missionDir) | nil | Initializes with mission directory |
loadFromRecording | () | bool | Full pipeline: load → simplify → smooth → finalize |
loadRecceRecording | () | bool | Loads raw driveline points from recce recording |
loadFinalDrivelineFromFile | () | bool | Loads a pre-saved final driveline JSON |
convertDrivelineToSpline | (drivelinePoints?) | bool | RDP-simplifies points into a spline structure |
updateSplineGeometry | () | bool | Computes smooth Catmull-Rom subdivisions |
createDrivelineFromSpline | () | bool | Generates final points from spline |
getFinalPointList | () | PointList/nil | Returns final points as a PointList object |
deepCopySpline | () | table/nil | Deep copies spline data (for undo/redo) |
getSpeedLimitKph | () | number | Returns configured speed limit (default 100) |
calculateDistanceBetweenPoints | (p1, p2) | number | Distance along the final driveline between two world positions |
renderRawDriveline | () | nil | Draws raw points as pink cylinders |
renderSmoothCurve | () | nil | Draws subdivided spline as blue cylinders |
renderFinalDriveline | () | nil | Draws final points as red cylinders |
renderSpline | (selectedNodeIdx) | nil | Draws editable spline nodes |
Internals
| Field | Type | Description |
|---|---|---|
missionDir | string | Mission directory path |
rawDrivelinePoints | table/nil | Original recorded driveline points |
spline | table/nil | Editable spline structure (nodes, widths, normals, subdivisions) |
finalDrivelinePoints | table/nil | Generated output points |
simplificationTolerance | number | RDP tolerance (default 1.0) |
properties.speedLimitKph | number | Speed limit for the driveline (default 100) |
Processing Pipeline
- Load:
loadRecceRecording()reads recorded points from the mission's recce directory - Simplify:
convertDrivelineToSpline()applies RDP (Ramer-Douglas-Peucker) algorithm to reduce node count while preserving shape - Smooth:
updateSplineGeometry()runsgeom.catmullRomRaycastto generate subdivided points with terrain conformance - Finalize:
createDrivelineFromSpline()converts subdivided positions to full point structures with quaternions, normals, and linked-list relationships
Final Point Structure
Each final point contains: pos, quat, ts, normal, prev, next, id, pacenoteDistances, cachedPacenotes
How It Works
- Raw driveline is recorded during recce (driving the stage slowly)
- RDP simplification reduces thousands of points to key shape-defining nodes
- Catmull-Rom spline interpolation creates smooth subdivisions between nodes
- Terrain raycasting (
catmullRomRaycast) snaps subdivisions to ground height - Final points get direction quaternions and terrain-aligned normals
- The result can be saved as JSON or used directly by
DrivelineRoute
Usage Examples
-- Full loading pipeline
local dv3 = DrivelineV3("/levels/west_coast/rally/stage1/")
if dv3:loadFromRecording() then
local pointList = dv3:getFinalPointList()
-- use with DrivelineRoute
end
-- Load pre-saved final driveline
local dv3 = DrivelineV3(missionDir)
if dv3:loadFinalDrivelineFromFile() then
-- ready to use
end
-- Calculate distance between two positions along the driveline
local dist = dv3:calculateDistanceBetweenPoints(posA, posB)Notes
- Uses
editor/toolUtilities/rdpfor RDP simplification - Uses
editor/toolUtilities/geomfor Catmull-Rom spline computation - Default simplification tolerance: 1.0 meters (configurable)
- Minimum spline divisions: 10; minimum spacing: 2.0 meters
calculateDistanceBetweenPointsuses xnorm projection for sub-segment precision- Rendering methods use
debugDrawerfor visualization in the editor
| Function | Signature | Returns | Description |
|---|---|---|---|
M.createDrivelinePointsFromPositions | (positions) | nil | createDrivelinePointsFromPositions |
See Also
- Rally Driveline Measurement - Related reference
- Rally Driveline Route - Related reference
- Rally Driveline Point List - Related reference
- Gameplay Systems Guide - Guide
Rally Driveline Route
The core driveline routing system for rally stages. Merges race pathnodes and pacenote waypoints into a navigable route, tracks the vehicle's position along it, and triggers pacenote audio events base
Rally Driveline Point List
Container class for a series of points along a rally driveline path. Provides point creation, relationship management, normal calculation, length computation, nearest-point search, and debug rendering