From eed8e8ccaacc0db995b5e96361aa3af3ae10bf4d Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 29 Apr 2026 18:13:32 +0200 Subject: [PATCH] =?UTF-8?q?diag(physics):=20L.2.3g=20=E2=80=94=20log=20ste?= =?UTF-8?q?p-up=20SUCCESS/FAIL=20+=20landing=20plane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/AcDream.Core/Physics/TransitionTypes.cs | 42 ++++++++++++++++----- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/AcDream.Core/Physics/TransitionTypes.cs b/src/AcDream.Core/Physics/TransitionTypes.cs index 2b5834c..6f73771 100644 --- a/src/AcDream.Core/Physics/TransitionTypes.cs +++ b/src/AcDream.Core/Physics/TransitionTypes.cs @@ -1389,21 +1389,23 @@ public sealed class Transition var ci = CollisionInfo; var oi = ObjectInfo; - // L.2.3f (2026-04-29): diagnostic for steep-roof bug. Log the - // collision normal Z so we can confirm whether the polygon being - // stepped up onto is "walkable" (normal.Z >= FloorZ ≈ 0.66) or - // not (≈ 0.087 LandingZ when not OnWalkable). If we see steep - // normals being accepted, the issue is in the find_walkable - // threshold rather than the StepUpHeight reach. - if (Environment.GetEnvironmentVariable("ACDREAM_DUMP_STEPUP") == "1") + // L.2.3f (2026-04-29): diagnostic for steep-roof bug. Logs the + // input polygon normal that triggered step-up. The verdict tells + // whether THIS polygon would pass FloorZ (≈ 0.66) — but actual + // step-up acceptance depends on the polygon found by step_sphere_down + // INSIDE the recursive TransitionalInsert, which may be different. + // The post-step "result=" line below logs that outcome. + bool diag = Environment.GetEnvironmentVariable("ACDREAM_DUMP_STEPUP") == "1"; + if (diag) { float floor = PhysicsGlobals.FloorZ; string verdict = collisionNormal.Z >= floor ? "WALKABLE" : "STEEP"; 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}, " + $"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 @@ -1443,6 +1445,28 @@ public sealed class Transition sp.StepUp = 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) { sp.RestoreCheckPos();