From e2416f679c877cedcf63b0da86b9d0c572ec33c1 Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sun, 13 Jun 2010 16:04:57 +0300 Subject: [PATCH] main.c: Skip simulation when time step is zero When user has set the simulation speed to zero, there is no need to run the simulation at all, as it won't be changing anyway. This makes it possible to run excessively large simulations and occassionally freeze the simulation. Then, for example, inspecting the tree topology (if draw_lines variable is enabled) becomes easier without need to worry about slow camera movement. Signed-off-by: Timo Kokkonen --- main.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index f2a012c..eb1b127 100644 --- a/main.c +++ b/main.c @@ -221,23 +221,25 @@ static void loop(SDL_Surface *screen, int num_of_planets, double total_mass, while (1) { planets = 0; - list_for_each_entry(pl1, &planet->list, list) { - pl2 = list_to_planet(pl1->list.next); - list_for_each_entry_from(pl2, &planet->list, list) { - struct planet *ptmp; - if (!gravitize_planets(pl1, pl2, - step_time)) - continue; - - ptmp = list_to_planet(pl2->list.prev); - merge_planets(pl1, pl2); - pl2 = ptmp; + if (status.time_scale > 0) { + list_for_each_entry(pl1, &planet->list, list) { + pl2 = list_to_planet(pl1->list.next); + list_for_each_entry_from(pl2, &planet->list, + list) { + struct planet *ptmp; + if (!gravitize_planets(pl1, pl2, + step_time)) + continue; + + ptmp = list_to_planet(pl2->list.prev); + merge_planets(pl1, pl2); + pl2 = ptmp; + } + + planet_root = move_planet(pl1, step_time); + planets++; } - - planet_root = move_planet(pl1, step_time); - planets++; } - move_camera(&camera, true_time); if (poll_events(&status, true_time)) -- 2.44.0