|
|
|
|
@ -113,6 +113,18 @@ OrbitalElements preview_burn_result(const Spacecraft* craft, BurnDirection direc
|
|
|
|
|
// Elliptical orbits only: uses analytical mean anomaly delta to compute
|
|
|
|
|
// exact time to target true anomaly, eliminating per-frame propagation.
|
|
|
|
|
// TODO: add parabolic (Barker's equation) and hyperbolic branches.
|
|
|
|
|
// TODO: Combine the two trigger code paths into one. Both ultimately need
|
|
|
|
|
// to compute "dt from step start until the burn fires" and schedule a sub-step.
|
|
|
|
|
// For TRIGGER_TRUE_ANOMALY, precalculate the absolute time at which the
|
|
|
|
|
// anomaly is reached (based on current orbital elements) and cache it on the
|
|
|
|
|
// Maneuver struct, so both paths reduce to: if (sim->time + sim->dt >= trigger_time)
|
|
|
|
|
// { scheduled_dt = min(trigger_time - sim->time, sim->dt); return true; }
|
|
|
|
|
//
|
|
|
|
|
// Complication: maneuvers for a single craft are stored in a flat array with no
|
|
|
|
|
// guaranteed order. When an earlier maneuver fires and changes the orbit, the
|
|
|
|
|
// cached trigger time for subsequent maneuvers becomes stale and must be
|
|
|
|
|
// recomputed. The current per-frame approach self-corrects by recomputing from
|
|
|
|
|
// the craft's current orbital elements each step.
|
|
|
|
|
bool check_maneuver_trigger(Maneuver* maneuver, Spacecraft* craft, SimulationState* sim) { |
|
|
|
|
switch (maneuver->trigger_type) { |
|
|
|
|
case TRIGGER_TIME: { |
|
|
|
|
|