From 4b201af742a15eb9953f1449195d47ee956976a8 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Wed, 21 Apr 2021 12:14:06 -0400 Subject: [PATCH] update satellite position when time_step is 0 --- src/main.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 74d1a10..df76f55 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -109,7 +109,8 @@ preFrameCallback(render_state* rs) if (is.window_closed || is.escape) rs->running = false; - updateSatellitePosition(rs->render_groups[0].entities[2]); + if (g_time_step > 0) + updateSatellitePosition(rs->render_groups[0].entities[2]); } void @@ -118,6 +119,15 @@ postFrameCallback(render_state* rs) static orbital_elements c_orb = {}; c_orb = g_orbit; 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 if (!ellipsesEqual(c_orb.ep, g_orbit.ep)) { @@ -139,15 +149,12 @@ postFrameCallback(render_state* rs) // updating/constructing an orbit g_orbit.epsilon = orbitGetSpecificEnergy(g_orbit.ep.a, 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 && - ((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; - } + if (g_time_step == 0 && update_if_paused) + updateSatellitePosition(rs->render_groups[0].entities[2]); } int