refactor(app): key live projections by runtime identity

Move materialized live-object sidecars and presentation worksets to exact RuntimeEntityKey ownership. Runtime remains the only GUID/incarnation/local-ID authority while hydration, animation, effects, lights, equipped children, renderer resources, visibility, liveness, and teardown resolve exact projection identities. Preserve synchronous callbacks, local-ID allocation order, and current rendering behavior.
This commit is contained in:
Erik 2026-07-25 21:50:58 +02:00
parent e18df84437
commit 420e5eea70
73 changed files with 2939 additions and 1715 deletions

View file

@ -243,18 +243,18 @@ public sealed class ProjectileControllerTests
Assert.True(fixture.Controller.TryBind(record, ProjectileSetup(), 1.0, 1, 1));
Assert.True(record.PhysicsBody!.InWorld);
Assert.True(record.PhysicsBody.IsActive);
Assert.Single(fixture.Live.SpatialProjectileRuntimes);
Assert.Equal(1, fixture.Live.SpatialProjectileRuntimeCount);
fixture.Spatial.RemoveLandblock(0x0101FFFFu);
Assert.False(record.IsSpatiallyVisible);
Assert.Empty(fixture.Live.SpatialProjectileRuntimes);
Assert.Equal(0, fixture.Live.SpatialProjectileRuntimeCount);
Assert.False(record.PhysicsBody.InWorld);
Assert.False(record.PhysicsBody.IsActive);
Assert.Equal(0, fixture.Engine.ShadowObjects.TotalRegistered);
fixture.Spatial.AddLandblock(EmptyLandblock(0x0101FFFFu));
Assert.Single(fixture.Live.SpatialProjectileRuntimes);
Assert.Equal(1, fixture.Live.SpatialProjectileRuntimeCount);
Assert.True(record.PhysicsBody.InWorld);
Assert.True(record.PhysicsBody.IsActive);
Assert.Equal(1, fixture.Engine.ShadowObjects.TotalRegistered);
@ -545,7 +545,8 @@ public sealed class ProjectileControllerTests
Assert.Same(runtime, record.ProjectileRuntime);
Assert.Same(body, record.PhysicsBody);
Assert.True(body.IsActive); // State preserves an already-active body.
Assert.Same(record.WorldEntity, fixture.Live.MaterializedWorldEntities[Guid]);
Assert.True(fixture.Live.TryGetWorldEntity(Guid, out WorldEntity entity));
Assert.Same(record.WorldEntity, entity);
Assert.Equal(1, fixture.Resources.Registers);
}
@ -1501,12 +1502,8 @@ public sealed class ProjectileControllerTests
angularVelocity ?? Vector3.Zero,
friction,
elasticity);
LiveEntityRegistrationResult registration = Live.RegisterLiveEntity(spawn);
Assert.NotNull(registration.Record);
registration.Record!.HasPartArray = true;
WorldEntity? entity = Live.MaterializeLiveEntity(
Guid,
cellId,
LiveEntityRecord record = Live.RegisterAndMaterializeProjection(
spawn,
localId => new WorldEntity
{
Id = localId,
@ -1518,10 +1515,11 @@ public sealed class ProjectileControllerTests
? new[] { new MeshRef(0x01000001u, Matrix4x4.Identity) }
: Array.Empty<MeshRef>(),
ParentCellId = cellId,
});
Assert.NotNull(entity);
},
initializeProjection: exact => exact.HasPartArray = true);
WorldEntity entity = Assert.IsType<WorldEntity>(record.WorldEntity);
Poses.PublishMeshRefs(entity);
return registration.Record!;
return record;
}
}