From 7a244b3291b6ef45675ffcff2905523bd927cd46 Mon Sep 17 00:00:00 2001 From: Erik Date: Fri, 29 May 2026 20:35:26 +0200 Subject: [PATCH] =?UTF-8?q?fix(physics):=20Phase=20A8.F=20=E2=80=94=20view?= =?UTF-8?q?er=20sweeps=20bypass=20the=2030-step=20cap=20(retail-faithful)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Retail's CTransition::find_transitional_position (:273613) has no step cap. calc_num_steps (:272149) has a dedicated viewer branch `if ((state & 4) != 0)` at :272181 for sight/viewer objects (ObjectInfoState.IsViewer = 0x4). The existing acdream cap correctly had a comment "Sight objects bypass this" but the bypass was never wired — no IsViewer caller existed until the A8.F camera spring-arm. With radius 0.3 m the cap fires at ~9 m. The spring-arm sweeps up to 40 m (≈134 steps), so zoomed-out cameras snapped to the player's head instead of sweeping through geometry. The fix adds `&& !ObjectInfo.IsViewer` to the guard; non-viewers keep the 30-step safety net (player spheres ~0.48 m radius never exceed 14 m/tick). Conformance test: radius=0.3, dist=12 (40 steps > 30 cap) over flat terrain. Normal mover bails (Assert.False). Viewer proceeds to target (Assert.True + CurPos.X > from.X). RED → GREEN. Co-Authored-By: Claude Sonnet 4.6 --- src/AcDream.Core/Physics/TransitionTypes.cs | 10 +++++-- .../Physics/TransitionTests.cs | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/AcDream.Core/Physics/TransitionTypes.cs b/src/AcDream.Core/Physics/TransitionTypes.cs index eb93665..f947a67 100644 --- a/src/AcDream.Core/Physics/TransitionTypes.cs +++ b/src/AcDream.Core/Physics/TransitionTypes.cs @@ -698,8 +698,14 @@ public sealed class Transition offsetPerStep = Vector3.Zero; } - // Retail safety cap (30 steps). Sight objects bypass this. - if (numSteps > PhysicsGlobals.MaxTransitionSteps) + // Retail safety cap (30 steps). Viewer/sight objects bypass it, matching + // retail: CTransition::find_transitional_position (acclient_2013_pseudo_c.txt + // :273613) has no cap, and calc_num_steps (:272149) has a dedicated viewer + // branch `if ((state & 4) != 0)` at :272181. The A8.F camera spring-arm + // (IsViewer) sweeps the eye far past 30 steps; the zoom clamp (≤40 m / 0.3 m + // radius ≈ 134 steps) bounds it. Non-viewers keep the safety net (players + // never exceed it: 30 × 0.48 m ≈ 14 m/tick). + if (numSteps > PhysicsGlobals.MaxTransitionSteps && !ObjectInfo.IsViewer) return false; // Apply free rotation if requested. diff --git a/tests/AcDream.Core.Tests/Physics/TransitionTests.cs b/tests/AcDream.Core.Tests/Physics/TransitionTests.cs index 307def0..7feb991 100644 --- a/tests/AcDream.Core.Tests/Physics/TransitionTests.cs +++ b/tests/AcDream.Core.Tests/Physics/TransitionTests.cs @@ -283,6 +283,34 @@ public class TransitionTests $"Sphere bottom {bottom:F4} should be >= terrain {groundZ}"); } + [Fact] + public void FindTransitionalPosition_LongSweep_ViewerBypassesStepCap() + { + // A8.F: the 30-step safety cap bailed long sweeps. Retail's + // find_transitional_position has no cap and handles viewers specially + // (calc_num_steps `state & 4` branch, acclient :272181). The camera + // spring arm (IsViewer) must not bail. radius 0.3, dist 12 → 40 steps > 30. + const float groundZ = 10f; + var engine = MakeEngine(FlatTerrain(groundZ)); + + Vector3 from = new(50f, 50f, groundZ); + Vector3 to = new(62f, 50f, groundZ); // 12 units → 40 steps at r=0.3 (>30 cap) + + // Normal mover: hits the 30-step cap, bails without moving. + var normal = MakeTransition(from, to, sphereRadius: 0.3f); + bool normalOk = normal.FindTransitionalPosition(engine); + Assert.False(normalOk); + + // Viewer: cap bypassed → sweep proceeds the full distance over flat ground. + var viewer = MakeTransition(from, to, sphereRadius: 0.3f); + viewer.ObjectInfo.State |= ObjectInfoState.IsViewer; + bool viewerOk = viewer.FindTransitionalPosition(engine); + Assert.True(viewerOk); + // Position must have advanced toward `to` (key invariant: viewer proceeds). + Assert.True(viewer.SpherePath.CurPos.X > from.X, + "Viewer sphere should have advanced in +X past the step cap"); + } + [Fact] public void SampleTerrainZ_FindsCorrectLandblock() {