fix(physics): #265/#166 - stop zeroing grounded residual velocity, wire GroundNormal
Capture bisect (docs/research/2026-07-30-265-capture-bisect.md, mined from artifacts/matrix-session2-resolve.jsonl records 3415-3434) traced #265's lost roof slides / permanent landing freeze and #166's missing downhill sled to a pre-existing (2026-07-20, ten days before Campaign P - not a regression) mechanism in PlayerMovementController.cs's grounded quantum block: it hand-zeroed Velocity.X/Y to exactly zero every tick once OnWalkable whenever animation root motion drives the walk (the production graphical local-player path), discarding any residual horizontal momentum a fall left on the body before calc_friction (AP-7/AD-55, already correctly ported) or PhysicsBody. UpdatePhysicsInternal's Euler integrator ever got a chance to act on it. Two changes: 1. PhysicsEngine.cs now syncs body.GroundNormal (the vector calc_friction dots velocity against, per retail CPhysicsObj::calc_friction 0x0050ee70's `contact_plane.Normal` read) from the committed ContactPlane.Normal at the same commit point that already publishes ContactPlane. GroundNormal had zero production writers before this and silently defaulted to Vector3.UnitZ forever - even surviving velocity would have been tested against a fake flat-ground normal on any real slope. Core-level, so player, remote, ordinary, and projectile movers all benefit uniformly. 2. PlayerMovementController.cs's grounded block no longer reconstructs Velocity at all for the animation-root-motion case (only the headless/test-controller get_state_velocity fallback still does, unchanged). Root motion continues to fully own commanded locomotion; this only stops destroying whatever Velocity already holds, letting it compose with root motion through the same ResolveWithTransition sweep exactly as retail's CPhysicsObj::UpdatePositionInternal composes both channels. Symptom (a), the uphill-jump bounce, traces to a SEPARATE, byte-exact (re-verified against acclient_2013_pseudo_c.txt:282647-282760), already-closed retail mechanism (AD-25, PhysicsObjUpdate. HandleAllCollisions's shouldReflect gate) - confirmed orthogonal to this fix, not addressed here (see the research doc's as-fixed addendum §9.5). Issue265SteepSlopeCaptureBisectTests.cs gains a composed harness (ReplayRealRoofLandingComposed) mirroring PlayerMovementController.cs's per-tick composition against Core types only, proving: the old model reproduces the mined freeze exactly; the new model survives the landing and slides continuously (the real captured geometry glides at constant velocity per retail's own dot>=0.25 early-return - AP-7); a synthetic dot<0.25 case shows genuine exponential decay via calc_friction; and a synthetic uphill-bounce case proves the fix changes nothing about HandleAllCollisions's reflection decision. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
61e959169b
commit
06c76009f1
5 changed files with 673 additions and 36 deletions
|
|
@ -1300,6 +1300,18 @@ public sealed class PhysicsEngine
|
|||
body.ContactPlane = ci.ContactPlane;
|
||||
body.ContactPlaneCellId = ci.ContactPlaneCellId;
|
||||
body.ContactPlaneIsWater = ci.ContactPlaneIsWater;
|
||||
// #265/#166 (2026-07-30): retail CPhysicsObj::calc_friction
|
||||
// (0x0050ee70) reads `this->contact_plane.Normal` directly off
|
||||
// the object (see PhysicsBody.calc_friction's doc comment).
|
||||
// acdream models that same field as the separate GroundNormal
|
||||
// property so isolated unit tests can drive calc_friction
|
||||
// without a full resolve, but nothing wrote it from a live
|
||||
// resolve before now -- calc_friction always saw the Vector3.UnitZ
|
||||
// default, i.e. every slope behaved like flat ground. Sync it
|
||||
// here, at the SAME commit point that already publishes
|
||||
// ContactPlane, so every caller (player, remote, ordinary,
|
||||
// projectile) gets a real slope normal for free.
|
||||
body.GroundNormal = ci.ContactPlane.Normal;
|
||||
}
|
||||
else if (ci.LastKnownContactPlaneValid)
|
||||
{
|
||||
|
|
@ -1307,10 +1319,16 @@ public sealed class PhysicsEngine
|
|||
body.ContactPlane = ci.LastKnownContactPlane;
|
||||
body.ContactPlaneCellId = ci.LastKnownContactPlaneCellId;
|
||||
body.ContactPlaneIsWater = ci.LastKnownContactPlaneIsWater;
|
||||
body.GroundNormal = ci.LastKnownContactPlane.Normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
body.ContactPlaneValid = false;
|
||||
// GroundNormal left unchanged/stale -- matches ContactPlane's
|
||||
// own stale-retention pattern in this branch (comment above).
|
||||
// calc_friction only reads it while OnWalkable, and OnWalkable
|
||||
// cannot be true without a valid contact plane, so a stale
|
||||
// value here is never observed.
|
||||
}
|
||||
|
||||
// AP-10 (Campaign P Slice P4, 2026-07-30): retail SetPositionInternal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue