Snap-to-Road
Provides snap-to-road functionality in the world editor's rally editor. Wraps a driveline (linked list of points) with spatial queries, point partitioning, filtering, camera path playback, and debug v
Provides snap-to-road functionality in the world editor's rally editor. Wraps a driveline (linked list of points) with spatial queries, point partitioning, filtering, camera path playback, and debug visualization.
Constructor
local Snaproad = require('/lua/ge/extensions/gameplay/rally/snaproad')
local sr = Snaproad(driveline)Public API - Navigation
| Function | Signature | Returns | Description |
|---|---|---|---|
C:closestSnapPoint | (source_pos, useAllPoints) | point | Finds closest driveline point to a world position |
C:closestSnapPos | (source_pos) | vec3 | Returns position of closest snap point |
C:nextSnapPoint | (srcPos) | point | Next point forward from closest to srcPos |
C:prevSnapPoint | (srcPos) | point | Previous point backward from closest to srcPos |
C:firstSnapPoint | () | point | First point in the driveline |
C:pointsBackwards | (fromPoint, steps, limitPoints) | point | Walk N steps backward, respecting limit points |
C:pointsForwards | (fromPoint, steps, limitPoints) | point | Walk N steps forward, respecting limit points |
C:distanceBackwards | (fromPoint, meters, limitPoints) | point | Walk backward by distance in meters |
C:distanceForwards | (fromPoint, meters, limitPoints) | point | Walk forward by distance in meters |
C:normalAlignPoints | (point) | prev, current, next | Gets alignment points for normal calculation |
C:forwardNormalVec | (point) | vec3 | Forward normal vector at a point |
M.init | (driveline) | nil | init |
M.groupPointsByCornerCall | (points) | nil | groupPointsByCornerCall |
M.prevSnapPos | (srcPos) | nil | prevSnapPos |
M.nextSnapPos | (srcPos) | nil | nextSnapPos |
M.setPartitionToFilter | () | nil | setPartitionToFilter |
M.partitionAllEnabled | () | nil | partitionAllEnabled |
M.toggleCornerCalls | () | nil | toggleCornerCalls |
Public API - Partitioning
| Function | Signature | Returns | Description |
|---|---|---|---|
C:setPartitionToPacenote | (pn) | nil | Partitions points around a pacenote (CS→CE) |
C:clearPartition | () | nil | Clears single-pacenote partition |
C:partitionAllPacenotes | (notebook) | nil | Partitions all points by all pacenotes |
C:clearAll | () | nil | Clears all partitioning and filtering |
C:measurePartition | () | nil | Measures geometry of current partition via geoPacenotes |
C:updateHalfpoint | (pn) | nil | Recalculates midpoint between CS and CE on snaproad |
Public API - Filtering
| Function | Signature | Returns | Description |
|---|---|---|---|
C:setFilter | (wp) | nil | Constrains navigation to valid range for a waypoint |
C:clearFilter | () | nil | Removes navigation filter |
C:setFilterToAllPartitions | () | nil | Sets filter to all inter-pacenote partitions |
C:setFilterPartitionPoint | (point) | nil | Sets filter to the partition containing a point |
Public API - Visualization & Camera
| Function | Signature | Returns | Description |
|---|---|---|---|
C:drawDebugSnaproad | (clrOverride) | nil | Draws snaproad points (respects partition/filter state) |
C:drawDebugRecceApp | () | nil | Draws for recce app (with height adjustment) |
C:drawDebugCameraPlaying | () | nil | Draws CS/CE markers and focus points during camera playback |
C:setGlobalOpacity | (opacity) | nil | Sets rendering opacity (0-1) |
C:playCameraPath | () | nil | Plays camera along partition with buffers |
C:stopCameraPath | () | nil | Stops camera playback |
C:pointsForCameraPath | (bufferBefore, bufferAfter) | table | Gets points for camera path (default 40m before, 20m after) |
How It Works
Point Structure
Each driveline point has: id, pos (vec3), prev/next (linked list), partition (reference), optional cachedPacenotes.
Partition States
The snaproad operates in three modes:
- Default - shows all points
- Single partition - highlights CS→CE focus area with before/after context
- All partitions - splits entire driveline by all pacenotes (used for Ctrl+click new pacenote creation)
Waypoint Filter Logic
When a waypoint is selected for movement:
- CS selected: Can move backward to previous CE, forward to own CE
- CE selected: Can move backward to own CS, forward to next CS
Corner Call Visualization
Groups points by steering angle into subgroups with gradient colors (red→yellow→green), labeling each group with the corner call string.
-- Snap a position to the road
local sr = Snaproad(driveline)
local point = sr:closestSnapPoint(worldPos)
local snappedPos = point.pos
-- Partition around a pacenote for editing
sr:setPartitionToPacenote(pacenote)
sr:drawDebugSnaproad()See Also
- Rally Audio Manager - Related reference
- Rally Camera Path Player - Related reference
- Rally Client - Related reference
- Gameplay Systems Guide - Guide
Rally Settings Manager
Loads and provides access to mission-level rally settings (notebook filename, selected codriver). Wraps the `MissionSettings` class for convenience.
Traffic Exclusion Zones
Creates traffic exclusion zones around rally stage infrastructure (start positions, pathnodes) to prevent AI traffic from interfering with rally routes. Zones are applied to the navgraph via `map.setT