public void ComputeTrajectory(Vessel vessel, DescentProfile profile, bool incremental)
{
try
{
incrementTime_ = Stopwatch.StartNew();
if (partialComputation_ == null || vessel != vessel_)
{
patchesBackBuffer_.Clear();
maxAccelBackBuffer_ = 0;
vessel_ = vessel;
if (vessel == null)
{
patches_.Clear();
return;
}
if (partialComputation_ != null)
partialComputation_.Dispose();
partialComputation_ = computeTrajectoryIncrement(vessel, profile).GetEnumerator();
}
bool finished = !partialComputation_.MoveNext();
if (finished)
{
var tmp = patches_;
patches_ = patchesBackBuffer_;
patchesBackBuffer_ = tmp;
maxAccel_ = maxAccelBackBuffer_;
partialComputation_.Dispose();
partialComputation_ = null;
}
frameTime_ += (float)incrementTime_.ElapsedMilliseconds;
}
catch (Exception)
{
++errorCount_;
throw;
}
}