Files
jesse 1d23c187ad Daikoku PA: two perimeter ramps, far side served by the median opening
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.
2026-08-03 11:53:40 -04:00

149 lines
4.7 KiB
Luau

-- Verification v2: corrected geometric metrics.
--
-- v1 had two badly-written assertions (the CODE was fine, the TEST was wrong):
-- * seam lip used Position.Y + Size.Y/2, but decks are pitched by
-- CFrame.lookAt(mid, mid+dir, UP), so that is the centre height, not the
-- surface height at the seam. On a sloped segment it over-reports badly.
-- Correct: evaluate each deck's TOP SURFACE at the shared sample point.
-- * pier offset measured distance to the nearest sample, but piers sit at
-- segment MIDPOINTS and samples are 60 studs apart -- so ~30.0 is the
-- correct answer for a perfectly centred pier. Correct: perpendicular
-- distance to the centreline polyline.
local sss = game:GetService("ServerScriptService")
local orig = sss:FindFirstChild("MapBuilder", true)
local clone = orig:Clone()
clone.Name = "MapBuilder_Verify2"
clone.Parent = orig.Parent
local okM, MB = pcall(require, clone)
if not okM then
clone:Destroy()
return "FAIL require: " .. tostring(MB)
end
local okB, map = pcall(MB.build)
if not okB then
clone:Destroy()
return "FAIL build: " .. tostring(map)
end
local Circuit = require(game:GetService("ReplicatedStorage"):FindFirstChild("Circuit", true))
local samples = Circuit.samples
local n = #samples
local decks = {}
for _, d in ipairs(map:GetDescendants()) do
if d:IsA("BasePart") then
local idx = d.Name:match("^Road_(%d+)$")
if idx then
decks[tonumber(idx)] = d
end
end
end
local out = {}
local function line(s)
out[#out + 1] = s
end
-- TRUE SEAM LIP -------------------------------------------------------------
-- Deck i spans local z in [-Size.Z/2, +Size.Z/2] and is 2 studs longer than
-- its segment (deliberate overlap), so the shared sample point sits at
-- local z = +(Size.Z - 2)/2 for deck i and -(Size.Z - 2)/2 for deck i+1.
local worst, worstAt = 0, -1
local lips = {}
for i = 1, n do
local j = (i % n) + 1
local a, b = decks[i], decks[j]
if a and b then
local ta = (a.CFrame * CFrame.new(0, a.Size.Y / 2, (a.Size.Z - 2) / 2)).Y
local tb = (b.CFrame * CFrame.new(0, b.Size.Y / 2, -(b.Size.Z - 2) / 2)).Y
local lip = math.abs(ta - tb)
lips[#lips + 1] = { lip, i }
if lip > worst then
worst, worstAt = lip, i
end
end
end
table.sort(lips, function(p, q)
return p[1] > q[1]
end)
local top = {}
for k = 1, math.min(5, #lips) do
top[#top + 1] = ("i=%d:%.4f(%s)"):format(lips[k][2], lips[k][1], samples[lips[k][2]].piece)
end
line(("SEAM true max lip=%.4f at i=%d -> %s"):format(worst, worstAt, worst <= 0.30 and "PASS" or "FAIL"))
line("SEAM top5: " .. table.concat(top, " "))
-- Deck-width continuity: the taper must not jump more than a few studs
-- between neighbours, or the widening would look like a step in the road.
local maxJump, jumpAt = 0, -1
for i = 1, n do
local j = (i % n) + 1
if decks[i] and decks[j] then
local dw = math.abs(decks[i].Size.X - decks[j].Size.X)
if dw > maxJump then
maxJump, jumpAt = dw, i
end
end
end
line(("TAPER max width step=%.2f studs at i=%d -> %s"):format(maxJump, jumpAt, maxJump <= 6 and "PASS" or "FAIL"))
-- PIER LATERAL OFFSET -------------------------------------------------------
-- Perpendicular distance from each pier to the centreline polyline (XZ).
local function segDist(p, u, v)
local pu = Vector3.new(p.X - u.X, 0, p.Z - u.Z)
local uv = Vector3.new(v.X - u.X, 0, v.Z - u.Z)
local L2 = uv:Dot(uv)
if L2 < 1e-6 then
return pu.Magnitude
end
local t = math.clamp(pu:Dot(uv) / L2, 0, 1)
return (pu - uv * t).Magnitude
end
local worstPier, nPier = 0, 0
for _, d in ipairs(map:GetDescendants()) do
if d.Name == "OverpassPier" then
nPier += 1
local best = math.huge
for i = 1, n do
local j = (i % n) + 1
best = math.min(best, segDist(d.Position, samples[i].pos, samples[j].pos))
end
worstPier = math.max(worstPier, best)
end
end
line(
("PIER lateral offset from centreline: n=%d worst=%.3f studs -> %s"):format(
nPier,
worstPier,
(nPier > 0 and worstPier < 3) and "PASS" or "FAIL"
)
)
-- Girders must hang BELOW their deck, never poke through the driving surface.
local bad, nG = 0, 0
for _, d in ipairs(map:GetDescendants()) do
if d.Name == "BridgeGirder" then
nG += 1
local topY = d.Position.Y + d.Size.Y / 2
local best, bi = math.huge, nil
for i = 1, n do
local dd = (Vector3.new(samples[i].pos.X, 0, samples[i].pos.Z) - Vector3.new(d.Position.X, 0, d.Position.Z)).Magnitude
if dd < best then
best, bi = dd, i
end
end
if bi and decks[bi] then
local deckBottom = decks[bi].Position.Y - decks[bi].Size.Y / 2
if topY > deckBottom + 0.6 then
bad += 1
end
end
end
end
line(("GIRDER below deck: n=%d intruding=%d -> %s"):format(nG, bad, bad == 0 and "PASS" or "FAIL"))
map:Destroy()
clone:Destroy()
return table.concat(out, "\n")