diag(phys): A6.P3 slice 4 — extend [cell-cache] probe with portalTargets

Extends the existing [cell-cache] probe (gated by ACDREAM_PROBE_CELL_CACHE=1)
to also dump the list of portal targets per cell: which other cells
each portal connects to, the portal polygon id, and the flags.

Output format (appended to existing [cell-cache] line):
  portalTargets=[(cell=0xNNNN,poly=0xNNNN,flags=0xNNNN),...]

Purpose: investigating issue #98 (cellar-up stuck at top of ramp).
We now know the polygon geometry is correct (per slice 4 polydump
capture: the cellar is a real 46° ramp). Question is whether the
cellar cell has a portal to the cottage main floor cell, and where
that portal is. If portalTargets shows no connection to the expected
upstairs cell, that's the bug.

Test suite: unaffected (probe is gated off by default).
Build: green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-22 12:31:34 +02:00
parent 0b449968a7
commit 319847289e

View file

@ -215,8 +215,29 @@ public sealed class PhysicsDataCache
var worldOrigin = Vector3.Transform(Vector3.Zero, worldTransform);
// A6.P3 slice 4 (2026-05-22): also dump portal targets so we
// can see which cells the player should be able to transition
// to (issue #98 investigation: cellar-up stuck at top of ramp).
string portalTargets;
if (portals.Count == 0)
{
portalTargets = "portalTargets=[]";
}
else
{
var sb = new System.Text.StringBuilder("portalTargets=[");
for (int i = 0; i < portals.Count; i++)
{
if (i > 0) sb.Append(',');
sb.Append(System.FormattableString.Invariant(
$"(cell=0x{portals[i].OtherCellId:X4},poly=0x{portals[i].PolygonId:X4},flags=0x{portals[i].Flags:X4})"));
}
sb.Append(']');
portalTargets = sb.ToString();
}
Console.WriteLine(System.FormattableString.Invariant(
$"[cell-cache] envCellId=0x{envCellId:X8} physicsPolyCount={cellStruct.PhysicsPolygons?.Count ?? 0} resolvedCount={resolved.Count} bspTotalLeafPolys={bspTotalLeafPolys} bspUnmatchedIds={bspUnmatchedIds} {bsStr} portalCount={portals.Count} visibleCells={visibleCellIds.Count} cellBspRoot={(cellStruct.CellBSP?.Root is null ? "null" : "ok")} worldOrigin=({worldOrigin.X:F2},{worldOrigin.Y:F2},{worldOrigin.Z:F2})"));
$"[cell-cache] envCellId=0x{envCellId:X8} physicsPolyCount={cellStruct.PhysicsPolygons?.Count ?? 0} resolvedCount={resolved.Count} bspTotalLeafPolys={bspTotalLeafPolys} bspUnmatchedIds={bspUnmatchedIds} {bsStr} portalCount={portals.Count} visibleCells={visibleCellIds.Count} cellBspRoot={(cellStruct.CellBSP?.Root is null ? "null" : "ok")} worldOrigin=({worldOrigin.X:F2},{worldOrigin.Y:F2},{worldOrigin.Z:F2}) {portalTargets}"));
}
if (PhysicsDiagnostics.ProbeWalkMissEnabled)