Exemplo n.º 1
0
        private void FillOutOfBounds(MyStorageData target, MyStorageDataTypeEnum type, ref Vector3I woffset, int lodIndex, Vector3I minInLod, Vector3I maxInLod)
        {
            var value = MyVoxelConstants.DefaultValue(type);
            var size = new Vector3I((1 << (m_treeHeight + LeafLodCount - lodIndex)) - 1);

            var offset = woffset - minInLod;

            var req = new BoundingBoxI(minInLod, maxInLod);
            var tree = new BoundingBoxI(Vector3I.Zero, size);

            if (req.Intersects(ref tree) != true)
            {
                target.BlockFill(type, offset + minInLod, offset + maxInLod, value);
                return;
            }

            // Left
            if (minInLod.X < 0)
            {
                var min = minInLod;
                var max = maxInLod;

                max.X = -1;
                minInLod.X = 0;

                target.BlockFill(type, min + offset, max + offset, value);
            }

            // Right
            if (maxInLod.X > size.X)
            {
                var min = minInLod;
                var max = maxInLod;

                min.X = size.X+1;
                minInLod.X = size.X;

                target.BlockFill(type, min + offset, max + offset, value);
            }

            // Top
            if (minInLod.Y < 0)
            {
                var min = minInLod;
                var max = maxInLod;

                max.Y = -1;
                minInLod.Y = 0;

                target.BlockFill(type, min + offset, max + offset, value);
            }

            // Bottom
            if (maxInLod.Y > size.Y)
            {
                var min = minInLod;
                var max = maxInLod;

                min.Y = size.Y + 1;
                minInLod.Y = size.Y;

                target.BlockFill(type, min + offset, max + offset, value);
            }

            // Back
            if (minInLod.Y < 0)
            {
                var min = minInLod;
                var max = maxInLod;

                max.Y = -1;
                minInLod.Y = 0;

                target.BlockFill(type, min + offset, max + offset, value);
            }

            // Front
            if (maxInLod.Y > size.Y)
            {
                var min = minInLod;
                var max = maxInLod;

                min.Y = size.Y + 1;
                minInLod.Y = size.Y;

                target.BlockFill(type, min + offset, max + offset, value);
            }
        }