示例#1
0
        //  Remove cell for voxels specified be min/max corner. Used after explosion when we want to remove a lot of voxels/cell from cache.
        //  This is efficient method, because it doesn't invalidate cache after every voxel change.
        //  Method knows that adjacent cells need to be removed too (because of MCA), so it invalidates them too.
        public static void RemoveCellForVoxels(MyVoxelMap voxelMap, MyMwcVector3Int minVoxel, MyMwcVector3Int maxVoxel)
        {
            //  Calculate voxel for boundary things...
            MyMwcVector3Int maxCornerExt = new MyMwcVector3Int(maxVoxel.X + 1, maxVoxel.Y + 1, maxVoxel.Z + 1);
            if (maxCornerExt.X > voxelMap.SizeMinusOne.X) maxCornerExt.X = voxelMap.SizeMinusOne.X;
            if (maxCornerExt.Y > voxelMap.SizeMinusOne.Y) maxCornerExt.Y = voxelMap.SizeMinusOne.Y;
            if (maxCornerExt.Z > voxelMap.SizeMinusOne.Z) maxCornerExt.Z = voxelMap.SizeMinusOne.Z;

            //  Min/max cell
            MyMwcVector3Int minCell = voxelMap.GetDataCellCoordinate(ref minVoxel);
            MyMwcVector3Int maxCell = voxelMap.GetDataCellCoordinate(ref maxCornerExt);

            //  Invalidate cells
            MyMwcVector3Int tempCellCoord;
            for (tempCellCoord.X = minCell.X; tempCellCoord.X <= maxCell.X; tempCellCoord.X++)
            {
                for (tempCellCoord.Y = minCell.Y; tempCellCoord.Y <= maxCell.Y; tempCellCoord.Y++)
                {
                    for (tempCellCoord.Z = minCell.Z; tempCellCoord.Z <= maxCell.Z; tempCellCoord.Z++)
                    {
                        RemoveCell(voxelMap.VoxelMapId, ref tempCellCoord);
                    }
                }
            }
        }