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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user