fix(physics): remote bodies slide on steep faces instead of freezing (#32)

A remote observed in acdream landed on a sloped roof and froze; the server slid
on, the gap passed AP-87's 4 m threshold, and the body snapped — the visible
blip. Live probe capture, two adjacent ticks 63 ms apart:

  t=88420671  rsInContact=True rsOnWalkable=False rsIsOnGround=True
              bodyCpNz=0.6097 floorZ=0.6642 steep=True gravity=True
              vel=(2.146,2.264,-3.549)
  t=88420734  contact=True onWalkable=True   <- forced against the sweep
              gravity=False                   <- cleared
              velBeforeZero=(2.146,2.264,0.000)
              moved=0.0000                    <- and every tick after

The roof is 52.4 degrees against a 48.4 degree limit, so acdream's classifier
was CORRECT and was then overruled. Four independent links each froze the body
on their own: a per-tick force of Contact|OnWalkable, a per-tick velocity zero,
a Gravity clear at landing, and a landing edge testing IsOnGround
(= inContact || ...) instead of OnWalkable. The tick called
HandleAllCollisions alone — the tail of SetPositionInternal without its prefix.

Retail simulates remotes locally and derives these bits rather than asserting
them: CPhysics::UseTime @0x00509950 iterates the whole object table;
update_object @0x00515D10 gates only on parent/cell/FROZEN with no
is_player fork; SetPositionInternal @0x00515330 sets CONTACT from
contact_plane_valid @0x00515430 and ON_WALKABLE from contact_plane.N.z vs
floor_z @0x00515465-@0x0051548E before handle_all_collisions @0x005154FE;
set_on_walkable @0x00511310 fires HitGround @0x00511364 / LeaveGround
@0x00511346 edge-triggered with no ownership gate; calc_acceleration
@0x00510950 zeroes only when CONTACT && ON_WALKABLE && !Sledding @0x0051096B;
calc_friction @0x0050EE70 returns at its first line when ON_WALKABLE is clear.
acdream had copied retail's airborne no-op WITHOUT retail's local simulation.

The fix is mostly deletion: stop forging the transients, stop discarding the
authoritative velocity, stop clearing Gravity, and route the remote tick
through the same SetPositionInternal commit TickHidden and the local player
already use, with the landing edge derived from the sweep's own OnWalkable.
AP-87's threshold and conditions and InterpolationManager's node_fail_counter
snap-to-tail are deliberately untouched — this removes the CAUSE of the
divergence rather than weakening the backstop.

Cross-checked against ACE: its only creature-side VectorUpdate emitters are the
jump broadcast and spell projectiles, so integrating the wire velocity cannot
double-move a walking remote; and PhysicsGlobals.DefaultState already carries
Gravity, so deleting the manufactured State |= Gravity is safe.

Register: AP-81 narrowed (its GRAVITY half retired outright), AP-87 annotated,
AP-139 filed (the interpolation-queue clear on the landing edge), AP-140 filed
(the two routing gates select snap-vs-interpolate on walkability where retail
uses CONTACT — adjust_offset @0x00555D30 gates on transient_state & 1
@0x00555D52). AP-140's follow-up is deliberately shaped as "point the two gates
at Body.InContact", NOT "re-derive Airborne", which would perturb five writers
and collide with a pinned RemoteTeleportPlacementTests assertion.

Three gaps recorded in #32 rather than papered over: the new LeaveGround
dispatch is untested for chatter; a persistently !Ok transition can latch a
remote airborne; and — the visual-gate watch item — the deleted forge was a
blanket guarantee of Contact|OnWalkable, and contact_allows_move @0x00528dd0
silently refuses action animations without both, which is the literal root
cause of closed #270. Retail-correct on a steep face, a regression anywhere
else.

10 discriminating tests over a real PhysicsEngine landblock whose contact
normal Z is 0.61 against FloorZ 0.6642 — the live roof's exact relationship.
Suite 11,019 passed / 4 skipped / 0 failed. Includes the temporary
ACDREAM_PROBE_REMOTE_LANDING / ACDREAM_PROBE_REMOTE_SLIDE probe family that
produced the capture above; strip with the family.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-04 10:21:16 +02:00
parent f058dfc9f9
commit 204d0ae047
11 changed files with 3103 additions and 245 deletions

View file

@ -104,6 +104,13 @@ internal sealed class RuntimeRemotePhysicsUpdater
return false;
}
uint serverGuid = record.ServerGuid;
// Bug B (2026-08-04): stamp the GUID for any [remote-slide-*] line
// emitted from inside this remote's synchronous tick — in particular
// blip producer Candidate 2, which fires deep inside
// InterpolationManager and has no GUID of its own. TEMPORARY — strip
// with the ACDREAM_PROBE_REMOTE_SLIDE family.
AcDream.Core.Physics.PhysicsDiagnostics.BeginRemoteSlideAttribution(
serverGuid);
uint localEntityId = record.LocalEntityId
?? throw new InvalidOperationException(
$"Runtime entity 0x{serverGuid:X8}/{record.Incarnation} has no local identity.");
@ -126,48 +133,58 @@ internal sealed class RuntimeRemotePhysicsUpdater
// Retail CPhysicsObj::UpdatePositionInternal @ 0x00512C30 scales
// the CSequence root displacement by m_scale only while the body
// is OnWalkable; otherwise it clears the displacement. Grounded
// remotes below are explicitly OnWalkable and airborne remotes use
// their authoritative velocity/gravity arc, so this is the same
// branch expressed through our retained runtime state.
System.Numerics.Vector3 scaledRootMotionLocalOrigin = !rm.Airborne
? rootMotionLocalFrame.Origin * objectScale
: System.Numerics.Vector3.Zero;
// carries ON_WALKABLE_TS (`if ((transient_state & 2) == 0)` at
// 0x00512CA1 multiplies the accumulated root frame by 0f, the else
// arm by m_scale). Bug B (2026-08-04): read the transient the
// sweep committed, never a separately tracked client bool — the
// two disagree exactly on a steep contact, which is the surface
// this whole fix is about.
bool bodyOnWalkableAtTickStart = rm.Body.OnWalkable;
System.Numerics.Vector3 scaledRootMotionLocalOrigin =
bodyOnWalkableAtTickStart
? rootMotionLocalFrame.Origin * objectScale
: System.Numerics.Vector3.Zero;
// Step 1: re-apply current motion commands → body.Velocity.
// Forces OnWalkable + Contact so the gate in apply_current_movement
// always succeeds (remotes are server-authoritative; we don't
// simulate airborne physics for them).
// Bug B (2026-08-04) capture for the [remote-slide-tick] line
// below. These USED to record whether the deleted per-tick
// `TransientState |= Contact | OnWalkable` force actually flipped a
// clear bit. The force is gone (see the block comment below), so
// they now simply report the transient state the body ENTERED this
// tick with — the INVERSE of what "forced" implied. The C# names
// are kept because the diagnosis doc quotes them, but the LOG keys
// were renamed to `entryNoContact=`/`entryNoWalkable=` so a
// post-fix capture cannot be read against a pre-fix one; grep the
// new keys.
// TEMPORARY — strip with the ACDREAM_PROBE_REMOTE_SLIDE family.
bool slideForcedContact = !rm.Body.InContact;
bool slideForcedWalkable = !rm.Body.OnWalkable;
System.Numerics.Vector3 slideVelocityBeforeZero = rm.Body.Velocity;
// retail CPhysicsObj::update_object 0x00515D10 -> set_active(1)
// @0x00515DC2. ACTIVE is the only transient this tick may assert
// on its own; CONTACT and ON_WALKABLE belong to
// SetPositionInternal (0x00515330) and are committed from the
// sweep's contact plane below.
//
// K-fix9 (2026-04-26): SKIP this when the remote is airborne.
// Otherwise the force-OnWalkable + apply_current_movement
// path stomps the +Z velocity we set in OnLiveVectorUpdated,
// and gravity never gets to integrate the arc. The airborne
// body keeps the launch velocity from the VectorUpdate;
// UpdatePhysicsInternal below applies gravity each tick;
// the next UpdatePosition snaps to the new ground location
// and re-grounds.
// Bug B (2026-08-04): the deleted lines were
// if (!rm.Airborne)
// rm.Body.TransientState |= Contact | OnWalkable | Active;
// rm.Body.Velocity = Vector3.Zero;
// — a per-tick FORGE of both retail transients plus a discard of
// the authoritative velocity ACE delivered. On a 52.4-degree roof
// the sweep correctly reported "contact, not walkable" and this
// overruled it every tick, so `calc_acceleration` saw
// Contact && OnWalkable and returned zero acceleration, friction
// never engaged, and the body could not move at all. Retail has no
// such write: CONTACT comes from `contact_plane_valid`
// (0x00515430) and ON_WALKABLE from `contact_plane.N.z >= floor_z`
// (0x00515465-0x0051548E), and `MoveOrTeleport` 0x00516330 never
// touches the wire velocity vector for a remote at all.
rm.Body.TransientState |=
AcDream.Core.Physics.TransientStateFlags.Active;
if (!rm.Airborne)
{
rm.Body.TransientState |= AcDream.Core.Physics.TransientStateFlags.Contact
| AcDream.Core.Physics.TransientStateFlags.OnWalkable
| AcDream.Core.Physics.TransientStateFlags.Active;
// #184 (2026-07-07): a grounded remote carries NO translation
// velocity. Its per-tick movement is the interp CATCH-UP toward
// the MoveOrTeleport-queued server waypoint (computed at the
// sticky-compose site below), which the KEPT ResolveWithTransition
// sweep de-overlaps against neighbours — and the resolved position
// is written back into the SHADOW (below) so the de-overlap
// persists and neighbours collide against the resolved body, not
// the raw server pos. This REPLACES the old synth-velocity model
// (get_state_velocity / SERVERVEL Body.Velocity = ServerVelocity):
// retail's UpdateObjectInternal (0x005156b0) has NO synth-velocity
// leg — a remote translates by adjust_offset and the UP is a gentle
// target. As of #184 Slice 2b this grounded model is the SINGLE
// remote path (players + NPCs) — retail has no fork.
rm.Body.Velocity = System.Numerics.Vector3.Zero;
// Stale server-velocity → stop the locomotion CYCLE (the legs).
// ANIM ONLY — translation is the catch-up. Kept verbatim (same
// !moveToArmed && !stickyArmed gate) from the old SERVERVEL branch
@ -200,12 +217,6 @@ internal sealed class RuntimeRemotePhysicsUpdater
// this per-node dispatch + the funnel. The #170-deleted per-frame
// apply_current_movement is NOT reintroduced.
}
else
{
// Airborne — keep Active flag (so UpdatePhysicsInternal
// doesn't early-return) but DON'T set Contact / OnWalkable.
rm.Body.TransientState |= AcDream.Core.Physics.TransientStateFlags.Active;
}
// Step 2: CSequence's complete Frame carries motion-table omega through
// the same compose as root translation. PhysicsBody.Omega remains
@ -242,9 +253,15 @@ internal sealed class RuntimeRemotePhysicsUpdater
// Origin when armed (0x00555430 ASSIGNS m_fOrigin — the REPLACE
// dichotomy), so a stuck monster still steers via #171.
// • AIRBORNE: seed an EMPTY frame (no catch-up — the arc integrates
// from velocity + gravity, unchanged).
// Body.Velocity is 0 when grounded (set above), so UpdatePhysicsInternal
// adds no translation on top of the catch-up — no double-move.
// from velocity + gravity, unchanged). Retail expresses that
// gate as `transient_state & 1` (CONTACT_TS) inside
// InterpolationManager::adjust_offset @0x00555D52, which is the
// `inContact:` argument below; before Bug B's fix the deleted
// per-tick force made that argument permanently true.
// Bug B (2026-08-04): the body's own velocity is no longer discarded
// each tick, so UpdatePhysicsInternal genuinely integrates whatever
// the sweep, gravity, and the authoritative wire vector left on it —
// that integration is what a steep-contact slide IS.
if (rm.Host is { } npcHost)
{
AcDream.Core.Physics.Motion.MotionDeltaFrame pmDelta =
@ -252,7 +269,13 @@ internal sealed class RuntimeRemotePhysicsUpdater
pmDelta.Origin = scaledRootMotionLocalOrigin;
pmDelta.Orientation = rootMotionLocalFrame.Orientation;
float maxSpeedNpc = rm.Motion.GetAdjustedMaxSpeed();
System.Numerics.Vector3? terrainNormalNpc = !rm.Airborne
// AD-10 terrain-only slope projection. Bug B (2026-08-04):
// gated on the committed ON_WALKABLE transient, the same fact
// retail root-frame scaling reads (0x00512CA1), instead of the
// client Airborne bool. A body resting on a NON-walkable steep
// contact must not have its root motion projected onto a
// terrain plane it is not standing on.
System.Numerics.Vector3? terrainNormalNpc = bodyOnWalkableAtTickStart
? _physics.Engine.SampleTerrainNormal(
rm.Body.Position.X,
rm.Body.Position.Y)
@ -289,7 +312,13 @@ internal sealed class RuntimeRemotePhysicsUpdater
pmDelta.Origin = scaledRootMotionLocalOrigin;
pmDelta.Orientation = rootMotionLocalFrame.Orientation;
float maxSpeedNpc = rm.Motion.GetAdjustedMaxSpeed();
System.Numerics.Vector3? terrainNormalNpc = !rm.Airborne
// AD-10 terrain-only slope projection. Bug B (2026-08-04):
// gated on the committed ON_WALKABLE transient, the same fact
// retail root-frame scaling reads (0x00512CA1), instead of the
// client Airborne bool. A body resting on a NON-walkable steep
// contact must not have its root motion projected onto a
// terrain plane it is not standing on.
System.Numerics.Vector3? terrainNormalNpc = bodyOnWalkableAtTickStart
? _physics.Engine.SampleTerrainNormal(
rm.Body.Position.X,
rm.Body.Position.Y)
@ -378,12 +407,16 @@ internal sealed class RuntimeRemotePhysicsUpdater
// deR/deH two-scalar reconstruction above.
sphereList: sphereList,
sphereScale: sphereScale,
// K-fix9 (2026-04-26): mirror the K-fix7 gate —
// airborne remotes must NOT pre-seed the
// ContactPlane, otherwise AdjustOffset's snap-to-plane
// branch zeroes the +Z offset every step (same bug
// we hit on the local jump).
isOnGround: !rm.Airborne,
// With a body present this argument no longer seeds
// transition contact at all (retail check_contact
// 0x0050F5B0 owns that, see PhysicsEngine); it only decides
// whether the retained walkable polygon is handed to the
// SpherePath. Bug B (2026-08-04): read the committed
// ON_WALKABLE transient, exactly like the local player
// (`isOnGround: _body.OnWalkable`) and TickHidden
// (`isOnGround: previousOnWalkable`), instead of the client
// Airborne bool.
isOnGround: previousOnWalkable,
body: rm.Body, // persist ContactPlane across frames for slope tracking
// Retail default physics state includes EdgeSlide; remote DR
// should exercise the same edge/cliff branch as local movement.
@ -446,137 +479,321 @@ internal sealed class RuntimeRemotePhysicsUpdater
// to actually-moving remotes — the perf risk the review flagged for
// a packed town. (In-place shadow-move + cell-relink-on-change is a
// further optimization if profiling still shows churn.)
// AD-25 (2026-07-30): retail CPhysicsObj::handle_all_collisions
// (0x00514780, pc:282647) runs UNCONDITIONALLY after EVERY
// SetPositionInternal — remote objects included; a
// VectorUpdate-launched jump arc is ordinary object physics in
// retail. #173 (2026-07-05) first mirrored the local player's
// reflect math here by hand, but with a narrower gate than
// retail's: `shouldReflect = !(prevOnWalkable && nowOnWalkable
// && !sledding)` collapses to the two ad-hoc branches this
// block used to hand-roll, and got BOTH wrong — the sledding
// branch suppressed the bounce exactly when retail's
// `!sledding` term forces it UNCONDITIONALLY, and the
// non-sledding branch only reflected airborne→airborne where
// retail reflects on every transition except grounded→grounded.
// PhysicsObjUpdate.HandleAllCollisions is the same verbatim
// port the local player and every ordinary body already use
// (PhysicsObjUpdate.CommitSetPositionTransition); call it
// directly instead of re-deriving the gate. It already
// no-ops the reflect step when collisionNormalValid is false,
// but — unlike the old wrapper this replaces — still runs the
// fsf&gt;1 unconditional velocity-zero "bleed" regardless of
// whether this tick found a collision normal, matching
// retail's own unconditional call site.
AcDream.Core.Physics.PhysicsObjUpdate.HandleAllCollisions(
rm.Body,
resolveResult.CollisionNormalValid,
resolveResult.CollisionNormal,
previousContact,
previousOnWalkable,
resolveResult.IsOnGround);
// K-fix15 (2026-04-26): post-resolve landing
// detection for airborne remotes. Mirrors
// PlayerMovementController's local-player landing
// path: when the resolver says we're on ground AND
// velocity is no longer pointing up, transition
// back to grounded — clear Airborne, restore
// Contact + OnWalkable, remove Gravity, zero any
// residual downward velocity, and trigger
// HitGround so the sequencer can swap from
// Falling → idle/locomotion. Without this, an
// airborne remote falls through the floor (gravity
// keeps building Velocity.Z negative until the
// sphere-sweep clamps each frame, but Airborne
// stays true forever).
if (rm.Airborne
&& resolveResult.IsOnGround
&& rm.Body.Velocity.Z <= 0f)
// ── SetPositionInternal commit (Bug B, 2026-08-04) ───────────
// This block REPLACES a bare `HandleAllCollisions(...,
// resolveResult.IsOnGround)` call. That call was the TAIL of
// retail SetPositionInternal (0x00515330) without its PREFIX:
// the sweep's own `InContact` / `OnWalkable` — the exact retail
// classification the engine already computed — were never
// committed to the body, and the ground edge was decided from
// `resolveResult.IsOnGround`, which is `inContact || …`
// (PhysicsEngine) and is therefore TRUE on a steep contact.
// A remote that touched a 52.4-degree roof was consequently
// declared landed, forced walkable, and stripped of gravity.
//
// Retail order (0x00515430 → 0x0051548E → 0x005154FE):
// CONTACT_TS <- collision_info.contact_plane_valid
// calc_acceleration
// ON_WALKABLE_TS <- contact_plane.N.z >= floor_z, via
// set_on_walkable @0x00511310, which is
// the SOLE source of
// MovementManager::HitGround /
// ::LeaveGround — no ownership, player, or
// creature gate anywhere in it
// calc_acceleration
// handle_all_collisions
//
// That is PhysicsObjUpdate.CommitSetPositionTransition's
// sequence MINUS its velocity-authority check: the helper also
// honours an `isVelocityCurrent` delegate and skips
// handle_all_collisions when a newer Vector/Movement packet
// installed a velocity from inside the ground-edge callback
// (PhysicsObjUpdate.cs:101-102). That check is inert here —
// this site would pass it as null (the helper's default), the
// same as the TickHidden call below, because a per-quantum
// simulation step is not a packet apply and opens no window in
// which a competing velocity authority could land: the only
// callbacks between the contact prefix and
// handle_all_collisions are HitGround/LeaveGround and the
// ownership re-check. The packet-driven placement paths are
// the ones that need it: `RemoteTeleportPlacement.Apply` is
// the only caller that passes the delegate, and
// `RuntimeSetPositionState`'s canonical commit makes the same
// check inline around its own `HandleAllCollisions`.
//
// It is spelled out through its own public sub-steps
// (CommitSetPositionContactPrefix / the ground edge /
// CommitSetPositionPostGround / HandleAllCollisions — the seam
// whose doc comment exists for precisely this) for two reasons:
// the Bug A landing probes must bracket the exact HitGround
// call, and this per-remote per-quantum path must not allocate
// an `isCurrent` closure.
//
// The whole commit is gated on `Ok && candidateMoved`, matching
// PlayerMovementController and retail UpdateObjectInternal
// (pc:283657): a failed transition is discarded whole and a
// zero-move frame never re-derives contact.
bool candidateMoved = postIntegratePos != preIntegratePos;
if (resolveResult.Ok && candidateMoved)
{
rm.Airborne = false;
// #184 (2026-07-07): clear the interp queue on landing (mirrors
// the player-remote landing). Airborne UPs hard-snap and never
// Enqueue, so any pre-jump waypoints are stale; without this the
// first grounded catch-up after touchdown chases them backward.
rm.Interp.Clear();
rm.Body.TransientState |= AcDream.Core.Physics.TransientStateFlags.Contact
| AcDream.Core.Physics.TransientStateFlags.OnWalkable;
rm.Body.Velocity = new System.Numerics.Vector3(
rm.Body.Velocity.X, rm.Body.Velocity.Y, 0f);
// #161: HitGround MUST run with the Gravity state
// bit still set — CMotionInterp::HitGround
// (0x00528ac0) gates on state&0x400 (retail never
// clears GRAVITY on landing; it's a persistent
// object property). Clearing it first made this
// re-apply a silent no-op, which is why the
// falling pose never exited. The re-apply
// dispatches the PRESERVED pre-fall forward
// command through the funnel → the motion table
// plays the Falling→X landing link. (The old
// K-fix17 forced SetCycle is deleted: it read the
// then-clobbered InterpretedState.ForwardCommand
// — 0x40000015 — and re-set the very Falling
// cycle it meant to clear.)
// R4-V5 (closes the V4 wiring-contract gap the
// adversarial review caught): retail order —
// minterp first, then moveto (MovementManager::
// HitGround 0x00524300, §2d — the R5-V5 facade
// relay). Re-arms a moveto suspended by the
// airborne UseTime contact gate; without it a
// chasing NPC that lands stalls until ACE's
// ~1 Hz re-emit.
ulong landingStateAuthorityVersion =
record.StateAuthorityVersion;
bool finalOnWalkable = AcDream.Core.Physics.PhysicsObjUpdate
.CommitSetPositionContactPrefix(
rm.Body,
resolveResult.InContact,
resolveResult.OnWalkable,
previousOnWalkable);
// Bug A investigation (2026-08-04, docs/ISSUES.md #32):
// capture the exact state HitGround is about to act on —
// see PhysicsDiagnostics.LogRemoteLanding for the field
// list and PhysicsDiagnostics.ProbeRemoteLandingEnabled
// for the discriminator table. TEMPORARY — strip once
// the live-test run has landed.
if (AcDream.Core.Physics.PhysicsDiagnostics.ProbeRemoteLandingEnabled)
if (!previousOnWalkable && finalOnWalkable)
{
bool gravitySetForProbe = rm.Body.HasGravity;
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteLanding(
site: "per-tick",
guid: serverGuid,
airborneBefore: true,
gravitySet: gravitySetForProbe,
contact: rm.Body.InContact,
onWalkable: rm.Body.OnWalkable,
hasDefaultSink: rm.Motion.DefaultSink is not null,
resolveIsOnGround: resolveResult.IsOnGround,
sequencerStyle: sequencer?.CurrentStyle ?? 0,
sequencerMotion: sequencer?.CurrentMotion ?? 0);
if (!gravitySetForProbe)
// Bug A investigation (2026-08-04, docs/ISSUES.md #32):
// capture the exact state HitGround is about to act on —
// see PhysicsDiagnostics.LogRemoteLanding for the field
// list and PhysicsDiagnostics.ProbeRemoteLandingEnabled
// for the discriminator table. TEMPORARY — strip once
// the live-test run has landed.
if (AcDream.Core.Physics.PhysicsDiagnostics.ProbeRemoteLandingEnabled)
{
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteLandingGateNoOp(
"per-tick", serverGuid);
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteLanding(
site: "per-tick",
guid: serverGuid,
airborneBefore: true,
gravitySet: rm.Body.HasGravity,
contact: rm.Body.InContact,
onWalkable: rm.Body.OnWalkable,
hasDefaultSink: rm.Motion.DefaultSink is not null,
resolveIsOnGround: resolveResult.IsOnGround,
sequencerStyle: sequencer?.CurrentStyle ?? 0,
sequencerMotion: sequencer?.CurrentMotion ?? 0);
if (!rm.Body.HasGravity)
{
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteLandingGateNoOp(
"per-tick", serverGuid);
}
AcDream.Core.Physics.PhysicsDiagnostics
.BeginRemoteLandingDispatchCapture();
}
// #161: HitGround MUST run with the Gravity state bit
// still set — CMotionInterp::HitGround (0x00528AC0)
// gates on state & 0x400. Bug B deleted the clear that
// used to follow this call: retail NEVER toggles
// GRAVITY_PS on a ground edge (`set_state` @0x00514DD0
// post-processes only lighting/nodraw/hidden), it gates
// gravity ACCELERATION on the CONTACT/ON_WALKABLE
// transients inside calc_acceleration @0x00510950.
// R4-V5: retail order is minterp then moveto
// (MovementManager::HitGround 0x00524300).
rm.Movement.HitGround();
// Bug A investigation (2026-08-04) — the OUTCOME half of
// the probe above, emitted before the ownership re-check
// below can return so the two lines always pair. See
// PhysicsDiagnostics.LogRemoteLandingAfter and
// docs/research/2026-08-04-bug-a-h3-scheduler-diagnosis.md
// §6.1 for the three-way decision table. TEMPORARY.
if (AcDream.Core.Physics.PhysicsDiagnostics.ProbeRemoteLandingEnabled)
{
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteLandingAfter(
site: "per-tick",
guid: serverGuid,
hitGroundInvoked: true,
sequencerStyle: sequencer?.CurrentStyle ?? 0,
sequencerMotion: sequencer?.CurrentMotion ?? 0,
forwardCommand: rm.Motion.InterpretedState.ForwardCommand);
}
if (!IsCurrentOwner(
record,
rm,
objectClockEpoch,
externalOwnerValid))
{
return false;
}
// #184 (2026-07-07): clear the interp queue on the
// LANDING edge. An airborne remote's Positions hard-snap
// and never Enqueue, so any pre-arc waypoints are stale;
// without this the first grounded catch-up after
// touchdown chases them backward. Bug B kept the
// behaviour and only re-derived the edge — it now hangs
// off the same `set_on_walkable(1)` transition retail
// fires HitGround from, instead of the hand-rolled
// `IsOnGround && Velocity.Z <= 0` test that fired on a
// steep contact too. Register row AP-139.
rm.Interp.Clear();
if (Environment.GetEnvironmentVariable("ACDREAM_DUMP_MOTION") == "1")
Console.WriteLine($"VU.land guid=0x{serverGuid:X8} Z={rm.Body.Position.Z:F2}");
}
else if (previousOnWalkable && !finalOnWalkable)
{
// set_on_walkable(0) @0x0051133C —
// MovementManager::LeaveGround. A remote that walks off
// a ledge or slides off a walkable lip onto a steep face
// now takes retail's ground-departure edge instead of
// staying nominally grounded forever.
rm.Motion.LeaveGround();
if (!IsCurrentOwner(
record,
rm,
objectClockEpoch,
externalOwnerValid))
{
return false;
}
}
rm.Movement.HitGround();
if (!IsCurrentOwner(
record,
rm,
objectClockEpoch,
externalOwnerValid))
{
return false;
}
// DR bookkeeping only (partner of the jump-start
// `State |= Gravity`): stops the per-tick gravity
// integration for the grounded body.
if (record.StateAuthorityVersion
== landingStateAuthorityVersion)
{
rm.Body.State &=
~AcDream.Core.Physics.PhysicsStateFlags.Gravity;
}
AcDream.Core.Physics.PhysicsObjUpdate
.CommitSetPositionPostGround(rm.Body);
if (Environment.GetEnvironmentVariable("ACDREAM_DUMP_MOTION") == "1")
Console.WriteLine($"VU.land guid=0x{serverGuid:X8} Z={rm.Body.Position.Z:F2}");
// retail CPhysicsObj::handle_all_collisions (0x00514780,
// pc:282647) @0x005154FE — the same verbatim port the local
// player and every ordinary body use. `nowOnWalkable` is the
// COMMITTED transient, not the contact-derived
// `resolveResult.IsOnGround` the old call passed: on a steep
// contact those disagree, and passing IsOnGround suppressed
// the landing reflect exactly where retail forces it.
AcDream.Core.Physics.PhysicsObjUpdate.HandleAllCollisions(
rm.Body,
resolveResult.CollisionNormalValid,
resolveResult.CollisionNormal,
previousContact,
previousOnWalkable,
rm.Body.OnWalkable);
// Bug B (2026-08-04): Airborne is DERIVED from the committed
// ON_WALKABLE transient, never latched by a landing test.
// This is the project's ONE definition of the flag — every
// writer spells `!Body.OnWalkable`, and there are FIVE of
// them: `SettleSpawnedRemoteContact` (the spawn-settle
// tail) and `RemoteTeleportPlacement.Apply` in App,
// `RuntimeSetPositionState`'s canonical placement commit,
// and this file's two (here and the `TickHidden` resolve).
// `PlayerMovementController.IsAirborne` computes the same
// predicate for the local player. It stays unchanged here;
// only the fact it is derived FROM has moved, from a
// hand-rolled `IsOnGround` test to the sweep's own
// contact-plane result.
//
// What this flag then GATES is a separate, still-open
// divergence: retail's free-flight predicate for the
// interpolate-vs-snap decision is CONTACT, not walkability
// (`InterpolationManager::adjust_offset` @0x00555D30 gates
// its whole body on `transient_state & 1` @0x00555D52).
// Register row AP-140.
rm.Airborne = !rm.Body.OnWalkable;
}
// Bug B (2026-08-04) — [remote-slide-tick]. Emitted here, after
// the SetPositionInternal commit above, so it reports the
// sweep's own retail classification (rsInContact / rsOnWalkable
// / rsCpNz) next to what the body now carries. Before the fix
// those two columns disagreed on a steep roof — that
// disagreement WAS the bug — and they must now agree on every
// committed frame. bodyCpNz vs floorZ settles NOT ESTABLISHED
// #2 ("is that roof steep in OUR collision data").
//
// Rate limit: ShouldEmitRemoteSlideTick emits immediately on
// any change to the signature below (every contact / walkable /
// grounded / airborne / gravity / steep / moved transition is
// captured at full 30 Hz fidelity) and otherwise throttles to
// one line per GUID per 200 ms, so a RESTING remote — the whole
// point of the capture — stays at ~5 lines/s instead of 30.
// TEMPORARY — strip with the ACDREAM_PROBE_REMOTE_SLIDE family.
{
bool slideBodyCpValid = rm.Body.ContactPlaneValid;
float slideBodyCpNz = rm.Body.ContactPlane.Normal.Z;
int slideSignature =
(rm.Airborne ? 1 << 0 : 0)
| (slideForcedContact ? 1 << 1 : 0)
| (slideForcedWalkable ? 1 << 2 : 0)
| (resolveResult.InContact ? 1 << 3 : 0)
| (resolveResult.OnWalkable ? 1 << 4 : 0)
| (resolveResult.IsOnGround ? 1 << 5 : 0)
| (rm.Body.InContact ? 1 << 6 : 0)
| (rm.Body.OnWalkable ? 1 << 7 : 0)
| (rm.Body.HasGravity ? 1 << 8 : 0)
| (slideBodyCpValid ? 1 << 9 : 0)
| (slideBodyCpValid
&& slideBodyCpNz
< AcDream.Core.Physics.PhysicsGlobals.FloorZ
? 1 << 10 : 0)
| (System.Numerics.Vector3.Distance(
preIntegratePos, resolveResult.Position) > 0.01f
? 1 << 11 : 0);
if (AcDream.Core.Physics.PhysicsDiagnostics
.ShouldEmitRemoteSlideTick(serverGuid, slideSignature))
{
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteSlideTick(
guid: serverGuid,
airborne: rm.Airborne,
forcedContact: slideForcedContact,
forcedWalkable: slideForcedWalkable,
velocityBeforeZero: slideVelocityBeforeZero,
resolved: true,
resolveInContact: resolveResult.InContact,
resolveOnWalkable: resolveResult.OnWalkable,
resolveIsOnGround: resolveResult.IsOnGround,
resolveContactPlaneValid: resolveResult.InContact,
resolveContactPlaneNormalZ:
resolveResult.ContactPlane.Normal.Z,
bodyContactPlaneValid: slideBodyCpValid,
bodyContactPlaneNormalZ: slideBodyCpNz,
contact: rm.Body.InContact,
onWalkable: rm.Body.OnWalkable,
gravity: rm.Body.HasGravity,
velocity: rm.Body.Velocity,
acceleration: rm.Body.Acceleration,
preIntegratePosition: preIntegratePos,
postIntegratePosition: postIntegratePos,
resolvedPosition: resolveResult.Position);
}
}
}
else
{
// Bug B (2026-08-04): the sweep was SKIPPED this tick (no
// starting cell, or no landblocks resident). Reported with
// resolved=false and every rs* field default so a silent
// stretch in the log cannot be misread as "the probe is not
// firing". Same edge-or-throttle admission. TEMPORARY — strip
// with the ACDREAM_PROBE_REMOTE_SLIDE family.
bool skipBodyCpValid = rm.Body.ContactPlaneValid;
float skipBodyCpNz = rm.Body.ContactPlane.Normal.Z;
int skipSignature =
(rm.Airborne ? 1 << 0 : 0)
| (slideForcedContact ? 1 << 1 : 0)
| (slideForcedWalkable ? 1 << 2 : 0)
| (rm.Body.InContact ? 1 << 6 : 0)
| (rm.Body.OnWalkable ? 1 << 7 : 0)
| (rm.Body.HasGravity ? 1 << 8 : 0)
| (skipBodyCpValid ? 1 << 9 : 0)
| (1 << 12);
if (AcDream.Core.Physics.PhysicsDiagnostics
.ShouldEmitRemoteSlideTick(serverGuid, skipSignature))
{
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteSlideTick(
guid: serverGuid,
airborne: rm.Airborne,
forcedContact: slideForcedContact,
forcedWalkable: slideForcedWalkable,
velocityBeforeZero: slideVelocityBeforeZero,
resolved: false,
resolveInContact: false,
resolveOnWalkable: false,
resolveIsOnGround: false,
resolveContactPlaneValid: false,
resolveContactPlaneNormalZ: 0f,
bodyContactPlaneValid: skipBodyCpValid,
bodyContactPlaneNormalZ: skipBodyCpNz,
contact: rm.Body.InContact,
onWalkable: rm.Body.OnWalkable,
gravity: rm.Body.HasGravity,
velocity: rm.Body.Velocity,
acceleration: rm.Body.Acceleration,
preIntegratePosition: preIntegratePos,
postIntegratePosition: postIntegratePos,
resolvedPosition: rm.Body.Position);
}
}
@ -696,6 +913,13 @@ internal sealed class RuntimeRemotePhysicsUpdater
?? throw new InvalidOperationException(
$"Runtime entity 0x{record.ServerGuid:X8}/{record.Incarnation} has no local identity.");
// Bug B (2026-08-04): hidden remotes run the same ComposeOffset chain,
// so the InterpolationManager stall snap can fire from here too and
// needs the same GUID attribution. TEMPORARY — strip with the
// ACDREAM_PROBE_REMOTE_SLIDE family.
AcDream.Core.Physics.PhysicsDiagnostics.BeginRemoteSlideAttribution(
record.ServerGuid);
System.Numerics.Vector3 preComposePosition = rm.Body.Position;
// The part-array contribution is the identity frame while Hidden.

