diff --git a/src/AcDream.Core/Physics/BSPQuery.cs b/src/AcDream.Core/Physics/BSPQuery.cs index 48bf975..9f2be66 100644 --- a/src/AcDream.Core/Physics/BSPQuery.cs +++ b/src/AcDream.Core/Physics/BSPQuery.cs @@ -1133,6 +1133,8 @@ public static class BSPQuery // ------------------------------------------------------------------------- // find_walkable_sphere — "stand here, find my contact plane" // Indoor walkable-plane synthesis entry point (Phase 2 follow-up 2026-05-19). + // Not a direct retail port; wraps BSPNODE::find_walkable + BSPLEAF::find_walkable + // (acclient_2013_pseudo_c.txt:326211, :326793) via the existing FindWalkableInternal. // ------------------------------------------------------------------------- /// diff --git a/tests/AcDream.Core.Tests/Physics/BSPQueryTests.cs b/tests/AcDream.Core.Tests/Physics/BSPQueryTests.cs index 1666263..31c175b 100644 --- a/tests/AcDream.Core.Tests/Physics/BSPQueryTests.cs +++ b/tests/AcDream.Core.Tests/Physics/BSPQueryTests.cs @@ -304,6 +304,10 @@ public class BSPQueryTests Assert.Equal((ushort)0, hitPolyId); Assert.NotNull(hitPoly); Assert.Equal(1f, hitPoly!.Plane.Normal.Z, precision: 3); // horizontal floor: normal.Z = 1 + // AdjustSphereToPlane moves the sphere onto the plane along the movement + // vector. For sphere at Z=0.4, radius 0.48, downward movement -0.5, plane + // at Z=0: iDist = (0.4-0.48)/-0.5 = 0.16; new center.Z = 0.4 - (-0.5)*0.16 = 0.48. + Assert.Equal(0.48f, adjustedCenter.Z, precision: 2); } [Fact] @@ -325,11 +329,14 @@ public class BSPQueryTests up: Vector3.UnitZ, out var hitPoly, out var hitPolyId, - out _); + out var adjustedCenter); Assert.True(found); Assert.Equal((ushort)1, hitPolyId); Assert.NotNull(hitPoly); + Assert.Equal(1f, hitPoly!.Plane.Normal.Z, precision: 3); // horizontal upper floor + // Same math as Test 1 but offset by 3: adjustedCenter.Z = 3.0 + 0.48 = 3.48. + Assert.Equal(3.48f, adjustedCenter.Z, precision: 2); } [Fact]