diff --git a/src/AcDream.Core/Physics/PhysicsDiagnostics.cs b/src/AcDream.Core/Physics/PhysicsDiagnostics.cs index 897c35d..5930c2d 100644 --- a/src/AcDream.Core/Physics/PhysicsDiagnostics.cs +++ b/src/AcDream.Core/Physics/PhysicsDiagnostics.cs @@ -243,6 +243,39 @@ public static class PhysicsDiagnostics public static bool ProbeContactPlaneEnabled { get; set; } = Environment.GetEnvironmentVariable("ACDREAM_PROBE_CONTACT_PLANE") == "1"; + /// + /// Indoor walking ISSUES #83 H-disambiguation spike (2026-05-21). + /// When true, two diagnostic emissions activate: + /// + /// One [walk-miss] line per + /// MISS + /// event, dumping foot world/local position, the nearest + /// walkable polygon in the cell (with XY-containment flag and + /// vertical gap), and whether the LandCell terrain at the same + /// XY would have grounded the player. + /// One [floor-polys] line per indoor + /// cell cached, enumerating each walkable-eligible polygon's + /// id, normal Z, local-XY bounding box, and plane Z at the + /// bbox center. + /// + /// Together these answer H1 (multi-cell iteration missing) vs H2 + /// (probe distance too short) vs H3 (poly absent / + /// walkable_hits_sphere rejection) for the ISSUES #83 + /// stuck-falling bug. Spike-only — remove once the root cause is + /// identified and the fix lands. + /// + /// + /// Initial state from ACDREAM_PROBE_WALK_MISS=1. + /// No DebugPanel mirror — one-shot diagnostic. + /// + /// + /// + /// Spec: docs/superpowers/specs/2026-05-21-indoor-walk-miss-probe-design.md. + /// + /// + public static bool ProbeWalkMissEnabled { get; set; } = + Environment.GetEnvironmentVariable("ACDREAM_PROBE_WALK_MISS") == "1"; + public static void LogCpBoolWrite(string field, bool oldValue, bool newValue) { var caller = GetCpCallerName(); diff --git a/tests/AcDream.Core.Tests/Physics/WalkMissDiagnosticTests.cs b/tests/AcDream.Core.Tests/Physics/WalkMissDiagnosticTests.cs new file mode 100644 index 0000000..91de8c4 --- /dev/null +++ b/tests/AcDream.Core.Tests/Physics/WalkMissDiagnosticTests.cs @@ -0,0 +1,41 @@ +using AcDream.Core.Physics; +using DatReaderWriter.Enums; +using System.Collections.Generic; +using System.Numerics; +using Xunit; + +namespace AcDream.Core.Tests.Physics; + +/// +/// Tests for the ISSUES #83 H-disambiguation probe spike (spec +/// 2026-05-21-indoor-walk-miss-probe-design.md). +/// +/// Covers: +/// 1. PhysicsDiagnostics.ProbeWalkMissEnabled flag get/set roundtrip. +/// 2. WalkMissDiagnostic.AggregateNearestWalkable selects the nearest +/// walkable polygon by |dz| when the foot XY lies inside a poly's +/// local XY bounding box. +/// 3. WalkMissDiagnostic.AggregateNearestWalkable falls back to the +/// nearest poly by |dz| when no walkable poly XY-contains the foot, +/// reporting ContainsFootXY=false. +/// +public class WalkMissDiagnosticTests +{ + [Fact] + public void ProbeWalkMiss_StaticApi_Roundtrip() + { + bool initial = PhysicsDiagnostics.ProbeWalkMissEnabled; + try + { + PhysicsDiagnostics.ProbeWalkMissEnabled = true; + Assert.True(PhysicsDiagnostics.ProbeWalkMissEnabled); + + PhysicsDiagnostics.ProbeWalkMissEnabled = false; + Assert.False(PhysicsDiagnostics.ProbeWalkMissEnabled); + } + finally + { + PhysicsDiagnostics.ProbeWalkMissEnabled = initial; + } + } +}