feat(physics): A6.P1 — instrument AdjustSphereToPlane with [push-back]

Wires the LogPushBackAdjust helper into all three return paths
of AdjustSphereToPlane (early-return on no-movement, early-return
on interp out-of-window, and the applied path). Probe is gated by
ProbePushBackEnabled so it's zero-cost when off.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-21 18:30:46 +02:00
parent 3a173b9616
commit eb8a3186e7

View file

@ -335,6 +335,12 @@ public static class BSPQuery
CollisionSphere validPos,
Vector3 movement)
{
// A6.P1: snapshot inputs for the [push-back] probe (cheap copy of
// Vector3 + 2 floats). Only the LogPushBackAdjust call below pays
// the Console.WriteLine cost, and only when the probe is on.
var inputCenter = validPos.Center;
float walkInterpBefore = path.WalkInterp;
float dpPos = Vector3.Dot(validPos.Center, poly.Plane.Normal) + poly.Plane.D;
float dpMove = Vector3.Dot(movement, poly.Plane.Normal);
float dist;
@ -342,7 +348,17 @@ public static class BSPQuery
if (dpMove <= PhysicsGlobals.EPSILON)
{
if (dpMove >= -PhysicsGlobals.EPSILON)
{
if (PhysicsDiagnostics.ProbePushBackEnabled)
{
PhysicsDiagnostics.LogPushBackAdjust(
inputCenter, validPos.Center, poly.Plane, validPos.Radius,
walkInterpBefore, path.WalkInterp,
dpPos, dpMove, 0f,
applied: false);
}
return false;
}
dist = dpPos - validPos.Radius;
}
else
@ -354,10 +370,30 @@ public static class BSPQuery
float interp = (1f - iDist) * path.WalkInterp;
if (interp >= path.WalkInterp || interp < -0.5f)
{
if (PhysicsDiagnostics.ProbePushBackEnabled)
{
PhysicsDiagnostics.LogPushBackAdjust(
inputCenter, validPos.Center, poly.Plane, validPos.Radius,
walkInterpBefore, path.WalkInterp,
dpPos, dpMove, iDist,
applied: false);
}
return false;
}
validPos.Center -= movement * iDist;
path.WalkInterp = interp;
if (PhysicsDiagnostics.ProbePushBackEnabled)
{
PhysicsDiagnostics.LogPushBackAdjust(
inputCenter, validPos.Center, poly.Plane, validPos.Radius,
walkInterpBefore, path.WalkInterp,
dpPos, dpMove, iDist,
applied: true);
}
return true;
}