// 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.GetVoxelRenderCellCoordinate(ref minVoxel); MyMwcVector3Int maxCell = voxelMap.GetVoxelRenderCellCoordinate(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, MyLodTypeEnum.LOD0); RemoveCell(voxelMap.VoxelMapId, ref tempCellCoord, MyLodTypeEnum.LOD1); } } } }
// 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, Vector3I minVoxel, Vector3I maxVoxel) { // Calculate voxel for boundary things... minVoxel -= MyVoxelPrecalc.InvalidatedRangeInflate; maxVoxel += MyVoxelPrecalc.InvalidatedRangeInflate; if (maxVoxel.X > voxelMap.SizeMinusOne.X) { maxVoxel.X = voxelMap.SizeMinusOne.X; } if (maxVoxel.Y > voxelMap.SizeMinusOne.Y) { maxVoxel.Y = voxelMap.SizeMinusOne.Y; } if (maxVoxel.Z > voxelMap.SizeMinusOne.Z) { maxVoxel.Z = voxelMap.SizeMinusOne.Z; } // Min/max cell Vector3I minCell = voxelMap.GetVoxelRenderCellCoordinate(ref minVoxel); Vector3I maxCell = voxelMap.GetVoxelRenderCellCoordinate(ref maxVoxel); // Invalidate cells Vector3I 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, ref tempCellCoord, MyLodTypeEnum.LOD0); RemoveCell(voxelMap, ref tempCellCoord, MyLodTypeEnum.LOD1); } } } }