fix(physics): increase contact point safety margin
Rewind to t-0.02 instead of exact contact time, plus 2cm normal push-back. The previous 0.5cm was too small — at high speed the sub-step could overshoot past the surface. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
76cf7a85ec
commit
1f30fbd2f5
1 changed files with 6 additions and 3 deletions
|
|
@ -774,11 +774,14 @@ public sealed class Transition
|
||||||
return TransitionState.Adjusted;
|
return TransitionState.Adjusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewind the sphere to the contact point (before penetration).
|
// Rewind the sphere to just BEFORE the contact point.
|
||||||
|
// Use t slightly before bestT to ensure no penetration.
|
||||||
if (bestT < 1f)
|
if (bestT < 1f)
|
||||||
{
|
{
|
||||||
Vector3 contactPos = currPos + movement * bestT;
|
float safeT = MathF.Max(0f, bestT - 0.02f);
|
||||||
contactPos += bestNormal * 0.005f;
|
Vector3 contactPos = currPos + movement * safeT;
|
||||||
|
// Additional push along normal to clear the surface.
|
||||||
|
contactPos += bestNormal * 0.02f;
|
||||||
sp.SetCheckPos(contactPos, sp.CheckCellId);
|
sp.SetCheckPos(contactPos, sp.CheckCellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue