fix(streaming): commit EnvCell landblocks atomically (#214)

Carry one complete cell payload with each streaming completion and publish visibility, physics, and render state on the render thread. Remove the obsolete post-readiness login reload that triggered a duplicate dungeon build.

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
Erik 2026-07-13 18:45:24 +02:00
parent 85980fe13f
commit b0c175afc0
26 changed files with 973 additions and 617 deletions

View file

@ -263,6 +263,32 @@ public sealed class CellVisibility
_cellLookup[cell.CellId] = cell;
}
/// <summary>
/// Atomically replaces one landblock's complete portal-cell set on the
/// render thread. Streaming workers build the input privately; no partially
/// hydrated landblock is ever visible to the per-frame flood.
/// </summary>
/// <param name="landblockId">Full landblock id, e.g. 0xA9B4FFFF.</param>
public void CommitLandblock(uint landblockId, IReadOnlyList<LoadedCell> cells)
{
uint prefix = landblockId >> 16;
if (cells.Any(cell => (cell.CellId >> 16) != prefix))
throw new ArgumentException(
"A visibility cell belongs to a different landblock.",
nameof(cells));
if (_cellsByLandblock.TryGetValue(prefix, out var previous))
{
foreach (var cell in previous)
_cellLookup.Remove(cell.CellId);
}
var committed = new List<LoadedCell>(cells);
_cellsByLandblock[prefix] = committed;
foreach (var cell in committed)
_cellLookup[cell.CellId] = cell;
}
/// <summary>
/// Phase A8 (2026-05-28): enumerates the loaded cells that belong to a
/// landblock prefix. Used by <c>GameWindow.ApplyLoadedTerrainLocked</c> when