feat(runtime): seal dormant SetPosition evaluations
This commit is contained in:
parent
22651c823d
commit
99f867f053
16 changed files with 2298 additions and 62 deletions
|
|
@ -78,6 +78,7 @@ public sealed class ShadowObjectRegistry
|
|||
_collisionWorld.Current.ShadowOwnerFreeSlots;
|
||||
private readonly HashSet<uint> _prefixScratch = new();
|
||||
private readonly List<uint> _removedPrefixScratch = new();
|
||||
private ulong _mutationRevision;
|
||||
internal event Action<uint, ulong>? OwnerMutated;
|
||||
internal event Action<uint, uint>? OwnerPrefixMembershipChanged;
|
||||
|
||||
|
|
@ -101,6 +102,7 @@ public sealed class ShadowObjectRegistry
|
|||
"A populated shadow registry cannot change collision roots.");
|
||||
}
|
||||
_collisionWorld = collisionWorld;
|
||||
AdvanceMutationRevision();
|
||||
}
|
||||
|
||||
internal sealed record RegistrationRecord(
|
||||
|
|
@ -123,8 +125,20 @@ public sealed class ShadowObjectRegistry
|
|||
? version
|
||||
: 0UL;
|
||||
|
||||
/// <summary>
|
||||
/// Monotonic authority for every logical mutation of the active shadow
|
||||
/// collision world. SetPosition evaluation receipts seal this value so a
|
||||
/// later owner insert, removal, move, state change, suspension, reflood,
|
||||
/// or cell-row replacement cannot be committed against a different world.
|
||||
/// </summary>
|
||||
internal ulong MutationRevision => _mutationRevision;
|
||||
|
||||
private void AdvanceMutationRevision() =>
|
||||
_mutationRevision = checked(_mutationRevision + 1UL);
|
||||
|
||||
private void BumpOwnerVersion(uint entityId)
|
||||
{
|
||||
AdvanceMutationRevision();
|
||||
ulong version = checked(GetOwnerVersion(entityId) + 1UL);
|
||||
_ownerVersions[entityId] = version;
|
||||
RefreshOwnerPrefixIndex(entityId);
|
||||
|
|
@ -1308,6 +1322,7 @@ public sealed class ShadowObjectRegistry
|
|||
DeregisterCore(entityId, publishMutation: false);
|
||||
RemoveOwnerPrefixMembership(entityId);
|
||||
_ownerVersions.Remove(entityId);
|
||||
AdvanceMutationRevision();
|
||||
return;
|
||||
}
|
||||
if (!_entityToCells.TryGetValue(entityId, out List<uint>? cells))
|
||||
|
|
@ -1877,6 +1892,13 @@ public sealed class ShadowObjectRegistry
|
|||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
bool mutated = _cells.Count != 0
|
||||
|| _entityToCells.Count != 0
|
||||
|| _entityReg.Count != 0
|
||||
|| _suspendedEntities.Count != 0
|
||||
|| _suspendedEntityCells.Count != 0;
|
||||
if (mutated)
|
||||
AdvanceMutationRevision();
|
||||
_cells.Clear();
|
||||
_entityToCells.Clear();
|
||||
_suspendedEntities.Clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue