示例#1
0
        public void Enqueue(ChunkBlocks blocks)
        {
            if (queue.Contains(blocks.X, blocks.Y, blocks.Z))
            {
                return;
            }

            var work = new WorkItem()
            {
                Blocks = blocks
            };

            queue.Set(blocks.X, blocks.Y, blocks.Z, work);
        }
示例#2
0
        private static ChunkView Visibility(ChunkBlocks blocks)
        {
            var iterator   = blocks.GetIterator();
            var directions = System.Enum.GetValues(typeof(VoxelFace));
            var visibility = new ChunkView(blocks.Length, blocks.Height, blocks.Depth);

            foreach (var coord in iterator)
            {
                var type = blocks.Blocks[coord.x, coord.y, coord.z];
                if (!type.isVisible)
                {
                    visibility.Blocks[coord.x, coord.y, coord.z] = true;
                    continue;
                }
                visibility.Blocks[coord.x, coord.y, coord.z] = true;

                foreach (int face in directions)
                {
                    var neighbour = coord + Voxel.Direction((VoxelFace)face);
                    if (blocks.TryGet(ref neighbour, out BlockType neighbourType) && neighbourType.IsObscure())
                    {
                        visibility.Faces[coord.x, coord.y, coord.z, face] = false;
                    }