From a149de885cb17b87503ae1c106416590317534f2 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sun, 1 Sep 2024 19:41:22 -0400 Subject: [PATCH] Parallelize chunk generation using fan-out pattern. --- Sources/Voxelotl/World.swift | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Sources/Voxelotl/World.swift b/Sources/Voxelotl/World.swift index 33984d9..11d81b4 100644 --- a/Sources/Voxelotl/World.swift +++ b/Sources/Voxelotl/World.swift @@ -62,15 +62,31 @@ public class World { func generate(width: Int, height: Int, depth: Int, seed: UInt64) { self._generator.reset(seed: seed) let orig = SIMD3(width, height, depth) / 2 + + var localChunks: [SIMD3: Chunk] = [:] + let localChunksLock = NSLock() + let queue = OperationQueue() + queue.qualityOfService = .userInitiated for z in 0..