feat: make ChunkRenderer thread safe
@@ -99,12 +99,14 @@ public class ChunkRenderer {
runUploadTasks();
+ synchronized (loadedChunkMeshes) {
for (var entry : loadedChunkMeshes.entrySet()) {
var mesh = entry.getValue();
if (shouldRenderChunk(mesh)) {
mesh.render();
}
}
+ }
postRender();
}
@@ -224,7 +226,9 @@ public class ChunkRenderer {
private void initChunk(Chunk chunk) {
long chunkIndex = getChunkIndex(chunk);
+ synchronized (loadedChunkMeshes) {
loadedChunkMeshes.computeIfAbsent(chunkIndex, key -> new ChunkMesh(chunk));
+ }
markChunkDirty(chunkIndex);
}
