Пример #1
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;
                    }