Browse Source

add TODO about combining code paths for check_maneuver_trigger

main
cinnaboot 3 months ago
parent
commit
008e524fe7
  1. 2
      docs/TODO
  2. 12
      src/maneuver.cpp

2
docs/TODO

@ -49,6 +49,8 @@ If you see modifications to this file in git status, IGNORE them and do not comm
the root body, or bary-center
- should try to use the same code path for bodies and craft on 'update' functions
as much as possible
- combine code paths for trigger types in check_maneuver_trigger().
- see TODO in src/maneuver.cpp
=== Simulation Config Files ===
- a format with nested children would be nice

12
src/maneuver.cpp

@ -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: {

Loading…
Cancel
Save