feat(physics): R5-V1 — port PositionManager/Sticky/Constraint + TargetManager (Core, unwired)

The retail movement-manager family the R4 MoveToManager port left as
do-not-invent seams (decomp §9f/§9g). Faithful C# ports of retail's
PositionManager facade + StickyManager + ConstraintManager + the
TargetManager voyeur system, with full conformance tests. NO wiring yet
— purely additive, no behavior change. Wiring (retiring TS-39 sticky +
AP-79 target adapter) is R5-V2/V3.

New Core classes (src/AcDream.Core/Physics/Motion/):
- StickyManager (0x00555400): follow-a-target steering. adjust_offset's
  dense x87 mush decoded via ACE (StickyRadius 0.3, StickyTime 1.0,
  follow speed ×5 / fallback 15) — speed-clamped signed-distance steer +
  bounded turn-to-face; 1 s watchdog; Ok→initialized / non-Ok→teardown.
- ConstraintManager (0x00556090): the server-position rubber-band leash.
  90% IsFullyConstrained jump gate + grounded linear brake taper.
  Structural only — acdream never ARMS it (retail arms from
  SmartBox::HandleReceivedPosition, which acdream lacks, with two x87
  constants BN elided). IsFullyConstrained stays false = TS-35 behavior;
  leash-arming + the unknown constants are a deferred issue.
- PositionManager facade (0x00555160): lazy Sticky/Constraint + fan-out.
- TargetManager (0x0051a370) + TargettedVoyeurInfo: the peer-to-peer
  voyeur subscription system (0.5 s throttle, 10 s staleness,
  send-on-drift-past-radius, dead-reckon GetInterpolatedPosition). A
  faithful superset of the AP-79 adapter — SetTarget subscribes ON the
  target; the target's HandleTargetting pushes updates back.
- IPhysicsObjHost: the CPhysicsObj back-pointer seam (position/velocity/
  radius/contact/GetObjectA + target-tracking fan-out) the App wires per
  entity in V2/V3. MotionDeltaFrame: mutable retail-Frame delta accumulator.

Supporting:
- TargetInfo extended to the full retail 10-field struct (additive
  defaults keep the R4 4-arg call sites compiling).
- MoveToMath: signed CylinderDistanceNoZ, NormalizeCheckSmall,
  GlobalToLocalVec.
- Rename: the misnamed AcDream.Core.Physics.PositionManager (a remote
  anim+interp per-frame combiner, NOT the retail facade) → RemoteMotion
  Combiner, freeing the name and removing the ambiguity that breaks every
  file importing both Physics + Physics.Motion (GameWindow will in V2/V3).

Tests: 42 new conformance cases (Sticky/Constraint/Position facade +
TargetManager incl. the full cross-entity voyeur round-trip). Full suite
4006 green (+2 skipped), no regressions.

Decomp + ACE cross-ref + port plan: docs/research/2026-07-03-r5-managers/.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-07-03 19:34:49 +02:00
parent 517bbfdae4
commit 3d89446d98
25 changed files with 7279 additions and 12 deletions

View file

@ -1558,10 +1558,21 @@ public sealed class MoveToManager
/// <summary>
/// Retail <c>TargetInfo</c> (acclient.h:31591, struct #3482) — the callback
/// payload <see cref="MoveToManager.HandleUpdateTarget"/> consumes. The P4
/// TargetTracker adapter (App-side, R4-V4 scope) is the ONLY producer;
/// <see cref="MoveToManager"/> itself has no target-tracking machinery of its
/// own (TargetManager bodies are R5 — decomp §9f, do-not-invent list).
/// payload <see cref="MoveToManager.HandleUpdateTarget"/> consumes AND the wire
/// record the R5 <see cref="TargetManager"/> voyeur system exchanges between
/// hosts (<c>SendVoyeurUpdate</c> → <c>receive_target_update</c> →
/// <see cref="TargetManager.ReceiveUpdate"/>).
///
/// <para>R5 EXTENDED this from the R4 4-field callback shape to the full retail
/// 10-field struct. The extra fields (<see cref="ContextId"/>,
/// <see cref="Radius"/>, <see cref="Quantum"/>,
/// <see cref="InterpolatedHeading"/>, <see cref="Velocity"/>,
/// <see cref="LastUpdateTime"/>) default to zero, so the existing 4-argument
/// <c>new TargetInfo(id, status, tp, ip)</c> call sites (MoveToManager tests,
/// the AP-79 adapter pre-V2) still compile unchanged.
/// <see cref="MoveToManager.HandleUpdateTarget"/> only reads
/// <see cref="ObjectId"/>/<see cref="Status"/>/<see cref="InterpolatedPosition"/>;
/// the extra fields are consumed by the voyeur system.</para>
/// </summary>
/// <param name="ObjectId">Retail <c>object_id</c> — matched against
/// <see cref="MoveToManager.TopLevelObjectId"/>; a mismatch is silently
@ -1572,11 +1583,30 @@ public sealed class MoveToManager
/// <param name="InterpolatedPosition">Retail <c>interpolated_position</c> —
/// the smoothed tracking point <see cref="MoveToManager.MoveToObject_Internal"/>
/// steers toward.</param>
/// <param name="ContextId">Retail <c>context_id</c> — the tracking context
/// (0 = the movement context; <c>CPhysicsObj::HandleUpdateTarget</c> only fans
/// out context 0).</param>
/// <param name="Radius">Retail <c>radius</c> — the voyeur's send-on-move
/// threshold (game units).</param>
/// <param name="Quantum">Retail <c>quantum</c> — the dead-reckoning lookahead
/// horizon (seconds) for <c>GetInterpolatedPosition</c>.</param>
/// <param name="InterpolatedHeading">Retail <c>interpolated_heading</c> —
/// normalized self→target direction (falls back to +Z when degenerate).</param>
/// <param name="Velocity">Retail <c>velocity</c> — the target's velocity at
/// send time.</param>
/// <param name="LastUpdateTime">Retail <c>last_update_time</c> — receipt
/// timestamp (drives the 10 s staleness timeout).</param>
public readonly record struct TargetInfo(
uint ObjectId,
TargetStatus Status,
Position TargetPosition,
Position InterpolatedPosition);
Position InterpolatedPosition,
uint ContextId = 0,
float Radius = 0f,
double Quantum = 0.0,
Vector3 InterpolatedHeading = default,
Vector3 Velocity = default,
double LastUpdateTime = 0.0);
/// <summary>
/// Retail <c>TargetStatus</c> (acclient.h:7264). Only <see cref="Ok"/> vs