Browse Source

update satellite position when time_step is 0

main
cinnaboot 5 years ago
parent
commit
4b201af742
  1. 19
      src/main.cpp

19
src/main.cpp

@ -109,6 +109,7 @@ preFrameCallback(render_state* rs)
if (is.window_closed || is.escape) if (is.window_closed || is.escape)
rs->running = false; rs->running = false;
if (g_time_step > 0)
updateSatellitePosition(rs->render_groups[0].entities[2]); updateSatellitePosition(rs->render_groups[0].entities[2]);
} }
@ -118,6 +119,15 @@ postFrameCallback(render_state* rs)
static orbital_elements c_orb = {}; static orbital_elements c_orb = {};
c_orb = g_orbit; c_orb = g_orbit;
gooDraw(rs->handles->window, c_orb, g_time_step); gooDraw(rs->handles->window, c_orb, g_time_step);
bool update_if_paused = false;
if (c_orb.nu != g_orbit.nu &&
((c_orb.nu >= 0 && c_orb.nu <= M_PI) ||
(c_orb.nu < 0 && c_orb.nu >= -1 * M_PI)))
{
g_orbit.nu = c_orb.nu;
update_if_paused = true;
}
// TODO: will need more validation from GUI as added // TODO: will need more validation from GUI as added
if (!ellipsesEqual(c_orb.ep, g_orbit.ep)) { if (!ellipsesEqual(c_orb.ep, g_orbit.ep)) {
@ -139,15 +149,12 @@ postFrameCallback(render_state* rs)
// updating/constructing an orbit // updating/constructing an orbit
g_orbit.epsilon = orbitGetSpecificEnergy(g_orbit.ep.a, g_orbit.mu); g_orbit.epsilon = orbitGetSpecificEnergy(g_orbit.ep.a, g_orbit.mu);
g_orbit.h = orbitGetAngularMomentum(g_orbit.ep.p, g_orbit.mu); g_orbit.h = orbitGetAngularMomentum(g_orbit.ep.p, g_orbit.mu);
update_if_paused = true;
} }
} }
if (c_orb.nu != g_orbit.nu && if (g_time_step == 0 && update_if_paused)
((c_orb.nu >= 0 && c_orb.nu <= M_PI) || updateSatellitePosition(rs->render_groups[0].entities[2]);
(c_orb.nu < 0 && c_orb.nu >= -1 * M_PI)))
{
g_orbit.nu = c_orb.nu;
}
} }
int int

Loading…
Cancel
Save