From 86ecdf9ee156a04d4a79d8e5d7461e5240c3b8ee Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 19 May 2026 21:41:13 +0200 Subject: [PATCH] fix(physics): tighten FindWalkableSphere test assertions + header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code review feedback on Task 2 commit 7f55e14: - Tests 1 and 2 now assert on adjustedCenter.Z (was the wrapper's primary behavioral contract — sphere placed on polygon plane — but it was unverified). Math derived from AdjustSphereToPlane: iDist = (dpPos - radius) / dpMove; new center = center - movement * iDist. - Test 2 also gains the hitPoly.Plane.Normal.Z assertion that Test 1 already had. - Test 4 comment slope-angle clarification. - BSPQuery.cs FindWalkableSphere section header now notes this is not a direct retail port (it wraps BSPNODE::find_walkable + BSPLEAF::find_walkable via the existing FindWalkableInternal). No behavior change. Build clean; 4/4 tests pass; same 8 pre-existing failures. Spec: docs/superpowers/specs/2026-05-19-indoor-walkable-plane-bsp-port-design.md Co-Authored-By: Claude Sonnet 4.6 --- src/AcDream.Core/Physics/BSPQuery.cs | 2 ++ tests/AcDream.Core.Tests/Physics/BSPQueryTests.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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]