fix(physics): L.4 — steep airborne hits slide-tangent (interim, deviates from retail)
Phase L.4 closes the "stuck in falling animation on a steep roof" bug
the user reported on 2026-04-30 ("I jump up, I land on it. It should not
even let me land, should just slide with a falling animation"). After
this commit the body no longer sticks to a steep roof when jumping
into it — it slides along the slope while keeping the falling animation.
Two pieces:
1. BSPQuery Path 6 steep-poly slide
When an airborne sphere hits a polygon whose world normal Z is below
FloorZ (≈ 0.6642, slope > ~49°), the previous flow was:
Path 6 SetCollide → Path 4 set_walkable → ContactPlane committed →
body "lands" on the steep poly with Contact bit + falling animation.
This left the player stuck mid-slope because OnWalkable was cleared
but Contact stayed set.
The new branch detects the steep normal in Path 6 BEFORE SetCollide
is called. Instead of entering the landing path, it removes the
into-wall component of the move (project onto the steep face), sets
CollisionNormal + SlidingNormal, and returns Slid. Same shape as
Path 5's step-up fallback and CylinderCollision. The resolver retries;
the sphere is now outside the poly; FindCollisions returns OK;
ValidateTransition commits the slid position. ContactPlane is never
set, so the body stays airborne with falling animation.
2. PlayerMovementController L.3a-bounce carve-out + Inelastic stop
Re-enables the velocity-reflection bounce when the contact normal is
upward-facing but steeper than walkable (0 < N.Z < FloorZ). The base
L.3a rule suppresses bounce on landing transitions to avoid micro-
bounce on flat terrain; that suppression also stuck the player to
too-steep roofs they shouldn't land on. This carve-out re-enables
the reflection specifically for the steep upward case.
Also lands related L.2c precipice / edge-slide work that was in flight:
- TransitionTypes EdgeSlideAfterStepDownFailed: walkable-poly-steep
cliff route + steep-ContactPlane cliff route ordering, so that
CliffSlide fires when the stored walkable polygon itself is too
steep (Path 4 had previously accepted it as a "landing" via the
permissive LandingZ threshold).
- CliffSlide reference-normal selection: prefer LastWalkable, fall back
to LastKnownContactPlane only when walkable, else use world-up. This
prevents the cross(steepN, steepN) = 0 degenerate case that left the
cliff slide as a no-op when both current and last-known were steep.
- Phase 2 / step-down branch / edge-slide branch / cliff-slide
diagnostic helpers gated on ACDREAM_DUMP_EDGE_SLIDE / ACDREAM_DUMP_STEEP_ROOF.
- Two new airborne-mover regression tests in BSPStepUpTests +
PhysicsEngineTests covering wall-slide and edge tangent motion.
DEVIATION FROM RETAIL — DOCUMENTED FOR FOLLOW-UP
The Path 6 steep slide is NOT what retail does. Retail's flow on the
same hit is:
Path 6 SetCollide (no steep check) → Path 4 find_walkable returns
nothing for steep → Phase 3 reset path: restore_check_pos +
kill_velocity → return COLLIDED → validate_transition reverts CheckPos
to CurPos and forces OK.
Net retail behavior: position reverts to pre-failed-move (typically
just below the roof in the common jump-up case), velocity zeroed,
gravity rebuilds Z next frame, body falls back down naturally with
the falling animation. The "freeze" framing I used earlier was wrong;
in the typical case retail just bounces the body off and lets gravity
take over.
Strict retail behavior would match the user's intent better in the
common case AND avoid the bounce-energy-accumulation we saw with the
slide-tangent approach (V grew to ~50 m/s in continuous-contact frames).
However, retail's behavior degenerates in the edge case of an overhead
landing onto a steep slope (body would freeze mid-air above the roof).
This commit ships the slide-tangent fix as an interim "much better"
state per user verification on 2026-04-30. Follow-up work to match
retail strictly: revert Path 6 steep-slide, audit Phase 3 reset to
ensure kill_velocity (matching OBJECTINFO::kill_velocity ->
CPhysicsObj::set_velocity({0,0,0}, 0)) actually fires, and re-test.
Refs:
- acclient_2013_pseudo_c.txt:323784-323821 (Path 6 SetCollide)
- acclient_2013_pseudo_c.txt:273191-273239 (Phase 3 reset path)
- acclient_2013_pseudo_c.txt:272563-272596 (validate_transition revert)
- acclient_2013_pseudo_c.txt:274467-274475 (kill_velocity)
- acclient_2013_pseudo_c.txt:282699-282715 (handle_all_collisions bounce)
Tests: 833/833 green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5210bd3d55
commit
b1af56eb19
8 changed files with 417 additions and 16 deletions
|
|
@ -506,6 +506,85 @@ public class BSPStepUpTests
|
|||
"indicates Path 5 recursing through DoStepUp without guard.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// L.2c regression: an airborne mover jumping/falling into a vertical wall
|
||||
/// must keep its vertical displacement. With no live or last-known contact
|
||||
/// plane, SlideSphere must remove only the component into the wall; inventing
|
||||
/// a flat UnitZ plane projects the displacement onto the wall/floor crease
|
||||
/// and leaves the character stuck in falling animation against the wall.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void D3_AirborneMover_TallWall_PreservesVerticalMotion()
|
||||
{
|
||||
var (root, resolved) = BSPStepUpFixtures.TallWall();
|
||||
|
||||
var from = new Vector3(0.1f, 0f, 2.0f);
|
||||
var to = new Vector3(0.6f, 0f, 1.5f);
|
||||
|
||||
var t = BSPStepUpFixtures.MakeAirborneTransition(from, to);
|
||||
var engine = MakeTestEngine(root, resolved, terrainZ: -50f);
|
||||
|
||||
t.FindTransitionalPosition(engine);
|
||||
|
||||
Assert.True(t.SpherePath.CurPos.Z < from.Z - 0.1f,
|
||||
$"Expected airborne wall-slide to preserve downward motion; " +
|
||||
$"from.Z={from.Z:F3}, CurPos.Z={t.SpherePath.CurPos.Z:F3}");
|
||||
Assert.True(t.SpherePath.CurPos.X <= 0.5f - BSPStepUpFixtures.SphereRadius + PhysicsGlobals.EPSILON * 20f,
|
||||
$"Expected wall to block X penetration; got CurPos.X={t.SpherePath.CurPos.X:F3}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// L.2c regression: if an airborne wall collision happens in a one-substep
|
||||
/// frame, the collision normal has to survive into the next frame. Retail
|
||||
/// does this with transient_state bit 2 + InitSlidingNormal. Without that,
|
||||
/// every frame replays the same hard stop and the character hangs in falling
|
||||
/// animation until another correction breaks the loop.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void D4_AirborneMover_TallWall_PersistsSlidingNormalAcrossFrames()
|
||||
{
|
||||
var (root, resolved) = BSPStepUpFixtures.TallWall();
|
||||
var engine = MakeTestEngine(root, resolved, terrainZ: -50f);
|
||||
var body = new PhysicsBody
|
||||
{
|
||||
Position = new Vector3(0.25f, 0f, 2.0f),
|
||||
TransientState = TransientStateFlags.Active,
|
||||
};
|
||||
|
||||
var frame1 = engine.ResolveWithTransition(
|
||||
currentPos: body.Position,
|
||||
targetPos: new Vector3(0.36f, 0f, 1.92f),
|
||||
cellId: 0xA9B40001u,
|
||||
sphereRadius: BSPStepUpFixtures.SphereRadius,
|
||||
sphereHeight: 0f,
|
||||
stepUpHeight: 0.04f,
|
||||
stepDownHeight: 0.04f,
|
||||
isOnGround: false,
|
||||
body: body);
|
||||
|
||||
body.Position = frame1.Position;
|
||||
|
||||
Assert.True(body.TransientState.HasFlag(TransientStateFlags.Sliding),
|
||||
"First airborne wall hit should cache SlidingNormal for the next frame.");
|
||||
Assert.Equal(2.0f, frame1.Position.Z, precision: 3);
|
||||
|
||||
var frame2 = engine.ResolveWithTransition(
|
||||
currentPos: body.Position,
|
||||
targetPos: body.Position + new Vector3(0.11f, 0f, -0.08f),
|
||||
cellId: 0xA9B40001u,
|
||||
sphereRadius: BSPStepUpFixtures.SphereRadius,
|
||||
sphereHeight: 0f,
|
||||
stepUpHeight: 0.04f,
|
||||
stepDownHeight: 0.04f,
|
||||
isOnGround: false,
|
||||
body: body);
|
||||
|
||||
Assert.True(frame2.Position.Z < frame1.Position.Z - 0.05f,
|
||||
$"Expected cached wall-slide normal to allow falling on frame 2; " +
|
||||
$"frame1.Z={frame1.Position.Z:F3}, frame2.Z={frame2.Position.Z:F3}");
|
||||
Assert.InRange(frame2.Position.X, 0.24f, 0.31f);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Helpers
|
||||
// =========================================================================
|
||||
|
|
|
|||
|
|
@ -261,6 +261,52 @@ public class PhysicsEngineTests
|
|||
Assert.Equal(50f, result.Position.Z, precision: 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveWithTransition_EdgeSlideAtLoadedTerrainBoundary_PreservesTangentMotion()
|
||||
{
|
||||
var engine = MakeFlatEngine(terrainZ: 50f);
|
||||
var body = new PhysicsBody
|
||||
{
|
||||
Position = new Vector3(191f, 96f, 50f),
|
||||
TransientState = TransientStateFlags.Contact | TransientStateFlags.OnWalkable,
|
||||
ContactPlaneValid = true,
|
||||
ContactPlane = new Plane(Vector3.UnitZ, -50f),
|
||||
ContactPlaneCellId = 0x003Du,
|
||||
};
|
||||
|
||||
var settled = engine.ResolveWithTransition(
|
||||
currentPos: new Vector3(191f, 96f, 50f),
|
||||
targetPos: new Vector3(191.25f, 96f, 50f),
|
||||
cellId: 0x003Du,
|
||||
sphereRadius: 0.5f,
|
||||
sphereHeight: 1.2f,
|
||||
stepUpHeight: 0.4f,
|
||||
stepDownHeight: 0.4f,
|
||||
isOnGround: true,
|
||||
body: body,
|
||||
moverFlags: ObjectInfoState.EdgeSlide);
|
||||
|
||||
Assert.True(body.WalkablePolygonValid);
|
||||
Assert.NotNull(body.WalkableVertices);
|
||||
|
||||
var result = engine.ResolveWithTransition(
|
||||
currentPos: settled.Position,
|
||||
targetPos: new Vector3(193f, 98f, 50f),
|
||||
cellId: 0x003Du,
|
||||
sphereRadius: 0.5f,
|
||||
sphereHeight: 1.2f,
|
||||
stepUpHeight: 0.4f,
|
||||
stepDownHeight: 0.4f,
|
||||
isOnGround: true,
|
||||
body: body,
|
||||
moverFlags: ObjectInfoState.EdgeSlide);
|
||||
|
||||
Assert.True(result.IsOnGround);
|
||||
Assert.InRange(result.Position.X, 190.75f, 192.0001f);
|
||||
Assert.True(result.Position.Y > 96.2f);
|
||||
Assert.Equal(50f, result.Position.Z, precision: 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveWithTransition_LandblockBoundary_UpdatesFullOutdoorCellId()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue