Drive Path Editor - Record
Records a vehicle's driven path into a new drive path spline. Samples position and velocity at a fixed interval, deduplicates close nodes, applies RDP simplification, and links the result to the recor
Records a vehicle's driven path into a new drive path spline. Samples position and velocity at a fixed interval, deduplicates close nodes, applies RDP simplification, and links the result to the recording vehicle.
Public API
| Function | Signature | Description |
|---|---|---|
M.getRecordingTime | () → number | Returns total elapsed recording time in seconds |
M.handleRecord | () | Per-frame update: samples vehicle position/velocity at recording frequency |
M.startRecord | (vehicle) | Begins recording: enters vehicle, clears buffers, records initial point |
M.stopRecord | (sceneVehicles) | Ends recording: creates spline, deduplicates, simplifies, links vehicle |
Recording Constants
| Constant | Value | Description |
|---|---|---|
recordingFreq | 1.0s | Sampling interval |
rdpTol | 3.0 | RDP simplification tolerance |
defaultWidth | 10.0m | Default spline width |
defaultVelLimit | 100.0 m/s | Default velocity limit per node |
minVelocity | 3.0 m/s | Minimum recorded velocity |
closeTolSq | 4.1 m² | Squared distance threshold for deduplication |
Recording Flow
startRecord(vehicle)
→ be:enterVehicle(0, vehicle.veh)
→ Record initial position + velocity
→ Reset timers
handleRecord() (called each frame)
→ Accumulate dt
→ Every recordingFreq seconds:
→ Sample position and velocity
→ Append to buffers
stopRecord(sceneVehicles)
→ Create new drive path spline named "Recorded_<vehicleName>"
→ Copy recorded nodes/velocities
→ Remove duplicates within closeTolSq
→ RDP simplify with rdpTol
→ Set default widths, normals, velocity limits
→ Link spline to recording vehicleUsage Example
local record = require('editor/drivePathEditor/record')
-- Start recording selected vehicle
record.startRecord(sceneVehicles[selectedIdx])
-- Each frame during recording:
record.handleRecord()
-- Stop and create spline:
record.stopRecord(sceneVehicles)
-- New spline is now in splineMgr.getDrivePathSplines()Dependencies
| Module | Purpose |
|---|---|
editor/drivePathEditor/splineMgr | addNewDrivePathSpline(), spline data access |
editor/toolUtilities/rdp | simplifyNodesVels() for path simplification |
See Also
- Drive Path Editor - Playback - Related reference
- Drive Path Editor - Spline Manager - Related reference
- World Editor Guide - Guide
Drive Path Editor - Playback
Handles AI playback of all linked drive path splines/vehicles. Starts vehicles at their spline's starting node, waits for each spline's delay time, then commands AI driving via `ai.driveUsingPath` in
Drive Path Editor - Spline Manager
Core data manager for drive path splines. Handles creation, deletion, splitting, joining, flipping, deep copying, serialization/deserialization, vehicle linking, nav graph caching, and geometry update