refactor(runtime): own per-session physics simulation

Move the sole PhysicsEngine, production cache, collision admissions, canonical bodies and hosts, remote components, ordinary/remote worksets, simulation, cell commits, and shadow synchronization under RuntimeEntityObjectLifetime. Keep App as the prepared-asset, animation-input, and render-projection adapter while preserving the named-retail update and collision order.

Add exact-incarnation, object-clock, callback-reentrancy, GUID-reuse, two-runtime isolation, source ownership, collision publication, and graphical projection coverage. Release build and the complete 8,588-test solution pass.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-26 13:39:57 +02:00
parent 0dc3bfdeff
commit 7e6033d0ad
39 changed files with 3685 additions and 1722 deletions

View file

@ -101,7 +101,7 @@ public sealed class RemoteTeleportControllerTests
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
})!;
var remote = new AcDream.App.Physics.RemoteMotion();
var remote = new AcDream.Runtime.Physics.RemoteMotion();
remote.Body.SnapToCell(
sourceCell,
entity.Position,
@ -242,7 +242,7 @@ public sealed class RemoteTeleportControllerTests
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
})!;
var remote = new AcDream.App.Physics.RemoteMotion();
var remote = new AcDream.Runtime.Physics.RemoteMotion();
remote.Body.SnapToCell(sourceCell, entity.Position, entity.Position);
live.SetRemoteMotionRuntime(guid, remote);
var engine = new PhysicsEngine { DataCache = new PhysicsDataCache() };
@ -333,7 +333,7 @@ public sealed class RemoteTeleportControllerTests
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
})!;
var remote = new AcDream.App.Physics.RemoteMotion();
var remote = new AcDream.Runtime.Physics.RemoteMotion();
remote.Body.SnapToCell(sourceCell, sourcePosition, sourcePosition);
remote.Body.TransientState = TransientStateFlags.Contact
| TransientStateFlags.OnWalkable;
@ -774,13 +774,13 @@ public sealed class RemoteTeleportControllerTests
Assert.Throws<InvalidOperationException>(() =>
fixture.Live.SetRemoteMotionRuntime(
RollbackFixture.Guid,
new AcDream.App.Physics.RemoteMotion()));
new AcDream.Runtime.Physics.RemoteMotion()));
Assert.Throws<InvalidOperationException>(() =>
fixture.Live.SetRemoteMotionRuntime(
RollbackFixture.Guid,
new BodyOnlyRemote(fixture.Remote.Body)));
var replacement = new AcDream.App.Physics.RemoteMotion(fixture.Remote.Body);
var replacement = new AcDream.Runtime.Physics.RemoteMotion(fixture.Remote.Body);
fixture.Live.SetRemoteMotionRuntime(RollbackFixture.Guid, replacement);
fixture.Spatial.AddLandblock(EmptyLandblock(RollbackFixture.DestinationLandblock));
@ -811,7 +811,7 @@ public sealed class RemoteTeleportControllerTests
Assert.Throws<InvalidOperationException>(() =>
fixture.Live.SetRemoteMotionRuntime(
RollbackFixture.Guid,
new AcDream.App.Physics.RemoteMotion()));
new AcDream.Runtime.Physics.RemoteMotion()));
Assert.Throws<InvalidOperationException>(() =>
fixture.Live.SetRemoteMotionRuntime(
RollbackFixture.Guid,
@ -1115,7 +1115,7 @@ public sealed class RemoteTeleportControllerTests
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
})!;
var remote = new AcDream.App.Physics.RemoteMotion();
var remote = new AcDream.Runtime.Physics.RemoteMotion();
remote.Body.SnapToCell(sourceCell, entity.Position, entity.Position);
live.SetRemoteMotionRuntime(guid, remote);
Assert.True(live.TryGetRecord(guid, out owner));
@ -1193,7 +1193,7 @@ public sealed class RemoteTeleportControllerTests
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
})!;
var remote = new AcDream.App.Physics.RemoteMotion();
var remote = new AcDream.Runtime.Physics.RemoteMotion();
remote.Body.SnapToCell(sourceCell, entity.Position, entity.Position);
live.SetRemoteMotionRuntime(guid, remote);
return new LoadedRemoteFixture(
@ -1238,7 +1238,7 @@ public sealed class RemoteTeleportControllerTests
private readonly record struct LoadedRemoteFixture(
LiveEntityRuntime Live,
WorldEntity Entity,
AcDream.App.Physics.RemoteMotion Remote,
AcDream.Runtime.Physics.RemoteMotion Remote,
PhysicsEngine Engine);
private static void AddDestination(PhysicsEngine engine) =>
@ -1397,7 +1397,7 @@ public sealed class RemoteTeleportControllerTests
Rotation = Quaternion.Identity,
MeshRefs = Array.Empty<MeshRef>(),
})!;
Remote = new AcDream.App.Physics.RemoteMotion();
Remote = new AcDream.Runtime.Physics.RemoteMotion();
Remote.Body.SnapToCell(
celllessSource ? 0u : SourceCell,
SourcePosition,
@ -1479,7 +1479,7 @@ public sealed class RemoteTeleportControllerTests
internal GpuWorldState Spatial { get; } = new();
internal LiveEntityRuntime Live { get; }
internal WorldEntity Entity { get; }
internal AcDream.App.Physics.RemoteMotion Remote { get; }
internal AcDream.Runtime.Physics.RemoteMotion Remote { get; }
internal PhysicsEngine Engine { get; } = new() { DataCache = new PhysicsDataCache() };
internal RemoteTeleportController Controller { get; }
internal LiveEntityPresentationController Presentation { get; }