internal void ComputeTrajectory() { if (!VesselHasParts)// || AttachedVessel.LandedOrSplashed) { increment_time = 0d; Patches.Clear(); return; } try { // start of trajectory calculation in current frame increment_time = Util.Clocks; // create or update aerodynamic model if (aerodynamicModel_ == null || !aerodynamicModel_.IsValidFor(AttachedVessel.mainBody)) { aerodynamicModel_ = AerodynamicModelFactory.GetModel(this, AttachedVessel.mainBody); } else { aerodynamicModel_.UpdateVesselMass(); } // if there is no ongoing partial computation, start a new one if (partialComputation_ == null) { //total_time = Util.Clocks; // restart the public buffers patchesBackBuffer_.Clear(); maxAccelBackBuffer_ = 0; // Create enumerator for Trajectory increment calculator partialComputation_ = ComputeTrajectoryIncrement().GetEnumerator(); } // we are finished when there are no more partial computations to be done bool finished = !partialComputation_.MoveNext(); // when calculation is finished, if (finished) { // swap the buffers for the patches and the maximum acceleration, // "publishing" the results List <Patch> tmp = Patches; Patches = patchesBackBuffer_; patchesBackBuffer_ = tmp; MaxAccel = maxAccelBackBuffer_; // Reset partial computation partialComputation_.Dispose(); partialComputation_ = null; // how long did the whole calculation take? //total_time = Util.ElapsedMilliseconds(total_time); } // how long did the calculation in this frame take? increment_time = Util.ElapsedMilliseconds(increment_time); } catch (Exception) { ++ErrorCount; throw; } }