View file

@ -41,6 +41,15 @@ internal static class RuntimeRemoteSteadyStatePosition
/// </summary>
private const float BodySnapThreshold = 4f;
/// <summary>
/// Bug B (2026-08-04): the same constant, exposed read-only so the
/// <c>[remote-slide-up]</c> line can print the threshold its
/// <c>bodyToTarget</c> is about to be compared against instead of the
/// reader having to remember it. TEMPORARY — strip with the
/// <c>ACDREAM_PROBE_REMOTE_SLIDE</c> family.
/// </summary>
internal const float DiagnosticBodySnapThreshold = BodySnapThreshold;
internal enum Action : byte
{
/// <summary>AP-87 backstop: the body wasn't already tracking the
@ -130,6 +139,28 @@ internal static class RuntimeRemoteSteadyStatePosition
float bodyToTarget = Vector3.Distance(remote.Body.Position, worldPosition);
if (firstUp || !willBeDrTicked || bodyToTarget > BodySnapThreshold)
{
// Bug B (2026-08-04) blip producer CANDIDATE 1. Emitted BEFORE the
// snap so body/queue state is the pre-snap truth the reader needs.
// docs/research/2026-08-04-bug-b-remote-slide-diagnosis.md §2.
// Pure read; the GUID comes from the attribution latch the routing
// seam stamps. TEMPORARY — strip with the probe family.
if (AcDream.Core.Physics.PhysicsDiagnostics.ShouldLogRemoteSlide(
AcDream.Core.Physics.PhysicsDiagnostics.RemoteSlideAttributionGuid))
{
(int depth, int failCount) =
remote.Interp.DiagnosticInterpolationState;
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteSlideBodySnap(
guid: AcDream.Core.Physics.PhysicsDiagnostics
.RemoteSlideAttributionGuid,
firstUp: firstUp,
willBeDrTicked: willBeDrTicked,
bodyToTarget: bodyToTarget,
threshold: BodySnapThreshold,
bodyPosition: remote.Body.Position,
targetPosition: worldPosition,
interpQueueDepth: depth,
interpFailCount: failCount);
}
remote.Interp.Clear();
remote.Body.Position = worldPosition;
remote.Body.Orientation = orientation;
@ -144,6 +175,23 @@ internal static class RuntimeRemoteSteadyStatePosition
remote.Body.Orientation);
if (immediate is { } close)
remote.Body.Orientation = close;
// Bug B (2026-08-04): the NON-blip outcome. Its presence across a
// slide window is what separates Shape B (queue fed, so the
// InterpolationManager stall snap can arm) from Shape A (queue never
// fed at all). TEMPORARY — strip with the probe family.
if (AcDream.Core.Physics.PhysicsDiagnostics.ShouldLogRemoteSlide(
AcDream.Core.Physics.PhysicsDiagnostics.RemoteSlideAttributionGuid))
{
(int depth, int failCount) =
remote.Interp.DiagnosticInterpolationState;
AcDream.Core.Physics.PhysicsDiagnostics.LogRemoteSlideEnqueue(
guid: AcDream.Core.Physics.PhysicsDiagnostics
.RemoteSlideAttributionGuid,
bodyToTarget: bodyToTarget,
targetPosition: worldPosition,
interpQueueDepth: depth,
interpFailCount: failCount);
}
return Action.Enqueued;
}