private static IEnumerable <bool> ComputeTrajectoryIncrement()
{
// create or update aerodynamic model
if (aerodynamicModel_ == null || !aerodynamicModel_.IsValidFor(Trajectories.AttachedVessel.mainBody))
{
aerodynamicModel_ = AerodynamicModelFactory.GetModel(Trajectories.AttachedVessel.mainBody);
}
else
{
aerodynamicModel_.IncrementalUpdate();
}
// create new VesselState from vessel, or null if it's on the ground
VesselState state = Trajectories.AttachedVessel.LandedOrSplashed ? null : new VesselState(Trajectories.AttachedVessel);
// iterate over patches until MaxPatchCount is reached
for (int patchIdx = 0; patchIdx < Settings.MaxPatchCount; ++patchIdx)
{
// stop if we don't have a vessel state
if (state == null)
{
break;
}
// If we spent more time in this calculation than allowed, pause until the next frame
if (incrementTime_.ElapsedMilliseconds > MaxIncrementTime)
{
yield return(false);
}
// if we have a patched conics solver, check for maneuver nodes
if (null != Trajectories.AttachedVessel.patchedConicSolver)
{
// search through maneuver nodes of the vessel
List <ManeuverNode> maneuverNodes = Trajectories.AttachedVessel.patchedConicSolver.maneuverNodes;
foreach (ManeuverNode node in maneuverNodes)
{
// if the maneuver node time corresponds to the end time of the last patch
if (node.UT == state.Time)
{
// add the velocity change of the burn to the velocity of the last patch
state.Velocity += node.GetBurnVector(CreateOrbitFromState(state));
break;
}
}
// Add one patch, then pause execution after every patch
foreach (bool result in AddPatch(state))
{
yield return(false);
}
}
state = AddPatch_outState;
}
}