acdream/tests/AcDream.App.Tests/Input/LocalPlayerProjectionControllerTests.cs
Erik 6921a02744 refactor(physics): delete legacy PhysicsEngine.Resolve/ResolvePlacement/HasCellSurface (C5a, AP-1/AD-1)
Member-wise deletion of the three legacy resolver members named in
docs/research/2026-08-05-c5a-contract.md: PhysicsEngine.Resolve,
PhysicsEngine.HasCellSurface, and PhysicsEngine.ResolvePlacement. An
exhaustive receiver census over src/ found zero production callers of any
of the three — every production placement writer already reaches the
canonical PhysicsEngine.SetPosition transaction exclusively through
RuntimeSetPositionState (three call sites total). The deletion is purely
member-wise: IsSpawnCellReady and AdjustPosition, which shared the same
source region as the deleted members, are preserved byte-identical — every
remaining production caller of either (including PhysicsCameraCollisionProbe,
AdjustPosition's sole surviving production caller) is unaffected.

Companion changes:
- PlayerMovementController's 3-argument SetPosition test overload is renamed
  to SeedPlacementForTest (internal) and CommitPreparedPosition is deleted;
  83 call sites across 19 test files were mechanically renamed to match.
- Seven pinned test dispositions from the contract are executed:
  3.1 (PhysicsEngineTests.cs: 11 legacy-resolver tests deleted, 6
  ResolveWithTransition tests kept), 3.2/3.3/3.4 (re-point to canonical
  SetPosition, with TransitionScratchDifferentialTests.cs additionally
  gaining positive IsCommitted assertions after each bitwise comparison so
  the differential proves a placement actually committed, not just that two
  possibly-uncommitted results match), 3.5 (Runtime rename), and 3.6
  (PlayerMovementPlacementTransactionTests.cs rewritten — its xmldoc now
  states plainly that the render-root publish moved to
  RuntimeSetPositionState.cs, but the sticky-release relocation claim was
  false and is retracted; this disposition's coverage loss is the sticky
  release path, not silently absorbed elsewhere).
- Stale `PhysicsEngine.Resolve`/`Resolve` doc citations in CellTransit.cs,
  PlayerMovementController.cs, and HeadlessSessionWorldProjection.cs are
  corrected to name the surviving canonical entry points by symbol
  (SetPosition, AdjustSetPosition/AdjustPosition, ResolveWithTransition)
  rather than fragile line numbers.

Retires AP-1 and AD-1 in docs/architecture/retail-divergence-register.md:
both rows described production zero-delta placement routing remaining on
the legacy resolver pending the Slice 4B2/4B route cutover; that resolver
no longer exists, so the condition each row tracked is now structurally
false rather than merely narrowed. AP-145 (routed through the prior commit)
and this commit's AP-1/AD-1 together bring the section counts to 101 AP / 47
AD active rows.

Builds on the AP-145 fix (previous commit) — this commit's staged tree was
independently rebuilt and its four suites independently rerun on top of
that commit before this commit was created, in addition to the combined
rebuild/rerun below.

Full-solution build: 0 errors (21 pre-existing warnings, all unrelated).
Suite results (combined tree): Core 4270/4271 passed (1 skip; the single
DatSoundCacheTests concurrent-decode-dedup failure is a known load-sensitive
race, confirmed passing standalone and unrelated to this change), Runtime
1176/1176, Headless 86/86, App 4132/4135 (3 skips).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 14:11:31 +02:00

144 lines
4.9 KiB
C#

using System.Numerics;
using AcDream.App.Input;
using AcDream.Core.Physics;
using AcDream.Core.World;
namespace AcDream.App.Tests.Input;
public sealed class LocalPlayerProjectionControllerTests
{
[Fact]
public void Project_PreservesCompleteAuthoritativeBodyQuaternion()
{
const uint cellId = 0x01010001u;
Quaternion complete = Quaternion.Normalize(
Quaternion.CreateFromAxisAngle(Vector3.UnitX, 0.7f)
* Quaternion.CreateFromAxisAngle(Vector3.UnitY, -0.4f));
var movement = new PlayerMovementController(new PhysicsEngine());
movement.SeedPlacementForTest(Vector3.Zero, cellId, Vector3.Zero);
movement.SetBodyOrientation(complete);
var entity = new WorldEntity
{
Id = 7u,
ServerGuid = 0x50000001u,
SourceGfxObjOrSetupId = 0x02000001u,
Position = Vector3.Zero,
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
};
var projection = new LocalPlayerProjectionController(new TestProjectionRuntime(
() => entity,
() => 1,
() => 1,
(_, _) => { },
(_, _) => { },
_ => true,
_ => { }));
projection.Project(
movement,
movement.CapturePresentationResult(),
hidden: false);
Assert.InRange(
MathF.Abs(Quaternion.Dot(
complete,
Quaternion.Normalize(entity.Rotation))),
0.99999f,
1.00001f);
}
[Fact]
public void Project_AlreadyPendingChangedPose_DoesNotResurrectShadow()
{
const uint cellId = 0x02020001u;
var movement = new PlayerMovementController(new PhysicsEngine());
movement.SeedPlacementForTest(new Vector3(12f, 8f, 3f), cellId, Vector3.Zero);
var entity = new WorldEntity
{
Id = 8u,
ServerGuid = 0x50000001u,
SourceGfxObjOrSetupId = 0x02000001u,
Position = Vector3.Zero,
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
};
var order = new List<string>();
var projection = new LocalPlayerProjectionController(new TestProjectionRuntime(
() => entity,
() => 2,
() => 2,
(_, _) => order.Add("shadow"),
(_, _) => order.Add("rebucket"),
_ => false,
_ => order.Add("suspend")));
projection.Project(
movement,
movement.CapturePresentationResult(),
hidden: false);
Assert.Equal(["rebucket", "suspend"], order);
Assert.Equal(movement.Position, entity.Position);
Assert.Equal(cellId, entity.ParentCellId);
}
[Fact]
public void Project_PendingToLoaded_RebucketsBeforeStationaryShadowRestore()
{
const uint cellId = 0x02020001u;
var movement = new PlayerMovementController(new PhysicsEngine());
movement.SeedPlacementForTest(new Vector3(12f, 8f, 3f), cellId, Vector3.Zero);
var entity = new WorldEntity
{
Id = 9u,
ServerGuid = 0x50000001u,
SourceGfxObjOrSetupId = 0x02000001u,
Position = movement.Position,
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
};
bool visible = false;
var order = new List<string>();
var projection = new LocalPlayerProjectionController(new TestProjectionRuntime(
() => entity,
() => 2,
() => 2,
(_, _) => order.Add("shadow"),
(_, _) =>
{
order.Add("rebucket");
visible = true;
},
_ => visible,
_ => order.Add("suspend")));
projection.Project(
movement,
movement.CapturePresentationResult(),
hidden: false);
Assert.Equal(["rebucket", "shadow"], order);
}
private sealed class TestProjectionRuntime(
Func<WorldEntity?> resolveEntity,
Func<int> liveCenterX,
Func<int> liveCenterY,
Action<WorldEntity, uint> syncShadow,
Action<uint, uint> rebucket,
Func<WorldEntity, bool> isCurrentVisibleProjection,
Action<WorldEntity> suspendShadow) : ILocalPlayerProjectionRuntime
{
public WorldEntity? ResolveEntity() => resolveEntity();
public int LiveCenterX => liveCenterX();
public int LiveCenterY => liveCenterY();
public void SyncShadow(WorldEntity entity, uint cellId) =>
syncShadow(entity, cellId);
public void Rebucket(uint serverGuid, uint landblockId) =>
rebucket(serverGuid, landblockId);
public bool IsCurrentVisibleProjection(WorldEntity entity) =>
isCurrentVisibleProjection(entity);
public void SuspendShadow(WorldEntity entity) => suspendShadow(entity);
}
}