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>
232 lines
7.7 KiB
C#
232 lines
7.7 KiB
C#
using System.Numerics;
|
|
using AcDream.App.Combat;
|
|
using AcDream.App.Input;
|
|
using AcDream.App.Rendering;
|
|
using AcDream.App.Update;
|
|
using AcDream.Core.Physics;
|
|
|
|
namespace AcDream.App.Tests.Rendering;
|
|
|
|
[Collection(CameraDiagnosticsCollection.Name)]
|
|
public sealed class CameraFrameControllerTests
|
|
{
|
|
[Fact]
|
|
public void FlyMode_UsesOneSemanticHeldInputSnapshot()
|
|
{
|
|
CameraController camera = CreateCamera();
|
|
camera.ToggleFly();
|
|
Vector3 start = camera.Fly.Position;
|
|
var input = new InputSource
|
|
{
|
|
Fly = new FlyCameraInput(
|
|
Forward: true,
|
|
Left: false,
|
|
Backward: false,
|
|
Right: false,
|
|
Up: true,
|
|
Down: false,
|
|
Boost: false),
|
|
};
|
|
CameraFrameController frame = CreateFrame(camera, input: input);
|
|
|
|
frame.Tick(new UpdateFrameTiming(0.5, 0.5f, 0.5));
|
|
|
|
Assert.Equal(1, input.FlyCaptures);
|
|
Assert.InRange(camera.Fly.Position.Y - start.Y, 5.999f, 6.001f);
|
|
Assert.InRange(camera.Fly.Position.Z - start.Z, 5.999f, 6.001f);
|
|
}
|
|
|
|
[Fact]
|
|
public void DevToolsKeyboardCapture_PausesFlyCamera()
|
|
{
|
|
CameraController camera = CreateCamera();
|
|
camera.ToggleFly();
|
|
Vector3 start = camera.Fly.Position;
|
|
var input = new InputSource
|
|
{
|
|
Fly = new FlyCameraInput(true, false, false, false, false, false, false),
|
|
};
|
|
CameraFrameController frame = CreateFrame(
|
|
camera,
|
|
capture: new CaptureSource { DevToolsKeyboard = true },
|
|
input: input);
|
|
|
|
frame.Tick(new UpdateFrameTiming(1.0, 1f, 1.0));
|
|
|
|
Assert.Equal(start, camera.Fly.Position);
|
|
Assert.Equal(0, input.FlyCaptures);
|
|
}
|
|
|
|
[Fact]
|
|
public void InboundCreatedPlayer_ProjectsThenReconcilesBeforeCameraPublication()
|
|
{
|
|
PlayerMovementController controller = CreatePlayer();
|
|
var calls = new List<string>();
|
|
var runtime = new PlayerRuntime(controller, calls);
|
|
var localFrame = new RetailLocalPlayerFrameController(
|
|
runtime,
|
|
new StillMovementInput());
|
|
CameraController camera = CreateCamera();
|
|
var legacy = new ChaseCamera();
|
|
var retail = new RetailChaseCamera();
|
|
camera.EnterChaseMode(legacy, retail);
|
|
var chase = new ChaseSource(legacy, retail);
|
|
var reconciler = new Reconciler(calls);
|
|
var frame = new CameraFrameController(
|
|
camera,
|
|
new CaptureSource(),
|
|
new InputSource(),
|
|
runtime,
|
|
chase,
|
|
localFrame,
|
|
reconciler,
|
|
new CombatTargetSource());
|
|
|
|
frame.Tick(new UpdateFrameTiming(1.0 / 60.0, 1f / 60f, 1.0));
|
|
|
|
Assert.Equal(["project", "reconcile"], calls);
|
|
Assert.NotEqual(Vector3.Zero, legacy.Position);
|
|
Assert.NotEqual(Vector3.Zero, retail.Position);
|
|
}
|
|
|
|
[Fact]
|
|
public void PreNetworkAdvancedPlayer_DoesNotRunTheInboundCreationReconcile()
|
|
{
|
|
PlayerMovementController controller = CreatePlayer();
|
|
var calls = new List<string>();
|
|
var runtime = new PlayerRuntime(controller, calls);
|
|
var localFrame = new RetailLocalPlayerFrameController(
|
|
runtime,
|
|
new StillMovementInput());
|
|
localFrame.AdvanceBeforeNetwork(PhysicsBody.MaxQuantum);
|
|
calls.Clear();
|
|
CameraController camera = CreateCamera();
|
|
var legacy = new ChaseCamera();
|
|
var retail = new RetailChaseCamera();
|
|
camera.EnterChaseMode(legacy, retail);
|
|
var frame = new CameraFrameController(
|
|
camera,
|
|
new CaptureSource(),
|
|
new InputSource(),
|
|
runtime,
|
|
new ChaseSource(legacy, retail),
|
|
localFrame,
|
|
new Reconciler(calls),
|
|
new CombatTargetSource());
|
|
|
|
frame.Tick(new UpdateFrameTiming(1.0 / 60.0, 1f / 60f, 1.0));
|
|
|
|
Assert.Empty(calls);
|
|
}
|
|
|
|
private static CameraFrameController CreateFrame(
|
|
CameraController camera,
|
|
CaptureSource? capture = null,
|
|
InputSource? input = null)
|
|
{
|
|
var runtime = new PlayerRuntime(null, []);
|
|
var localFrame = new RetailLocalPlayerFrameController(
|
|
runtime,
|
|
new StillMovementInput());
|
|
return new CameraFrameController(
|
|
camera,
|
|
capture ?? new CaptureSource(),
|
|
input ?? new InputSource(),
|
|
runtime,
|
|
new ChaseSource(null, null),
|
|
localFrame,
|
|
new Reconciler([]),
|
|
new CombatTargetSource());
|
|
}
|
|
|
|
private static CameraController CreateCamera() =>
|
|
new(new OrbitCamera(), new FlyCamera());
|
|
|
|
private static PlayerMovementController CreatePlayer()
|
|
{
|
|
var engine = new PhysicsEngine();
|
|
var heights = new byte[81];
|
|
Array.Fill(heights, (byte)50);
|
|
var heightTable = new float[256];
|
|
for (int i = 0; i < heightTable.Length; i++)
|
|
heightTable[i] = i;
|
|
engine.AddLandblock(
|
|
0xA9B4FFFFu,
|
|
new TerrainSurface(heights, heightTable),
|
|
Array.Empty<CellSurface>(),
|
|
Array.Empty<PortalPlane>(),
|
|
0f,
|
|
0f);
|
|
var controller = new PlayerMovementController(engine);
|
|
controller.SeedPlacementForTest(new Vector3(96f, 96f, 50f), 0x0001u, new Vector3(96f, 96f, 50f));
|
|
return controller;
|
|
}
|
|
|
|
private sealed class CaptureSource : IInputCaptureSource
|
|
{
|
|
public bool DevToolsKeyboard { get; set; }
|
|
public bool WantCaptureMouse => false;
|
|
public bool WantCaptureKeyboard => DevToolsKeyboard;
|
|
public bool DevToolsWantCaptureKeyboard => DevToolsKeyboard;
|
|
}
|
|
|
|
private sealed class InputSource : ICameraFrameInputSource
|
|
{
|
|
public bool IsAvailable { get; set; } = true;
|
|
public FlyCameraInput Fly { get; set; }
|
|
public ChaseCameraAdjustmentInput Chase { get; set; }
|
|
public int FlyCaptures { get; private set; }
|
|
public FlyCameraInput CaptureFly()
|
|
{
|
|
FlyCaptures++;
|
|
return Fly;
|
|
}
|
|
public ChaseCameraAdjustmentInput CaptureChaseAdjustment() => Chase;
|
|
}
|
|
|
|
private sealed class ChaseSource(
|
|
ChaseCamera? legacy,
|
|
RetailChaseCamera? retail) : IChaseCameraSource
|
|
{
|
|
public ChaseCamera? Legacy => legacy;
|
|
public RetailChaseCamera? Retail => retail;
|
|
}
|
|
|
|
private sealed class StillMovementInput : IMovementInputSource
|
|
{
|
|
public MovementInput Capture() => default;
|
|
}
|
|
|
|
private sealed class PlayerRuntime(
|
|
PlayerMovementController? controller,
|
|
List<string> calls) : ILocalPlayerFrameRuntime
|
|
{
|
|
public bool CanPresentPlayer { get; set; } = controller is not null;
|
|
public PlayerMovementController? Controller => controller;
|
|
public uint ResolveLocalEntityId() => 7u;
|
|
public void HandleTargeting() { }
|
|
public bool IsHidden => false;
|
|
public RetailObjectClockDisposition ObjectClockDisposition =>
|
|
RetailObjectClockDisposition.Advance;
|
|
public void Project(
|
|
PlayerMovementController owner,
|
|
MovementResult movement,
|
|
bool hidden) => calls.Add("project");
|
|
public void SendPreNetwork(
|
|
PlayerMovementController owner,
|
|
MovementResult movement,
|
|
bool hidden) { }
|
|
public void SendPostNetwork(PlayerMovementController owner, bool hidden) { }
|
|
}
|
|
|
|
private sealed class Reconciler(List<string> calls)
|
|
: ILiveSpatialReconcilePhase
|
|
{
|
|
public void Reconcile() => calls.Add("reconcile");
|
|
}
|
|
|
|
private sealed class CombatTargetSource : ICombatCameraTargetSource
|
|
{
|
|
public Vector3? GetTrackedTargetPoint() => null;
|
|
}
|
|
}
|