From f4b1299d3eabcf6bc5ac5e90f1a15227b23647dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Oudin?= Date: Tue, 13 Feb 2018 12:47:33 +0100 Subject: [PATCH] Avoid entering the block if we already stopped bouncing --- Ball.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ball.cpp b/Ball.cpp index 5e431b0..aa478cf 100644 --- a/Ball.cpp +++ b/Ball.cpp @@ -70,7 +70,7 @@ void Ball::_compute_v_z(Point normal) { void Ball::update_pos(double dt) { crt_time += dt; - if (crt_time >= T) { + if ((bouncing) && (crt_time >= T)) { double old_t = T; double max_t; Point normal = surface.getNormalVector(); @@ -83,7 +83,7 @@ void Ball::update_pos(double dt) { _compute_v_z(normal); max_t = (T - old_t)/2.0 + old_t; - if ((bouncing) && ((A + B * max_t - (G_CTE / 2) * max_t * max_t + min_height) < radius)) { + if (((A + B * max_t - (G_CTE / 2) * max_t * max_t + min_height) < radius)) { stop_bouncing = crt_time; bouncing = false; }