diff --git a/src/AcDream.Core/Physics/PhysicsDiagnostics.cs b/src/AcDream.Core/Physics/PhysicsDiagnostics.cs index 8417ccb..bef8e4d 100644 --- a/src/AcDream.Core/Physics/PhysicsDiagnostics.cs +++ b/src/AcDream.Core/Physics/PhysicsDiagnostics.cs @@ -304,6 +304,50 @@ public static class PhysicsDiagnostics public static bool ProbePushBackEnabled { get; set; } = Environment.GetEnvironmentVariable("ACDREAM_PROBE_PUSH_BACK") == "1"; + /// + /// A6.P1 emission helper for the AdjustSphereToPlane site. + /// One line per call: input sphere center, plane geometry, push-back + /// delta, walk-interp before/after, and whether the adjust applied. + /// Direct paired comparison to retail's cdb breakpoint on + /// CPolygon::adjust_sphere_to_plane. + /// + /// + /// Caller MUST guard with if (!ProbePushBackEnabled) return; + /// before computing the delta arguments — this method assumes the + /// caller paid that price already. + /// + /// + public static void LogPushBackAdjust( + Vector3 inputCenter, + Vector3 outputCenter, + Plane plane, + float radius, + float walkInterpBefore, + float walkInterpAfter, + float dpPos, + float dpMove, + float iDist, + bool applied) + { + var delta = outputCenter - inputCenter; + float deltaMag = delta.Length(); + var ci = System.Globalization.CultureInfo.InvariantCulture; + Console.WriteLine(string.Format(ci, + "[push-back] site=adjust_sphere " + + "in=({0:F4},{1:F4},{2:F4}) " + + "out=({3:F4},{4:F4},{5:F4}) " + + "delta=({6:F4},{7:F4},{8:F4}) deltaMag={9:F4} " + + "n=({10:F4},{11:F4},{12:F4}) d={13:F4} " + + "r={14:F4} winterp={15:F4}->{16:F4} " + + "dpPos={17:F4} dpMove={18:F4} iDist={19:F4} applied={20}", + inputCenter.X, inputCenter.Y, inputCenter.Z, + outputCenter.X, outputCenter.Y, outputCenter.Z, + delta.X, delta.Y, delta.Z, deltaMag, + plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D, + radius, walkInterpBefore, walkInterpAfter, + dpPos, dpMove, iDist, applied)); + } + public static void LogCpBoolWrite(string field, bool oldValue, bool newValue) { var caller = GetCpCallerName();