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

78 lines
2.4 KiB
Luau

-- Diagnose the raycast outlier: report WHICH parts the rays hit.
-- The v3 raycast filtered on the whole map, so overhead geometry (overpass
-- decks, girders, gantries, tunnel ceilings) can be hit before the road.
local sss = game:GetService("ServerScriptService")
local orig = sss:FindFirstChild("MapBuilder", true)
local clone = orig:Clone()
clone.Name = "MapBuilder_Diag"
clone.Parent = orig.Parent
local MB = require(clone)
local map = MB.build()
local Circuit = require(game:GetService("ReplicatedStorage"):FindFirstChild("Circuit", true))
local samples = Circuit.samples
local n = #samples
local rp = RaycastParams.new()
rp.FilterType = Enum.RaycastFilterType.Include
rp.FilterDescendantsInstances = { map }
local out = {}
-- Road-only params: what the driver actually touches.
local roadOnly = RaycastParams.new()
roadOnly.FilterType = Enum.RaycastFilterType.Include
roadOnly.FilterDescendantsInstances = { map:FindFirstChild("Expressway") }
local worstAll, worstRoad, atAll, atRoad = 0, 0, -1, -1
local hits = {}
for i = 1, n do
local j = (i % n) + 1
local p = samples[j].pos
local fwd = (samples[(j % n) + 1].pos - samples[i].pos)
fwd = Vector3.new(fwd.X, 0, fwd.Z)
if fwd.Magnitude > 0.01 then
fwd = fwd.Unit
local o1 = p - fwd * 3 + Vector3.new(0, 40, 0)
local o2 = p + fwd * 3 + Vector3.new(0, 40, 0)
local a1 = workspace:Raycast(o1, Vector3.new(0, -120, 0), rp)
local a2 = workspace:Raycast(o2, Vector3.new(0, -120, 0), rp)
if a1 and a2 then
local d = math.abs(a1.Position.Y - a2.Position.Y)
if d > worstAll then
worstAll, atAll = d, i
end
if d > 1 then
hits[#hits + 1] = ("i=%d(%s) d=%.2f hitA=%s hitB=%s"):format(
i,
samples[i].piece,
d,
a1.Instance.Name,
a2.Instance.Name
)
end
end
local b1 = workspace:Raycast(o1, Vector3.new(0, -120, 0), roadOnly)
local b2 = workspace:Raycast(o2, Vector3.new(0, -120, 0), roadOnly)
if b1 and b2 then
local d = math.abs(b1.Position.Y - b2.Position.Y)
if d > worstRoad then
worstRoad, atRoad = d, i
end
end
end
end
out[#out + 1] = ("ALL-GEOMETRY worst=%.3f at i=%d"):format(worstAll, atAll)
out[#out + 1] = ("ROAD-ONLY worst=%.3f at i=%d -> %s"):format(
worstRoad,
atRoad,
worstRoad <= 0.60 and "PASS" or "FAIL"
)
out[#out + 1] = ("outlier samples (d>1), first 12 of %d:"):format(#hits)
for k = 1, math.min(12, #hits) do
out[#out + 1] = " " .. hits[k]
end
map:Destroy()
clone:Destroy()
return table.concat(out, "\n")