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>
214 lines
7.5 KiB
C#
214 lines
7.5 KiB
C#
using System.Numerics;
|
|
using AcDream.Core.Physics;
|
|
using AcDream.Runtime.Gameplay;
|
|
|
|
namespace AcDream.Runtime.Tests.Gameplay;
|
|
|
|
public sealed class PlayerOutboundPositionTests
|
|
{
|
|
private static readonly Plane GroundPlane =
|
|
new(Vector3.UnitZ, 0f);
|
|
|
|
[Fact]
|
|
public void CrossLandblockWorldFrame_SendsCarriedCellLocalPosition()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
|
|
// The render origin remains A9B1, so a point 22.56 m into A9B2 is
|
|
// represented at world Y=214.56. The wire frame must remain the
|
|
// carried A9B2-local 22.56, never the render-space 214.56.
|
|
controller.SeedPlacementForTest(
|
|
new Vector3(116.07f, 214.56f, 83.76f),
|
|
0xA9B20021u,
|
|
new Vector3(116.07f, 22.56f, 83.76f));
|
|
|
|
Assert.True(controller.TryGetOutboundPosition(out Position outbound));
|
|
Assert.Equal(0xA9B20021u, outbound.ObjCellId);
|
|
Assert.Equal(
|
|
new Vector3(116.07f, 22.56f, 83.76f),
|
|
outbound.Frame.Origin);
|
|
Assert.NotEqual(controller.Position, outbound.Frame.Origin);
|
|
}
|
|
|
|
[Fact]
|
|
public void UnplacedBody_DoesNotProduceWirePosition()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
|
|
Assert.False(controller.TryGetOutboundPosition(out _));
|
|
}
|
|
|
|
[Fact]
|
|
public void OutboundPosition_PreservesCompleteAuthoritativeQuaternion()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
controller.SeedPlacementForTest(
|
|
new Vector3(116.07f, 214.56f, 83.76f),
|
|
0xA9B20021u,
|
|
new Vector3(116.07f, 22.56f, 83.76f));
|
|
Quaternion complete = Quaternion.Normalize(
|
|
Quaternion.CreateFromAxisAngle(Vector3.UnitX, 0.7f)
|
|
* Quaternion.CreateFromAxisAngle(Vector3.UnitY, -0.4f));
|
|
controller.SetBodyOrientation(complete);
|
|
|
|
Assert.True(controller.TryGetOutboundPosition(out Position outbound));
|
|
|
|
Assert.InRange(
|
|
MathF.Abs(Quaternion.Dot(
|
|
complete,
|
|
Quaternion.Normalize(outbound.Frame.Orientation))),
|
|
0.99999f,
|
|
1.00001f);
|
|
}
|
|
|
|
[Fact]
|
|
public void PositionEvent_FirstFrameIsDue()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var current = PositionAt(Quaternion.Identity);
|
|
|
|
Assert.True(controller.ShouldSendPositionEvent(current, GroundPlane, 0f));
|
|
}
|
|
|
|
[Fact]
|
|
public void PositionEvent_StationaryHeadingChangeIsDueAfterRetailInterval()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var sent = PositionAt(Quaternion.Identity);
|
|
var turned = PositionAt(Quaternion.CreateFromAxisAngle(
|
|
Vector3.UnitZ,
|
|
MathF.PI / 2f));
|
|
controller.NotePositionSent(sent, GroundPlane, nowSeconds: 0f);
|
|
|
|
Assert.False(controller.ShouldSendPositionEvent(
|
|
turned,
|
|
GroundPlane,
|
|
PlayerMovementController.HeartbeatInterval));
|
|
Assert.True(controller.ShouldSendPositionEvent(
|
|
turned,
|
|
GroundPlane,
|
|
PlayerMovementController.HeartbeatInterval + 0.01f));
|
|
}
|
|
|
|
[Fact]
|
|
public void PositionEvent_UnchangedCompleteFrameIsNotIdleHeartbeat()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var sent = PositionAt(Quaternion.Identity);
|
|
controller.NotePositionSent(sent, GroundPlane, nowSeconds: 0f);
|
|
|
|
Assert.False(controller.ShouldSendPositionEvent(
|
|
sent,
|
|
GroundPlane,
|
|
PlayerMovementController.HeartbeatInterval + 0.01f));
|
|
}
|
|
|
|
[Fact]
|
|
public void MovementEvent_StampsOnlyTime_NotTheRememberedFrame()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var sent = PositionAt(Quaternion.Identity);
|
|
var turned = PositionAt(Quaternion.CreateFromAxisAngle(
|
|
Vector3.UnitZ,
|
|
MathF.PI / 2f));
|
|
controller.NotePositionSent(sent, GroundPlane, nowSeconds: 0f);
|
|
controller.NoteMovementSent(nowSeconds: 0.9f);
|
|
|
|
Assert.False(controller.ShouldSendPositionEvent(
|
|
turned,
|
|
GroundPlane,
|
|
nowSeconds: 1.1f));
|
|
Assert.True(controller.ShouldSendPositionEvent(
|
|
turned,
|
|
GroundPlane,
|
|
nowSeconds: 1.91f));
|
|
}
|
|
|
|
[Fact]
|
|
public void PositionEvent_CellOrContactPlaneChangeIsDueInsideInterval()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var sent = PositionAt(Quaternion.Identity);
|
|
controller.NotePositionSent(sent, GroundPlane, nowSeconds: 0f);
|
|
|
|
var otherCell = sent with { ObjCellId = 0xA9B20022u };
|
|
var otherPlane = new Plane(Vector3.Normalize(new Vector3(0.01f, 0f, 1f)), 0f);
|
|
|
|
Assert.True(controller.ShouldSendPositionEvent(otherCell, GroundPlane, 0.1f));
|
|
Assert.True(controller.ShouldSendPositionEvent(sent, otherPlane, 0.1f));
|
|
}
|
|
|
|
[Fact]
|
|
public void PositionEvent_QuaternionSignIsStoredFrameDataLikeRetail()
|
|
{
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var sent = PositionAt(Quaternion.Identity);
|
|
var oppositeStoredQuaternion = PositionAt(new Quaternion(0f, 0f, 0f, -1f));
|
|
controller.NotePositionSent(sent, GroundPlane, nowSeconds: 0f);
|
|
|
|
Assert.True(controller.ShouldSendPositionEvent(
|
|
oppositeStoredQuaternion,
|
|
GroundPlane,
|
|
PlayerMovementController.HeartbeatInterval + 0.01f));
|
|
}
|
|
|
|
[Fact]
|
|
public void PositionEvent_RetailEpsilonUsesDifferentOriginAndQuaternionBoundaries()
|
|
{
|
|
const float epsilon = 0.000199999995f;
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var sent = new Position(0xA9B20021u, Vector3.Zero, Quaternion.Identity);
|
|
controller.NotePositionSent(sent, GroundPlane, nowSeconds: 0f);
|
|
|
|
var exactOriginBoundary = sent with
|
|
{
|
|
Frame = sent.Frame with { Origin = new Vector3(epsilon, 0f, 0f) },
|
|
};
|
|
var exactQuaternionBoundary = sent with
|
|
{
|
|
Frame = sent.Frame with
|
|
{
|
|
Orientation = new Quaternion(epsilon, 0f, 0f, 1f),
|
|
},
|
|
};
|
|
float elapsed = PlayerMovementController.HeartbeatInterval + 0.01f;
|
|
|
|
Assert.False(controller.ShouldSendPositionEvent(
|
|
exactOriginBoundary,
|
|
GroundPlane,
|
|
elapsed));
|
|
Assert.True(controller.ShouldSendPositionEvent(
|
|
exactQuaternionBoundary,
|
|
GroundPlane,
|
|
elapsed));
|
|
}
|
|
|
|
[Fact]
|
|
public void PositionEvent_RetailPlaneDistanceBoundaryIsStrict()
|
|
{
|
|
const float epsilon = 0.000199999995f;
|
|
var controller = new PlayerMovementController(new PhysicsEngine());
|
|
var sent = PositionAt(Quaternion.Identity);
|
|
controller.NotePositionSent(sent, GroundPlane, nowSeconds: 0f);
|
|
|
|
var exactNormalBoundary = new Plane(
|
|
new Vector3(epsilon, 0f, 1f),
|
|
0f);
|
|
var exactDistanceBoundary = new Plane(Vector3.UnitZ, epsilon);
|
|
|
|
Assert.False(controller.ShouldSendPositionEvent(
|
|
sent,
|
|
exactNormalBoundary,
|
|
nowSeconds: 0.1f));
|
|
Assert.True(controller.ShouldSendPositionEvent(
|
|
sent,
|
|
exactDistanceBoundary,
|
|
nowSeconds: 0.1f));
|
|
}
|
|
|
|
private static Position PositionAt(Quaternion orientation)
|
|
=> new(
|
|
0xA9B20021u,
|
|
new Vector3(116.07f, 22.56f, 83.76f),
|
|
orientation);
|
|
}
|