fix(physics): tighten FindWalkableSphere test assertions + header
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 <noreply@anthropic.com>
This commit is contained in:
parent
7f55e14cd7
commit
86ecdf9ee1
2 changed files with 10 additions and 1 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue