refactor: store-owned diff snapshot and drop dead ChunkJob.ExistingChunk

TryGetDiff now returns an independent copy so callers can safely retain the
reference; removes the defensive copy from ChunkStreamer.DispatchLoad.
ChunkJob.ExistingChunk was never populated (DispatchRemesh uses closures
instead), so the field is removed along with its misleading record-level
comment.
This commit is contained in:
2026-06-01 13:31:05 +02:00
parent 6b148362c0
commit 34f923cbca
3 changed files with 9 additions and 13 deletions

View File

@@ -299,15 +299,9 @@ public sealed class ChunkStreamer : IDisposable
private void DispatchLoad(Vector3i pos)
{
NeighborSnapshots neighbors = this.SnapshotNeighbors(pos);
IReadOnlyDictionary<int, ushort>? diff = null;
if (this._world.ModificationStore.TryGetDiff(pos, out var d) && d != null)
{
// Copy: TryGetDiff returns the live internal dictionary, which the
// main thread may mutate via World.SetBlock while the worker iterates.
diff = new Dictionary<int, ushort>(d);
}
this._world.ModificationStore.TryGetDiff(pos, out IReadOnlyDictionary<int, ushort>? diff);
var job = new ChunkJob(pos, ExistingChunk: null, neighbors, diff);
var job = new ChunkJob(pos, neighbors, diff);
this._inFlight++;
IChunkMesher mesher = this._mesher;