diag(physics): L.2.3g — log step-up SUCCESS/FAIL + landing plane

Enhances the ACDREAM_DUMP_STEPUP=1 diagnostic so we can characterize
the steep-roof bug. The original log only showed the input collision
normal of the polygon that triggered step-up; it didn't show what
polygon the step-up actually LANDED on (which can differ — step-up
scans for any walkable polygon within StepUpHeight reach, so it might
ascend onto a flatter surface higher up than the polygon hit).

New log lines:
  stepup: enter normal=(...) → WALKABLE/STEEP, OnWalkable=..., StepUpHeight=...
  stepup: SUCCESS — landed on plane normal=(...) → WALKABLE/STEEP, new CheckPos=...
  stepup: FAILED — sliding back along normal

When user climbs the offending steep roof, the SUCCESS line will tell
us whether the landing polygon is steeper than FloorZ=0.66 (then we
have a threshold bug) or whether step-up scanned past the steep slope
to land on a flatter polygon (then the StepUpHeight reach is too
permissive).

Also logs CurPos and final CheckPos so we can correlate to in-world
location.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-29 18:13:32 +02:00
parent 8fe178ee5c
commit eed8e8ccaa

View file

@ -1389,21 +1389,23 @@ public sealed class Transition
var ci = CollisionInfo; var ci = CollisionInfo;
var oi = ObjectInfo; var oi = ObjectInfo;
// L.2.3f (2026-04-29): diagnostic for steep-roof bug. Log the // L.2.3f (2026-04-29): diagnostic for steep-roof bug. Logs the
// collision normal Z so we can confirm whether the polygon being // input polygon normal that triggered step-up. The verdict tells
// stepped up onto is "walkable" (normal.Z >= FloorZ ≈ 0.66) or // whether THIS polygon would pass FloorZ (≈ 0.66) — but actual
// not (≈ 0.087 LandingZ when not OnWalkable). If we see steep // step-up acceptance depends on the polygon found by step_sphere_down
// normals being accepted, the issue is in the find_walkable // INSIDE the recursive TransitionalInsert, which may be different.
// threshold rather than the StepUpHeight reach. // The post-step "result=" line below logs that outcome.
if (Environment.GetEnvironmentVariable("ACDREAM_DUMP_STEPUP") == "1") bool diag = Environment.GetEnvironmentVariable("ACDREAM_DUMP_STEPUP") == "1";
if (diag)
{ {
float floor = PhysicsGlobals.FloorZ; float floor = PhysicsGlobals.FloorZ;
string verdict = collisionNormal.Z >= floor ? "WALKABLE" : "STEEP"; string verdict = collisionNormal.Z >= floor ? "WALKABLE" : "STEEP";
Console.WriteLine( Console.WriteLine(
$"stepup: normal=({collisionNormal.X:F3},{collisionNormal.Y:F3},{collisionNormal.Z:F3}) " + $"stepup: enter normal=({collisionNormal.X:F3},{collisionNormal.Y:F3},{collisionNormal.Z:F3}) " +
$"|Z|={collisionNormal.Z:F3} vs FloorZ={floor:F3} → {verdict}, " + $"|Z|={collisionNormal.Z:F3} vs FloorZ={floor:F3} → {verdict}, " +
$"OnWalkable={oi.State.HasFlag(ObjectInfoState.OnWalkable)}, " + $"OnWalkable={oi.State.HasFlag(ObjectInfoState.OnWalkable)}, " +
$"StepUpHeight={oi.StepUpHeight:F3}"); $"StepUpHeight={oi.StepUpHeight:F3}, " +
$"CurPos=({sp.CurPos.X:F2},{sp.CurPos.Y:F2},{sp.CurPos.Z:F2})");
} }
// L.2.3c (2026-04-29): capture the existing contact plane BEFORE // L.2.3c (2026-04-29): capture the existing contact plane BEFORE
@ -1443,6 +1445,28 @@ public sealed class Transition
sp.StepUp = false; sp.StepUp = false;
sp.WalkableValid = false; sp.WalkableValid = false;
// L.2.3f: log the result + landing plane if step-up succeeded.
// This is the actual surface the player ended up on, which may
// differ from the input collision normal (e.g. step-up scanned
// past a steep slope and landed on a flatter polygon higher up).
if (diag)
{
if (stepDown && ci.ContactPlaneValid)
{
float floor = PhysicsGlobals.FloorZ;
string verdict = ci.ContactPlane.Normal.Z >= floor ? "WALKABLE" : "STEEP";
Console.WriteLine(
$"stepup: SUCCESS — landed on plane normal=" +
$"({ci.ContactPlane.Normal.X:F3},{ci.ContactPlane.Normal.Y:F3},{ci.ContactPlane.Normal.Z:F3}) " +
$"|Z|={ci.ContactPlane.Normal.Z:F3} vs FloorZ={floor:F3} → {verdict}, " +
$"new CheckPos=({sp.CheckPos.X:F2},{sp.CheckPos.Y:F2},{sp.CheckPos.Z:F2})");
}
else
{
Console.WriteLine($"stepup: FAILED — sliding back along normal");
}
}
if (!stepDown) if (!stepDown)
{ {
sp.RestoreCheckPos(); sp.RestoreCheckPos();