Rework the PA junction to match the reference drawing: yellow = PA -> highway (entry), red = highway -> PA (exit). Entry and exit swap sides (entry now EAST, exit WEST) and both trunks hug the PA perimeter instead of running concentric spirals. The simplification: both carriageways sit at the same deck level, adjacent, so the median opening IS the far-side access path. The under-deck crossing and merge runs are deleted outright -- 8 runs collapse to 4, and the girder-soffit ceiling logic that constrained the crossing goes with them. Part count 24,210 -> 21,691. The median opening is now load-bearing rather than cosmetic (it is the only route from the far carriageway to the ramps), so it widens from 6 to 9 samples per junction. Orientation is a single flip-able constant (ORIENT) so a mirrored result is a one-line correction, not a rewrite. Measured on the built map (not asserted): - 600 entry + 600 exit ramp parts - max grade 8.00% / 8.27%, under the 9% limit - 0 collisions with piers/masts/girders (558 structural parts) - segment continuity <= 2.5 studs; trunk->merge handoff <= 1.7 studs - merge lands at dY 0.0 (exact deck level), 33 studs lateral - median open at junctions: 0 parts vs. control ~7 on plain mainline Two traps worth recording, both caught by controls: 1. Studio's require() cache silently rebuilt STALE code. The first "passing" build reported 17,575 parts and zero ramps, and the map contained PAOffRamp/PAOnRamp parts whose names exist nowhere in the current source. Every measurement taken before this was describing an old map. Added tools/rebuild_fresh.luau, which clones the module to bust the cache; use it rather than requiring MapBuilder directly. 2. A reported "median never opens" bug was a bad probe, not a defect. It counted `Barrier` (the outer edge parapet, which must NEVER open) instead of `Median_<i>`. Re-run against the right name: control 7, junctions 0. Both were only visible because the probes carry controls -- a 0-hit result with no control is vacuous. The verification harnesses are kept in tools/ with their controls built in.
140 lines
3.3 KiB
Luau
140 lines
3.3 KiB
Luau
-- Triage the obstacle hits: WHAT is hit, on WHICH segments, and how far
|
|
-- through the run. Contact with the apron at the ring mouth and with the
|
|
-- carriageway at the merge is intended; contact with a pier is never.
|
|
-- SAFETY: MapBuilder.build() destroys Workspace.Map first. Stash the live map
|
|
-- aside and restore it afterwards -- see verify_shared_ramps.luau.
|
|
local ServerScriptService = game:GetService("ServerScriptService")
|
|
local live = workspace:FindFirstChild("Map")
|
|
local stash = nil
|
|
if live then
|
|
stash = Instance.new("Folder")
|
|
stash.Name = "__MAP_STASH__"
|
|
stash.Parent = ServerScriptService
|
|
live.Parent = stash
|
|
end
|
|
local function restoreLive()
|
|
if stash then
|
|
local held = stash:FindFirstChild("Map")
|
|
local rebuilt = workspace:FindFirstChild("Map")
|
|
if rebuilt then
|
|
rebuilt:Destroy()
|
|
end
|
|
if held then
|
|
held.Parent = workspace
|
|
end
|
|
stash:Destroy()
|
|
end
|
|
end
|
|
|
|
local out = {}
|
|
local function log(...)
|
|
table.insert(out, table.concat({ ... }, " "))
|
|
end
|
|
|
|
local src = ServerScriptService:FindFirstChild("Server")
|
|
src = src and src:FindFirstChild("MapBuilder") or ServerScriptService:FindFirstChild("MapBuilder", true)
|
|
local MapBuilder = require(src:Clone())
|
|
local map = MapBuilder.build and MapBuilder.build() or MapBuilder.Build()
|
|
map.Name = "TRIAGE_CLONE"
|
|
map.Parent = workspace
|
|
|
|
local RUNS = {
|
|
"PAEntryRampTrunk",
|
|
"PAEntryRampNear",
|
|
"PAEntryRampCross",
|
|
"PAEntryRampMerge",
|
|
"PAExitRampTrunk",
|
|
"PAExitRampNear",
|
|
"PAExitRampCross",
|
|
"PAExitRampMerge",
|
|
}
|
|
local deckOf = {}
|
|
for _, r in ipairs(RUNS) do
|
|
deckOf[r] = {}
|
|
end
|
|
for _, d in ipairs(map:GetDescendants()) do
|
|
if d:IsA("BasePart") then
|
|
for _, r in ipairs(RUNS) do
|
|
local idx = d.Name:match("^" .. r .. "_(%d+)$")
|
|
if idx then
|
|
table.insert(deckOf[r], { i = tonumber(idx), p = d })
|
|
end
|
|
end
|
|
end
|
|
end
|
|
for _, r in ipairs(RUNS) do
|
|
table.sort(deckOf[r], function(a, b)
|
|
return a.i < b.i
|
|
end)
|
|
end
|
|
|
|
local function isRampPart(p)
|
|
local n = p.Name
|
|
if n:find("PARamp") or n:find("PARing") then
|
|
return true
|
|
end
|
|
for _, r in ipairs(RUNS) do
|
|
if n:sub(1, #r) == r then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- Normalise an obstacle name to its class (Road_537 -> Road_).
|
|
local function klass(n)
|
|
if n:sub(1, 5) == "Road_" then
|
|
return "Road_*"
|
|
end
|
|
return (n:gsub("_%d+$", "_*"))
|
|
end
|
|
|
|
for _, r in ipairs(RUNS) do
|
|
local segs = deckOf[r]
|
|
local byClass = {}
|
|
for k, e in ipairs(segs) do
|
|
local params = OverlapParams.new()
|
|
params.FilterType = Enum.RaycastFilterType.Include
|
|
params.FilterDescendantsInstances = { map }
|
|
params.MaxParts = 60
|
|
for _, o in ipairs(workspace:GetPartsInPart(e.p, params)) do
|
|
if o ~= e.p and not isRampPart(o) then
|
|
local c = klass(o.Name)
|
|
local rec = byClass[c]
|
|
if not rec then
|
|
rec = { lo = k, hi = k, n = 0 }
|
|
byClass[c] = rec
|
|
end
|
|
rec.lo = math.min(rec.lo, k)
|
|
rec.hi = math.max(rec.hi, k)
|
|
rec.n += 1
|
|
end
|
|
end
|
|
end
|
|
local any = false
|
|
for c, rec in pairs(byClass) do
|
|
any = true
|
|
log(
|
|
string.format(
|
|
"%-18s %-16s segs %d..%d of %d (%.0f%%..%.0f%% along) %d contacts",
|
|
r,
|
|
c,
|
|
rec.lo,
|
|
rec.hi,
|
|
#segs,
|
|
rec.lo / #segs * 100,
|
|
rec.hi / #segs * 100,
|
|
rec.n
|
|
)
|
|
)
|
|
end
|
|
if not any then
|
|
log(string.format("%-18s CLEAN", r))
|
|
end
|
|
end
|
|
|
|
map:Destroy()
|
|
restoreLive()
|
|
log(string.format("live map restored: %s", tostring(workspace:FindFirstChild("Map") ~= nil)))
|
|
return table.concat(out, "\n")
|