fix(physics): document adjustedCenter discard + restore wall-poly test
Code review feedback on Task 3 commit 91b29d1:
- TryFindIndoorWalkablePlane: comment explaining why FindWalkableSphere's
adjustedCenter out param is intentionally discarded (ValidateWalkable
recomputes contact geometry from plane + foot position, consistent
with the outdoor terrain path).
- IndoorWalkablePlaneTests: new TryFindIndoorWalkablePlane_WallPolyInBsp_ReturnsFalse
restores integration-level coverage that the renamed NoBsp_ReturnsFalse
lost. Verifies WalkableAllowance gate rejects a wall polygon in the
cell BSP. Steep-poly rejection is also covered at the BSPQuery layer
by FindWalkableSphere_SteepPoly_RejectedByWalkableAllowance.
No behavior change. Build clean; all related 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
91b29d1a89
commit
7c516edd7b
2 changed files with 57 additions and 0 deletions
|
|
@ -1247,6 +1247,12 @@ public sealed class Transition
|
||||||
this.SpherePath.WalkableAllowance = savedWalkableAllowance;
|
this.SpherePath.WalkableAllowance = savedWalkableAllowance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adjustedCenter (sphere slid onto polygon plane) is intentionally
|
||||||
|
// discarded — ValidateWalkable recomputes contact geometry from the
|
||||||
|
// world-space plane + foot position, consistent with the outdoor terrain
|
||||||
|
// path (SampleTerrainWalkable returns only plane + vertices, no adjusted
|
||||||
|
// sphere). The local is held only to satisfy the out param.
|
||||||
|
|
||||||
if (!found || hitPoly is null) return false;
|
if (!found || hitPoly is null) return false;
|
||||||
|
|
||||||
// Transform hit polygon's plane + vertices to world space. Math is
|
// Transform hit polygon's plane + vertices to world space. Math is
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,57 @@ public class IndoorWalkablePlaneTests
|
||||||
Assert.False(found);
|
Assert.False(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TryFindIndoorWalkablePlane_WallPolyInBsp_ReturnsFalse()
|
||||||
|
{
|
||||||
|
// A polygon with a horizontal normal (Z = 0) is a wall, not a floor.
|
||||||
|
// walkable_hits_sphere rejects it: dp = dot(UnitZ, (0,1,0)) = 0 <= FloorZ.
|
||||||
|
// Regression coverage for the previous NoWalkablePolys_ReturnsFalse intent
|
||||||
|
// (the renamed NoBsp_ReturnsFalse only covers the null-BSP early-return).
|
||||||
|
Vector3[] wallVerts =
|
||||||
|
{
|
||||||
|
new Vector3(0f, 0f, 0f),
|
||||||
|
new Vector3(1f, 0f, 0f),
|
||||||
|
new Vector3(1f, 0f, 1f),
|
||||||
|
new Vector3(0f, 0f, 1f),
|
||||||
|
};
|
||||||
|
var resolved = new Dictionary<ushort, ResolvedPolygon>
|
||||||
|
{
|
||||||
|
[0] = new ResolvedPolygon
|
||||||
|
{
|
||||||
|
Vertices = wallVerts,
|
||||||
|
Plane = new Plane(new Vector3(0f, 1f, 0f), 0f), // wall facing +Y
|
||||||
|
NumPoints = 4,
|
||||||
|
SidesType = CullMode.None,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var center = new Vector3(0.5f, 0f, 0.5f);
|
||||||
|
var bsp = BuildLeafBsp(new ushort[] { 0 }, center, 2f);
|
||||||
|
|
||||||
|
var cell = new CellPhysics
|
||||||
|
{
|
||||||
|
BSP = bsp,
|
||||||
|
WorldTransform = Matrix4x4.Identity,
|
||||||
|
InverseWorldTransform = Matrix4x4.Identity,
|
||||||
|
Resolved = resolved,
|
||||||
|
};
|
||||||
|
|
||||||
|
var transition = new Transition();
|
||||||
|
transition.SpherePath.WalkInterp = 1.0f;
|
||||||
|
|
||||||
|
// Foot sphere positioned to overlap the wall's plane (|Y - 0| = 0 < radius 0.48).
|
||||||
|
bool found = transition.TryFindIndoorWalkablePlane(
|
||||||
|
cell,
|
||||||
|
localFootCenter: new Vector3(0.5f, 0f, 0.5f),
|
||||||
|
sphereRadius: 0.48f,
|
||||||
|
out _,
|
||||||
|
out _,
|
||||||
|
out _);
|
||||||
|
|
||||||
|
Assert.False(found);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TryFindIndoorWalkablePlane_EmptyResolved_ReturnsFalse()
|
public void TryFindIndoorWalkablePlane_EmptyResolved_ReturnsFalse()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue