fn generateChunks() !void {
var tsa = std.heap.ThreadSafeAllocator{ .child_allocator = allocator };
const thread_alloc = tsa.allocator();
var pool = std.Io.Threaded.init(thread_alloc);
defer pool.deinit();
const io = pool.io();
var g: std.Io.Group = .init;
var y
loop through y
var x
loop through x
var z
loop through z
const chunk_pos = int3.new(@intCast(x), @intCast(y), @intCast(z));
const chunk = getChunk(chunk_pos).?;
try chunk.init(chunk_pos, allocator);
try MeshManager.markForMeshing(chunk.position);
}
}
}
try workOnChunks(io, &g, Chunk.Stage.terrain);
try workOnChunks(io, &g, Chunk.Stage.decoration);
}
fn workOnChunks(io: std.Io, g: *std.Io.Group, stage: Chunk.Stage) !void {
var y
loop through y
var x
loop through x
var z
loop through z
const chunk_pos = int3.new(x, y, z);
const c = getChunk(chunk_pos).?;
try g.concurrent(io, ChunkGenerator.generateChunk, .{ chunk, stage });
}
}
g.wait(io);
}
}