refactor(streaming): extract landblock physics publisher

Move streamed terrain/cell/building and static collision publication behind a focused update-thread owner. Preserve retail publication order while making replacement and retirement exact by logical landblock ownership, including current-cell rebasing and adjacent-seam isolation.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-21 21:13:22 +02:00
parent acb6b34d01
commit 3613d393e6
7 changed files with 1538 additions and 546 deletions

View file

@ -124,6 +124,7 @@ public sealed class PhysicsEngine
ShadowObjects.DeregisterStaticOwnersForLandblock(landblockId);
ShadowObjects.RemoveLandblock(landblockId);
DataCache?.RemoveCellsForLandblock(landblockId); // D8: rebase cell BSP transforms on next apply
DataCache?.RemoveBuildingsForLandblock(landblockId);
// #145: if the player's current cell belonged to the landblock being removed (a teleport
// drops the stale source center via OnLivePositionUpdated), clear it. Otherwise CurrCell

View file

@ -58,6 +58,11 @@ public sealed class CellGraph
public void RemoveLandblock(uint landblockPrefix)
{
uint lb = landblockPrefix & 0xFFFF0000u;
if (CurrCell is { } current
&& (current.Id & 0xFFFF0000u) == lb)
{
CurrCell = null;
}
_terrain.TryRemove(lb, out _);
foreach (var id in new List<uint>(_envCells.Keys))
if ((id & 0xFFFF0000u) == lb) _envCells.TryRemove(id, out _);
@ -70,6 +75,12 @@ public sealed class CellGraph
public void RemoveEnvCellsForLandblock(uint landblockPrefix)
{
uint lb = landblockPrefix & 0xFFFF0000u;
if (CurrCell is { } current
&& (current.Id & 0xFFFF0000u) == lb
&& (current.Id & 0xFFFFu) >= 0x0100u)
{
CurrCell = null;
}
foreach (var id in new List<uint>(_envCells.Keys))
if ((id & 0xFFFF0000u) == lb) _envCells.TryRemove(id, out _);
}