//And this actually creates the voxel and then begins the aero properties determination private void CreateVoxel() { lock (this) //lock this object to prevent race with main thread { try { //Actually voxelize it _voxel = new VehicleVoxel(_vehiclePartList, _currentGeoModules, _voxelCount); if (_vehicleCrossSection.Length < _voxel.MaxArrayLength) _vehicleCrossSection = _voxel.EmptyCrossSectionArray; _voxelLowerRightCorner = _voxel.LocalLowerRightCorner; _voxelElementSize = _voxel.ElementSize; CalculateVesselAeroProperties(); _calculationCompleted = true; // voxelizing = false; } catch (Exception e) { ThreadSafeDebugLogger.Instance.RegisterException(e); } finally { //Always, when we finish up, if we're in flight, cleanup the voxel if (HighLogic.LoadedSceneIsFlight && _voxel != null) { _voxel.CleanupVoxel(); _voxel = null; } //And unset the flag so that the main thread can queue it again voxelizing = false; } } }
public void ForceCleanup() { if (_voxel != null) { _voxel.CleanupVoxel(); _voxel = null; } _vehicleCrossSection = null; _ductedAreaAdjustment = null; _currentAeroModules = null; _newAeroModules = null; _currentUnusedAeroModules = null; _newUnusedAeroModules = null; _currentAeroSections = null; _newAeroSections = null; _legacyWingModels = null; _vehiclePartList = null; activeAdjusters = null; }