Example #1
0
        private static void InvalidateNeighborSlice(ChunkData Chunks, GlobalChunkCoordinate ChunkCoordinate,
                                                    Point3 NeighborOffset, int Y)
        {
            var neighborCoordinate = new GlobalChunkCoordinate(
                ChunkCoordinate.X + NeighborOffset.X,
                ChunkCoordinate.Y + NeighborOffset.Y,
                ChunkCoordinate.Z + NeighborOffset.Z);

            if (Chunks.CheckBounds(neighborCoordinate))
            {
                var chunk = Chunks.GetChunk(neighborCoordinate);
                chunk.InvalidateSlice(Y);
            }
        }
Example #2
0
        public void GetChunksIntersecting(BoundingBox box, HashSet <VoxelChunk> chunks)
        {
            chunks.Clear();
            var minChunk = GlobalVoxelCoordinate.FromVector3(box.Min).GetGlobalChunkCoordinate();
            var maxChunk = GlobalVoxelCoordinate.FromVector3(box.Max).GetGlobalChunkCoordinate();

            for (var x = minChunk.X; x <= maxChunk.X; ++x)
            {
                for (var y = minChunk.Y; y <= maxChunk.Y; ++y)
                {
                    for (var z = minChunk.Z; z <= maxChunk.Z; ++z)
                    {
                        var coord = new GlobalChunkCoordinate(x, y, z);
                        if (ChunkData.CheckBounds(coord))
                        {
                            chunks.Add(ChunkData.GetChunk(coord));
                        }
                    }
                }
            }
        }
Example #3
0
        public void GetChunksIntersecting(BoundingFrustum Frustum, HashSet <VoxelChunk> chunks)
        {
            chunks.Clear();
            var frustumBox = MathFunctions.GetBoundingBox(Frustum.GetCorners());
            var minChunk   = GlobalVoxelCoordinate.FromVector3(frustumBox.Min).GetGlobalChunkCoordinate();
            var maxChunk   = GlobalVoxelCoordinate.FromVector3(frustumBox.Max).GetGlobalChunkCoordinate();

            for (var x = minChunk.X; x <= maxChunk.X; ++x)
            {
                for (var y = minChunk.Y; y <= maxChunk.Y; ++y)
                {
                    for (var z = minChunk.Z; z <= maxChunk.Z; ++z)
                    {
                        var chunkCoord = new GlobalChunkCoordinate(x, y, z);
                        var min        = new GlobalVoxelCoordinate(chunkCoord, new LocalVoxelCoordinate(0, 0, 0));
                        var box        = new BoundingBox(min.ToVector3(), min.ToVector3() + new Vector3(VoxelConstants.ChunkSizeX, VoxelConstants.ChunkSizeY, VoxelConstants.ChunkSizeZ));
                        if (ChunkData.CheckBounds(chunkCoord) && Frustum.Contains(box) != ContainmentType.Disjoint)
                        {
                            chunks.Add(ChunkData.GetChunk(chunkCoord));
                        }
                    }
                }
            }
        }