Pacenote Generator
Simplified corner detection system that generates pacenotes from driveline points. Analyzes road geometry using circle-fitting to identify direction changes, then groups consecutive nodes into corners
Simplified corner detection system that generates pacenotes from driveline points. Analyzes road geometry using circle-fitting to identify direction changes, then groups consecutive nodes into corners with simplification passes.
Public API
| Function | Signature | Returns | Description |
|---|---|---|---|
M.detectCorners | (pointList, params?) | table | Detects corners from driveline points; returns corner descriptors |
Default Parameters
M.defaultParams = {
lookAheadContext = 7, -- Nodes to look ahead/behind for direction
straightThreshold = 5.0, -- Degrees below which is "straight"
mergeDistanceThreshold = 0.2, -- Meters threshold for merging straights
maxSimplifyIterations = 10 -- Max simplification passes
}Internals
Key Local Functions
| Function | Description |
|---|---|
circleCenterAndAngle(p1, p2, p3) | Fits circle through 3 points; returns center and arc angle |
computeNodeData(route, params) | Annotates nodes with direction, angle, radius, center |
computeCornerData(corner) | Aggregates length and angle from corner's nodes |
splitRouteIntoCorners(route) | Splits at direction changes into corner segments |
simplifyConsecutive(corners) | Merges consecutive corners with same direction |
simplifyStraightsExtendNext(corners, threshold) | Extends straights by absorbing inline next nodes |
simplifyCorners(corners, params) | Iterative simplification loop |
Corner Detection Pipeline
- Convert: Input points → route array with
posandid - Annotate: For each node, look ±
contextnodes, fit circle, compute:direction: "" (straight), " right", or " left" (via cross product sign)angle: arc angle (0 if belowstraightThreshold)radius: distance from point to fitted circle center
- Split: Create new corner segment whenever direction changes
- Simplify: Iteratively merge straights that extend along a line + consecutive same-direction corners
Output Format
{
{
pos = vec3, -- first node position (corner start)
posEnd = vec3, -- last node position (corner end)
direction = string, -- "" | " right" | " left"
angle = number, -- total arc angle in degrees
length = number, -- total corner length in meters
nodes = table -- array of annotated route nodes
},
...
}Direction Detection
Uses 2D cross product (Z component) of consecutive segments:
local cross = (p3z - p2z):cross(p2z - p1z).z
-- cross > 0 → right, cross < 0 → leftHow It Works
- Caller provides array of driveline points (with
.posproperty or as vec3) - Points are converted to route nodes and annotated with geometry data
- Route is split into corners at each direction change
- Simplification merges inline straights and consecutive same-direction corners
- Returns array of corner descriptors used by notebook to create pacenotes
Adapted from geometry.lua but simplified to focus only on corner detection without velocity/severity calculations.
Usage Example
local generator = require('gameplay/rally/notebook/pacenoteGenerator')
-- Detect corners from driveline points
local corners = generator.detectCorners(drivelinePoints)
-- With custom parameters
local corners = generator.detectCorners(drivelinePoints, {
lookAheadContext = 5,
straightThreshold = 3.0,
mergeDistanceThreshold = 0.5,
maxSimplifyIterations = 15
})
-- Use results to generate pacenotes
for _, corner in ipairs(corners) do
if corner.direction ~= "" then
-- Create pacenote for this corner
end
endSee Also
- Rally Codriver - Related reference
- Rally Mission Settings - Related reference
- Rally Pacenote - Related reference
- Gameplay Systems Guide - Guide
Rally Pacenote
Core class representing a single pacenote in a rally notebook. Manages note text (freeform + structured), waypoints (corner start/end), audio compilation, validation, debug drawing, trigger types, and
Pacenote Waypoint
Class representing a waypoint within a pacenote. Each pacenote has typically two waypoints: a Corner Start (CS) and Corner End (CE). Waypoints define 3D positions with normals for intersection planes