Files
tokyo-wangan-racing/tools/verify_c1_fixes.luau
T
jesse 7d368d5444 Render C1 structural variety: girder bridges, Ginza overpasses, JCT speeds, 3+3 widening
Four fidelity fixes, all verified in a live Studio datamodel (not just built):

1. Wire up the dead `bridge` flag. Circuit.luau marks 474 samples as bridge
   spans but nothing ever read the field, so every elevated metre rendered as
   the same slab on square columns. Flagged spans now get a steel box girder
   (鋼箱桁橋) with stiffener ribs under the deck, carried on a transverse pier
   cap and round columns at a wider pitch than the viaduct pillars.

2. Ginza 跨道橋. The Ginza section sits below street level in the filled-in
   楓川・築地川 river beds and the surviving city bridges cross over it, their
   piers landing in the median. Adds the crossing decks, parapets and centre
   piers -- which is the physical reason lane changes are banned there, not
   just a paint choice.

3. Junction speed plates. 江戸橋JCT内 / 浜崎橋JCT内 / 京橋JCT-旧白魚橋乗継所 are
   posted 40 km/h, not the 50 km/h mainline limit; plates repeat more often
   through the short restricted stretches.

4. Shiodome JCT -> Hamazakibashi JCT widened to 3+3 lanes via widthAt(), with
   a taper (max ~1.7 studs/sample) instead of a step. Every fixed-width
   consumer -- deck, median, parapets, lane marks, signage offsets, skyline
   setback, finish line -- now reads widthAt() so nothing floats or clips.

Verified headlessly (tools/verify_c1_fixes*.luau):
  girders 488 / 474 flagged samples, pier caps 85, columns 80
  Ginza overpasses 7, piers 7, lateral offset from centreline 0.000 studs
  speed plates 40km/h x7, 50km/h x8
  deck width Shiodome 81.5 vs Kasumigaseki 60.0
  seam lip max 0.0006, road-surface raycast step max 0.260, 0 deck holes

Two earlier "failures" were bad tests, not bad geometry, and the fixed
harnesses document the traps: deck parts are pitched by CFrame.lookAt so
Position.Y+Size.Y/2 is not the surface height (and LookVector is -Z, so the
end faces are easy to swap), and a seam raycast must filter to the Expressway
folder or it hits TunnelCeiling/MedianFence and reports a phantom 19-stud step.
2026-08-01 18:10:00 -04:00

165 lines
5.1 KiB
Luau

-- Headless verification of the four C1 fidelity fixes.
-- Asserts NUMBERS the build produced, not "the build ran".
local sss = game:GetService("ServerScriptService")
local orig = sss:FindFirstChild("MapBuilder", true)
if not orig then return "FAIL: MapBuilder not found" end
-- Freshness gate: prove we are measuring the NEW source before trusting anything.
local fresh = {}
for _, tok in ipairs({ "WIDE_ROAD_WIDTH", "BridgeGirder", "GinzaOverpass", "isJctSample", "GIRDER_H" }) do
fresh[#fresh + 1] = tok .. "=" .. tostring(orig.Source:find(tok, 1, true) ~= nil)
end
-- Fresh-require so Studio's module cache cannot serve a stale copy.
local clone = orig:Clone()
clone.Name = "MapBuilder_Verify"
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 counts = {}
local decks = {}
for _, d in ipairs(map:GetDescendants()) do
if d:IsA("BasePart") then
counts[d.Name] = (counts[d.Name] or 0) + 1
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
line("FRESHNESS: " .. table.concat(fresh, " "))
-- FIX 1: bridge flag wired up ------------------------------------------------
local nBridgeSamples = 0
for _, s in ipairs(Circuit.samples) do
if s.bridge then
nBridgeSamples += 1
end
end
local girders = counts["BridgeGirder"] or 0
line(("FIX1 bridge flag: samples=%d girders=%d piercaps=%d piercols=%d -> %s"):format(
nBridgeSamples, girders, counts["PierCap"] or 0, counts["PierColumn"] or 0,
(girders >= nBridgeSamples * 0.5 and girders > 0) and "PASS" or "FAIL"))
-- FIX 2: Ginza overpasses with piers between the carriageways ----------------
local ov, pier = counts["GinzaOverpass"] or 0, counts["OverpassPier"] or 0
line(("FIX2 Ginza 跨道橋: overpass=%d pier=%d parapet=%d -> %s"):format(
ov, pier, counts["OverpassParapet"] or 0, (ov > 0 and pier == ov) and "PASS" or "FAIL"))
-- Piers must actually sit BETWEEN the carriageways (near the centreline),
-- not off to one side -- that is the whole point of the fix.
local worstPier = 0
for _, d in ipairs(map:GetDescendants()) do
if d.Name == "OverpassPier" then
local best = math.huge
for i, s in ipairs(Circuit.samples) do
if s.piece == "Ginza" then
local dd = (Vector3.new(s.pos.X, 0, s.pos.Z) - Vector3.new(d.Position.X, 0, d.Position.Z)).Magnitude
best = math.min(best, dd)
local _ = i
end
end
worstPier = math.max(worstPier, best)
end
end
line(("FIX2 pier centreline offset: worst=%.2f studs -> %s"):format(
worstPier, worstPier < 6 and "PASS" or "FAIL"))
-- FIX 3: 40 km/h plates in junctions ----------------------------------------
local n40, n50 = 0, 0
for _, d in ipairs(map:GetDescendants()) do
if d.Name == "SpeedLimitSign" then
for _, g in ipairs(d:GetDescendants()) do
if g:IsA("TextLabel") then
if g.Text == "40" then
n40 += 1
elseif g.Text == "50" then
n50 += 1
end
break
end
end
end
end
line(("FIX3 speed plates: 40kmh=%d 50kmh=%d -> %s"):format(
n40, n50, (n40 > 0 and n50 > 0) and "PASS" or "FAIL"))
-- FIX 4: Shiodome 3+3 widening ----------------------------------------------
local shioW, baseW, shioN, baseN = 0, 0, 0, 0
for i, s in ipairs(Circuit.samples) do
local d = decks[i]
if d then
if s.piece == "Shiodome" then
shioW += d.Size.X
shioN += 1
elseif s.piece == "Kasumigaseki" then
baseW += d.Size.X
baseN += 1
end
end
end
shioW = shioN > 0 and shioW / shioN or 0
baseW = baseN > 0 and baseW / baseN or 0
line(("FIX4 deck width: Shiodome avg=%.1f Kasumigaseki avg=%.1f -> %s"):format(
shioW, baseW, (shioW > baseW + 8) and "PASS" or "FAIL"))
-- Lane boundary count: 3 lanes per side needs 2 boundary lines per side.
local function boundariesNear(zone)
local best, bestI = math.huge, nil
for i, s in ipairs(Circuit.samples) do
if s.piece == zone then
bestI = bestI or i
best = 0
end
end
local _ = best
return bestI
end
local si = boundariesNear("Shiodome")
local nLines = 0
if si and decks[si] then
local c = decks[si].Position
for _, d in ipairs(map:GetDescendants()) do
if (d.Name == "LaneLine" or d.Name == "Dash") and (d.Position - c).Magnitude < 40 then
nLines += 1
end
end
end
line(("FIX4 lane boundaries near Shiodome sample %s: %d markings"):format(tostring(si), nLines))
-- REGRESSION: no holes in the deck, seam lips still within tolerance --------
local holes, maxLip = 0, 0
local n = #Circuit.samples
for i = 1, n do
local a, b = decks[i], decks[(i % n) + 1]
if a and b then
local lip = math.abs((a.Position.Y + a.Size.Y / 2) - (b.Position.Y + b.Size.Y / 2))
maxLip = math.max(maxLip, lip)
elseif not a then
holes += 1
end
end
line(("REGRESSION decks=%d holes=%d maxSeamLip=%.3f -> %s"):format(
n, holes, maxLip, (holes == 0 and maxLip <= 0.30) and "PASS" or "FAIL"))
map:Destroy()
clone:Destroy()
return table.concat(out, "\n")