diff --git a/src/AcDream.Core/Physics/TransitionTypes.cs b/src/AcDream.Core/Physics/TransitionTypes.cs index 50dc718..ae2b3de 100644 --- a/src/AcDream.Core/Physics/TransitionTypes.cs +++ b/src/AcDream.Core/Physics/TransitionTypes.cs @@ -1383,10 +1383,31 @@ public sealed class Transition // Retail: CEnvCell::find_env_collisions returns from the cell // branch with the cell's walkable plane set — no fall-through // to terrain. - if (TryFindIndoorWalkablePlane(cellPhysics, localCenter, sphereRadius, - out var indoorPlane, - out var indoorVertices, - out uint _)) + bool walkableHit = TryFindIndoorWalkablePlane( + cellPhysics, localCenter, sphereRadius, + out var indoorPlane, + out var indoorVertices, + out uint hitPolyId); + + if (PhysicsDiagnostics.ProbeIndoorBspEnabled) + { + if (walkableHit) + { + // dz = signed gap between foot and synthesized plane. + // Plane: N·p + D = 0 ⇒ pZ_on_plane = -D/N.z (for upward-facing planes) + // gap = foot.Z - pZ_on_plane = foot.Z - (-D/N.z) = foot.Z + D/N.z + float dz = footCenter.Z + indoorPlane.D / indoorPlane.Normal.Z; + Console.WriteLine(System.FormattableString.Invariant( + $"[indoor-walkable] cell=0x{sp.CheckCellId:X8} wpos=({footCenter.X:F3},{footCenter.Y:F3},{footCenter.Z:F3}) probe={INDOOR_WALKABLE_PROBE_DISTANCE:F2} result=HIT poly=0x{hitPolyId:X4} wn=({indoorPlane.Normal.X:F3},{indoorPlane.Normal.Y:F3},{indoorPlane.Normal.Z:F3}) wD={indoorPlane.D:F3} dz={dz:+0.00;-0.00;+0.00}")); + } + else + { + Console.WriteLine(System.FormattableString.Invariant( + $"[indoor-walkable] cell=0x{sp.CheckCellId:X8} wpos=({footCenter.X:F3},{footCenter.Y:F3},{footCenter.Z:F3}) probe={INDOOR_WALKABLE_PROBE_DISTANCE:F2} result=MISS")); + } + } + + if (walkableHit) { return ValidateWalkable( footCenter,