private void _updateChunk() { threadLocked = true; while (modifications.Count > 0) { BlockMod m = modifications.Dequeue(); Vector3 pos = m.position -= position; Debug.Log(m.position); blockMap[(int)pos.x, (int)pos.y, (int)pos.z] = m.id; } ClearMeshData(); for (int x = 0; x < chunkSize; x++) { for (int y = 0; y < chunkSize; y++) { for (int z = 0; z < chunkSize; z++) { if (world.blockType[blockMap[x, y, z]].isSolid) { UpdateMeshData(new Vector3(x, y, z)); } } } } lock (world.chunksToDraw) { world.chunksToDraw.Enqueue(this); } threadLocked = false; }
void ApplyModifications() { applyingModifications = true; while (modifications.Count > 0) { Queue <BlockMod> queue = modifications.Dequeue(); Debug.Log(queue.Count); while (queue.Count > 0) { BlockMod b = queue.Dequeue(); ChunkCoord c = GetChunkCoordFromVector3(b.position); Debug.Log(chunks); if (chunks[c.x, c.y, c.z] == null) { chunks[c.x, c.y, c.z] = new Chunk(c, world, true); activeChunks.Add(c); } chunks[c.x, c.y, c.z].modifications.Enqueue(b); if (!chunksToUpdate.Contains(chunks[c.x, c.y, c.z])) { chunksToUpdate.Add(chunks[c.x, c.y, c.z]); } } } applyingModifications = false; }