//Initial generation public void Process() { while (runThread) { preparation.Wait(); if (Length < maxSize) { Position pos = localCenters[Length]; pos = loadMarker.ToGlobal(pos) / 8; Tuple <int, int, int> key = new Tuple <int, int, int> (pos.x, pos.y, pos.z); OctreeNode node = null; if (!leafOctants.ContainsKey(key) || leafOctants.TryGetValue(key, out node)) { if (node == null) { node = terra.TraverseOctree(pos.x, pos.y, pos.z, 0); } if (node != null && node.chunk == null) { leafOctants.TryAdd(key, node); queue.Enqueue(key); generation.Post(); } } preparation.Post(); Length++; } } }
public Chunk RequestChunk(int x, int y, int z) { OctreeNode node = terra.TraverseOctree(x, y, z, 0); if (node != null) { return(node.chunk); } return(null); }