fix(physics): Phase A8.F — viewer sweeps bypass the 30-step cap (retail-faithful)
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 <noreply@anthropic.com>
This commit is contained in:
parent
53634b5089
commit
7a244b3291
2 changed files with 36 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue