public void Generate(Object empty) { ArrayPool <Position> pool = ArrayPool <Position> .Create(Constants.CHUNK_SIZE3D * 6 * 4, 1); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int x = 0; x < CHUNKS_TO_GENERATE; x++) { for (int y = 0; y < CHUNKS_TO_GENERATE; y++) { for (int z = 0; z < CHUNKS_TO_GENERATE; z++) { Chunk chunk = chunkFiller.GenerateChunk(x << Constants.CHUNK_EXPONENT, y << Constants.CHUNK_EXPONENT, z << Constants.CHUNK_EXPONENT, weltschmerz); if (!chunk.IsSurface) { chunk.x = (uint)x << Constants.CHUNK_EXPONENT; chunk.y = (uint)y << Constants.CHUNK_EXPONENT; chunk.z = (uint)z << Constants.CHUNK_EXPONENT; } if (!chunk.IsEmpty) { mesher.MeshChunk(chunk, pool); } } } } stopwatch.Stop(); Godot.GD.Print(CHUNKS_TO_GENERATE * CHUNKS_TO_GENERATE * CHUNKS_TO_GENERATE + " chunks generated in " + stopwatch.ElapsedMilliseconds); }
//Loads chunks private void LoadArea(Tuple <int, int, int> pos, OctreeNode node, ArrayPool <Position> pool) { Chunk chunk; if (pos.Item2 << Constants.CHUNK_EXPONENT > weltschmerz.GetConfig().elevation.max_elevation) { chunk = new Chunk(); chunk.IsEmpty = true; chunk.x = (uint)pos.Item1 << Constants.CHUNK_EXPONENT; chunk.y = (uint)pos.Item2 << Constants.CHUNK_EXPONENT; chunk.z = (uint)pos.Item3 << Constants.CHUNK_EXPONENT; } else { chunk = chunkFiller.GenerateChunk(pos.Item1 << Constants.CHUNK_EXPONENT, pos.Item2 << Constants.CHUNK_EXPONENT, pos.Item3 << Constants.CHUNK_EXPONENT, weltschmerz); if (!chunk.IsSurface) { chunk.x = (uint)pos.Item1 << Constants.CHUNK_EXPONENT; chunk.y = (uint)pos.Item2 << Constants.CHUNK_EXPONENT; chunk.z = (uint)pos.Item3 << Constants.CHUNK_EXPONENT; } } if (!chunk.IsEmpty) { mesher.MeshChunk(chunk, pool); chunksPlaced++; } node.chunk = chunk; }