Road Architect - Link
Manages end-to-end road link operations in the Road Architect. Handles detection of linkable road endpoints, link creation (joining two roads), and link removal (splitting joined roads).
Manages end-to-end road link operations in the Road Architect. Handles detection of linkable road endpoints, link creation (joining two roads), and link removal (splitting joined roads).
Public Functions
| Function | Signature | Description |
|---|---|---|
M.computePossibleLinks | (...) | Computes possible end-to-end road links |
M.joinRoads | (...) | Joins two roads at their endpoints |
M.computePossibleJct | (...) | Computes possible junction connections |
M.createSplitJunction | (...) | Creates a split junction |
Example: Linking Roads End-to-End
local link = require('editor/tech/roadArchitect/link')
-- Find link candidates near the selected road's endpoint
local candidates = link.getLinkCandidates(roads, map, selRoadIdx, selNodeIdx)
-- Preview a candidate link (for rendering)
if #candidates > 0 then
local preview = link.computeLinkPreview(candidates[1], roads, map)
-- preview used by render module to show proposed connection
end
-- Check if two endpoints are linkable
if link.isLinkable(road1, 1, road2, #road2.nodes) then
-- Create the link (merges road2 into road1)
link.createLink(roads, map, candidate)
end
-- Split a previously linked road back apart
link.removeLink(roads, map, roadIdx, splitNodeIdx)
-- Link constraints:
-- - Both endpoints must be within proximity threshold
-- - Neither road can be a junction road (isJctRoad)
-- - Roads must not already be the same road
-- - Endpoint headings should be roughly alignedNotes
- Linking merges the second road's nodes into the first road
- The second road is removed from the roads array after linking
- Unlinking creates a new road from the split-off portion
- Link preview is rendered by the render module as a dashed line
Functions
computePossibleLinks(rIdx1, nIdx1, rIdxs, nIdxs)
Computes possible links.
rIdx1(any)nIdx1(any)rIdxs(any)nIdxs(any)
Returns: links[bestIdx]
joinRoads(link)
Handles join roads.
link(any)
computePossibleJct(rIdx, nIdx, rIdxs, nIdxs)
Computes possible jct.
rIdx(any)nIdx(any)rIdxs(any)nIdxs(any)
Returns: nil
createSplitJunction(candJct)
Creates split junction.
candJct(any)
Returns: self
Functions
computePossibleLinks(rIdx1, nIdx1, rIdxs, nIdxs)
Computes possible links.
rIdx1(any)nIdx1(any)rIdxs(any)nIdxs(any)
Returns: links[bestIdx]
joinRoads(link)
Handles join roads.
link(any)
computePossibleJct(rIdx, nIdx, rIdxs, nIdxs)
Computes possible jct.
rIdx(any)nIdx(any)rIdxs(any)nIdxs(any)
Returns: nil
createSplitJunction(candJct)
Creates split junction.
candJct(any)
Returns: self
See Also
- Road Architect - Clothoid - Related reference
- Road Architect - Decals - Related reference
- Road Architect - Export - Related reference
- World Editor Guide - Guide
Road Architect - Junctions
Manages road junctions (intersections) in the Road Architect. Handles junction creation from road endpoints/midpoints, topology computation, lane connection mapping, and junction road generation.
Road Architect - Overlays
Manages road overlay elements in the Road Architect. Overlays are textured patches placed on top of road surfaces (e.g., crosswalks, road markings, patches). Handles overlay creation, positioning, mat