API ReferenceGE ExtensionseditorvehicleEditorliveEditor
Vehicle Editor - Node Triangle Self Collision Detector
Detects and visualizes nodes that are within collision radius of triangles they don't belong to, highlighting potential self-collision issues in JBeam vehicle data.
Detects and visualizes nodes that are within collision radius of triangles they don't belong to, highlighting potential self-collision issues in JBeam vehicle data.
Module Exports
| Export | Type | Description |
|---|---|---|
M.menuEntry | string | "Node Triangle Self Collision Detector" - menu label |
M.open | function | Opens the detector window |
M.onVehicleEditorRenderJBeams | hook | Draws detected collision pairs in 3D |
M.onUpdate | hook | Renders the ImGui controls window |
M.onSerialize | hook | Persists window state and results |
M.onDeserialized | hook | Restores persisted state |
Key Internals
| Variable | Type | Purpose |
|---|---|---|
windowOpen | BoolPtr | Window visibility toggle |
nodeCollisionRadiusPtr | FloatPtr | Adjustable collision radius (default 0.025 m) |
vehsResultData | table | Stores per-vehicle analysis results keyed by vehicle ID |
How It Works
Analysis Phase (analyze())
- Collects all coupler nodes from vehicle data (excluded from checks)
- Iterates every triangle × every node combination
- Skips a node if:
- It's part of the triangle
- Has
collision == falseorselfCollisiondisabled - Is a coupler node (has
couplerTagortag) - Shares a
firstGroupwith any triangle node - Triangle is
NONCOLLIDABLE
- Computes
nodePos:triangleClosestPoint(triPos1, triPos2, triPos3)distance - If distance ≤ collision radius, records the node-triangle pair with distance
Render Phase (onVehicleEditorRenderJBeams)
- Draws orange spheres at colliding node positions
- Draws green solid triangles for affected triangles
- Labels nodes and triangles with their IDs/names
Lua Code Example
-- Open the self-collision detector
extensions.editor_vehicleEditor_liveEditor_veNodeTriSelfCollisionDetector.open()
-- The ImGui window provides:
-- - Slider: Node Collision Radius (0.025 to 0.1 m)
-- Note: 0.025 m is the actual collision radius in the physics engine
-- - "Start Analysis" button - runs the O(nodes × triangles) check
-- - "Clear Results" button - clears stored collision data
-- Analysis skips nodes that share a firstGroup with triangle nodes:
-- if triNode1.firstGroup == firstNodeGroup
-- or triNode2.firstGroup == firstNodeGroup
-- or triNode3.firstGroup == firstNodeGroup then
-- goto skipNode
-- end
-- Triangle closest point distance check:
-- local closestPoint = nodePos:triangleClosestPoint(triPos1, triPos2, triPos3)
-- local distSqr = nodePos:squaredDistance(closestPoint)
-- if distSqr <= nodeCollisionRadiusSqr then
-- -- Record collision pair
-- end
-- Results are printed to console with format:
-- "Node 42 (fr1) is colliding with triangle 10 (fr1) - 11 (fr2) - 12 (fr3) at distance 0.015 m"
-- Coupler nodes are excluded via jbeamTableSchema processing:
-- jbeamTableSchema.processTableWithSchemaDestructive(couplerNodesCopy, newCouplerNodePairs)
-- Visualization uses debug drawer for live 3D overlay:
-- debugDrawer:drawSphere(nodePos, resultData.nodeCollisionRadius, orangeColor)
-- debugDrawer:drawTriSolid(triPos1, triPos2, triPos3, greenColor255)
-- Results persist across serialization for each vehicle ID
-- vehsResultData[vehicleID] = { nodeCollisionRadius, nodeTriPairs }See Also
- Adjustable Tech Car Tuner - Related reference
- Aero Debug - Related reference
- Crash Tester - Related reference
- World Editor Guide - Guide
Vehicle Editor - Lights Debug
Visualizes spotlight and point light props on the active vehicle in the Vehicle Editor, drawing debug spheres, direction arrows, and labels in 3D.
Vehicle Editor - Powertrain Inspector
Displays live powertrain device data and JBeam definitions for the active vehicle in the Vehicle Editor, allowing inspection of engines, transmissions, and other drivetrain components.