From 1f30fbd2f5349e69dbda4e71f3caa7c8e9bfdcf2 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 14 Apr 2026 13:35:06 +0200 Subject: [PATCH] fix(physics): increase contact point safety margin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/AcDream.Core/Physics/TransitionTypes.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/AcDream.Core/Physics/TransitionTypes.cs b/src/AcDream.Core/Physics/TransitionTypes.cs index bfd62fa..1774313 100644 --- a/src/AcDream.Core/Physics/TransitionTypes.cs +++ b/src/AcDream.Core/Physics/TransitionTypes.cs @@ -774,11 +774,14 @@ public sealed class Transition 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) { - Vector3 contactPos = currPos + movement * bestT; - contactPos += bestNormal * 0.005f; + float safeT = MathF.Max(0f, bestT - 0.02f); + Vector3 contactPos = currPos + movement * safeT; + // Additional push along normal to clear the surface. + contactPos += bestNormal * 0.02f; sp.SetCheckPos(contactPos, sp.CheckCellId); }