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.
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
-- 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")
|
||||
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Push MapBuilder.luau source into a LIVE (Play-mode) Studio via the MCP bridge.
|
||||
|
||||
Rojo cannot reach the running server datamodel in Play mode, so the source is
|
||||
shipped as ~9000-char chunks into named StringValue children (p0, p1, ...) under
|
||||
ReplicatedStorage, then concatenated and assigned to the ModuleScript's .Source.
|
||||
|
||||
Named children matter: a retried chunk overwrites its slot instead of appending
|
||||
a duplicate. Bridge calls fail intermittently ("Unable to find an active Studio
|
||||
instance") even while Studio is up, so every call is retried.
|
||||
"""
|
||||
import sys, time
|
||||
|
||||
sys.path.insert(0, "/tmp")
|
||||
import rbx
|
||||
|
||||
SRC_PATH = "/home/jesse/roblox/tokyo-wangan-racing/src/server/MapBuilder.luau"
|
||||
MODULE = 'game:GetService("ServerScriptService"):FindFirstChild("Server", true)'
|
||||
CHUNK = 9000
|
||||
|
||||
|
||||
def call(code, tries=4):
|
||||
last = None
|
||||
for a in range(tries):
|
||||
try:
|
||||
r = rbx.call(
|
||||
"execute_luau",
|
||||
{"code": code, "datamodel_type": "Server"},
|
||||
warmup=6,
|
||||
wait=45,
|
||||
timeout=300,
|
||||
)
|
||||
if r and "Unable to find an active Studio" not in str(r):
|
||||
return r
|
||||
last = r
|
||||
except Exception as e: # noqa: BLE001
|
||||
last = e
|
||||
time.sleep(5)
|
||||
raise RuntimeError(f"bridge failed after {tries} tries: {last}")
|
||||
|
||||
|
||||
src = open(SRC_PATH, encoding="utf-8").read()
|
||||
nbytes = len(src.encode())
|
||||
print(f"source: {len(src)} chars, {nbytes} utf-8 bytes")
|
||||
|
||||
# Pick a long-bracket level that does not occur in the source.
|
||||
lvl = 0
|
||||
while ("]" + "=" * lvl + "]") in src or ("[" + "=" * lvl + "[") in src:
|
||||
lvl += 1
|
||||
eq = "=" * lvl
|
||||
print(f"long-bracket level: {lvl}")
|
||||
|
||||
chunks = [src[i : i + CHUNK] for i in range(0, len(src), CHUNK)]
|
||||
print(f"chunks: {len(chunks)}")
|
||||
|
||||
print(call('local rs=game:GetService("ReplicatedStorage")\n'
|
||||
'local b=rs:FindFirstChild("MBBuf") if b then b:Destroy() end\n'
|
||||
'b=Instance.new("Folder") b.Name="MBBuf" b.Parent=rs\n'
|
||||
'return "buffer reset"'))
|
||||
|
||||
for i, c in enumerate(chunks):
|
||||
code = (
|
||||
'local rs=game:GetService("ReplicatedStorage")\n'
|
||||
'local b=rs:WaitForChild("MBBuf")\n'
|
||||
f'local n="p{i}"\n'
|
||||
"local sv=b:FindFirstChild(n) or Instance.new(\"StringValue\")\n"
|
||||
"sv.Name=n sv.Parent=b\n"
|
||||
f"sv.Value=[{eq}[{c}]{eq}]\n"
|
||||
f'return "p{i} "..#sv.Value'
|
||||
)
|
||||
print(f" chunk {i+1}/{len(chunks)}: {call(code)}")
|
||||
|
||||
assemble = f"""
|
||||
local rs=game:GetService("ReplicatedStorage")
|
||||
local b=rs:WaitForChild("MBBuf")
|
||||
local parts={{}}
|
||||
for i=0,{len(chunks)-1} do
|
||||
local sv=b:FindFirstChild("p"..i)
|
||||
if not sv then return "MISSING CHUNK p"..i end
|
||||
parts[#parts+1]=sv.Value
|
||||
end
|
||||
local s=table.concat(parts)
|
||||
local sss=game:GetService("ServerScriptService")
|
||||
local m=sss:FindFirstChild("MapBuilder", true)
|
||||
if not m then return "MapBuilder ModuleScript NOT FOUND" end
|
||||
m.Source=s
|
||||
return ("assembled=%d expected={nbytes} match=%s class=%s path=%s"):format(
|
||||
#s, tostring(#s=={nbytes}), m.ClassName, m:GetFullName())
|
||||
"""
|
||||
print(call(assemble))
|
||||
@@ -0,0 +1,164 @@
|
||||
-- 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")
|
||||
@@ -0,0 +1,144 @@
|
||||
-- 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")
|
||||
@@ -0,0 +1,120 @@
|
||||
-- Verification v3: seam lip measured against the KNOWN shared sample point.
|
||||
--
|
||||
-- v2 still had a sign bug: Roblox CFrame.LookVector is the -Z axis, so a deck
|
||||
-- built with CFrame.lookAt(mid, mid+dir) has its FORWARD end at local
|
||||
-- z = -(Size.Z-2)/2 and its REAR end at +(Size.Z-2)/2. v2 had these swapped,
|
||||
-- comparing deck i's rear to deck i+1's rear -- a systematic error that
|
||||
-- reported a near-constant 5.2 on every sloped segment regardless of zone.
|
||||
--
|
||||
-- This version avoids guessing signs: for each deck it takes BOTH end faces,
|
||||
-- picks whichever is nearer the shared sample point b.pos in XZ, and reports
|
||||
-- the surface-height difference there. Sanity-checked against the flat-ground
|
||||
-- expectation and cross-checked with a downward raycast.
|
||||
local sss = game:GetService("ServerScriptService")
|
||||
local orig = sss:FindFirstChild("MapBuilder", true)
|
||||
local clone = orig:Clone()
|
||||
clone.Name = "MapBuilder_Verify3"
|
||||
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
|
||||
|
||||
-- Top-surface height of deck `d` at the end nearest world point `p` (XZ).
|
||||
local function topAtNearestEnd(d, p)
|
||||
local half = (d.Size.Z - 2) / 2
|
||||
local best, bestD = nil, math.huge
|
||||
for _, z in ipairs({ -half, half }) do
|
||||
local w = d.CFrame * CFrame.new(0, d.Size.Y / 2, z)
|
||||
local dd = (Vector3.new(w.X, 0, w.Z) - Vector3.new(p.X, 0, p.Z)).Magnitude
|
||||
if dd < bestD then
|
||||
best, bestD = w.Y, dd
|
||||
end
|
||||
end
|
||||
return best, bestD
|
||||
end
|
||||
|
||||
local worst, worstAt, worstGap = 0, -1, 0
|
||||
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 shared = samples[j].pos -- the sample both decks meet at
|
||||
local ya, da = topAtNearestEnd(a, shared)
|
||||
local yb, db = topAtNearestEnd(b, shared)
|
||||
local lip = math.abs(ya - yb)
|
||||
lips[#lips + 1] = { lip, i, math.max(da, db) }
|
||||
if lip > worst then
|
||||
worst, worstAt, worstGap = lip, i, math.max(da, db)
|
||||
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 max lip=%.4f at i=%d (endpoint XZ err %.3f) -> %s"):format(
|
||||
worst, worstAt, worstGap, worst <= 0.30 and "PASS" or "FAIL"))
|
||||
line("SEAM top5: " .. table.concat(top, " "))
|
||||
|
||||
-- Independent cross-check: raycast down onto the driving surface just before
|
||||
-- and just after each seam. A real step would show up here too.
|
||||
-- MUST filter to the Expressway folder only. Filtering on the whole map lets
|
||||
-- the ray hit TunnelCeiling / MedianFence / overpass decks on the way down and
|
||||
-- reports a bogus ~19-stud "step" that has nothing to do with the road surface.
|
||||
local rp = RaycastParams.new()
|
||||
rp.FilterType = Enum.RaycastFilterType.Include
|
||||
rp.FilterDescendantsInstances = { map:FindFirstChild("Expressway") }
|
||||
local rWorst, rAt = 0, -1
|
||||
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 h1 = workspace:Raycast(p - fwd * 3 + Vector3.new(0, 40, 0), Vector3.new(0, -120, 0), rp)
|
||||
local h2 = workspace:Raycast(p + fwd * 3 + Vector3.new(0, 40, 0), Vector3.new(0, -120, 0), rp)
|
||||
if h1 and h2 then
|
||||
local d = math.abs(h1.Position.Y - h2.Position.Y)
|
||||
if d > rWorst then
|
||||
rWorst, rAt = d, i
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
line(("RAYCAST surface step across seams (+-3 studs): max=%.4f at i=%d -> %s"):format(
|
||||
rWorst, rAt, rWorst <= 0.60 and "PASS" or "FAIL"))
|
||||
|
||||
map:Destroy()
|
||||
clone:Destroy()
|
||||
return table.concat(out, "\n")
|
||||
Reference in New Issue
Block a user