refactor(physics): expose hitPolyId from FindWalkableInternal
Adds a ref ushort hitPolyId parameter to FindWalkableInternal so callers can identify which polygon was hit. The leaf branch already iterates foreach (ushort polyId in node.Polygons); this surfaces it. No behavior change. Existing callers (StepSphereDown, Path 4 Collide) pass a discard local. The new BSPQuery.FindWalkableSphere wrapper (next commit) will consume it. Prep for indoor walkable-plane BSP port — see spec docs/superpowers/specs/2026-05-19-indoor-walkable-plane-bsp-port-design.md
This commit is contained in:
parent
e62d076f33
commit
ff548b962c
1 changed files with 10 additions and 6 deletions
|
|
@ -652,6 +652,7 @@ public static class BSPQuery
|
|||
Vector3 movement,
|
||||
Vector3 up,
|
||||
ref ResolvedPolygon? hitPoly,
|
||||
ref ushort hitPolyId,
|
||||
ref bool changed)
|
||||
{
|
||||
if (node is null) return;
|
||||
|
|
@ -673,6 +674,7 @@ public static class BSPQuery
|
|||
{
|
||||
changed = true;
|
||||
hitPoly = poly;
|
||||
hitPolyId = polyId;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -686,22 +688,22 @@ public static class BSPQuery
|
|||
if (dist >= reach)
|
||||
{
|
||||
FindWalkableInternal(node.PosNode, resolved, path, validPos, movement, up,
|
||||
ref hitPoly, ref changed);
|
||||
ref hitPoly, ref hitPolyId, ref changed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dist <= -reach)
|
||||
{
|
||||
FindWalkableInternal(node.NegNode, resolved, path, validPos, movement, up,
|
||||
ref hitPoly, ref changed);
|
||||
ref hitPoly, ref hitPolyId, ref changed);
|
||||
return;
|
||||
}
|
||||
|
||||
// Straddles.
|
||||
FindWalkableInternal(node.PosNode, resolved, path, validPos, movement, up,
|
||||
ref hitPoly, ref changed);
|
||||
ref hitPoly, ref hitPolyId, ref changed);
|
||||
FindWalkableInternal(node.NegNode, resolved, path, validPos, movement, up,
|
||||
ref hitPoly, ref changed);
|
||||
ref hitPoly, ref hitPolyId, ref changed);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
@ -1103,9 +1105,10 @@ public static class BSPQuery
|
|||
var validPos = new CollisionSphere(checkPos);
|
||||
bool changed = false;
|
||||
ResolvedPolygon? polyHit = null;
|
||||
ushort _polyId = 0; // step-down doesn't need the id, but the signature requires it
|
||||
|
||||
FindWalkableInternal(root, resolved, path, validPos, movement, up,
|
||||
ref polyHit, ref changed);
|
||||
ref polyHit, ref _polyId, ref changed);
|
||||
|
||||
if (changed && polyHit is not null)
|
||||
{
|
||||
|
|
@ -1487,10 +1490,11 @@ public static class BSPQuery
|
|||
{
|
||||
var validPos = new CollisionSphere(sphere0);
|
||||
ResolvedPolygon? hitPoly = null;
|
||||
ushort _hitPolyId = 0; // Path 4 doesn't need the id
|
||||
bool changed = false;
|
||||
|
||||
FindWalkableInternal(root, resolved, path, validPos, movement, localSpaceZ,
|
||||
ref hitPoly, ref changed);
|
||||
ref hitPoly, ref _hitPolyId, ref changed);
|
||||
|
||||
if (changed && hitPoly is not null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue