From dc213cdeeb909a485335109ff071579ac86696de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Oudin?= Date: Tue, 13 Feb 2018 16:21:38 +0100 Subject: [PATCH] Fix bouncing when staying on the ground. Now, there is still a min_p that is respected. --- Ball.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Ball.cpp b/Ball.cpp index 0103ceb..9b13459 100644 --- a/Ball.cpp +++ b/Ball.cpp @@ -31,10 +31,10 @@ void Ball::_compute_pos(double dt) { ); } else { double n_time = crt_time - stop_bouncing; - Center.y = ((radius * (1.0 - exp(-n_time)) + radius)/2.) + (radius - - ((radius * (1- exp(-n_time)) + radius)/2.)) * sin(5. * n_time); - v_x *= 0.99; - v_z *= 0.99; + double min_rad = radius - min_height; + Center.y = min_height + ((min_rad * (1.0 - exp(-n_time)) + min_rad )/2.) + + (min_rad - ((min_rad* (1- exp(-n_time)) + min_rad)/2.)) * sin(5. * + n_time); } Center.x += dt * v_x; Center.z += dt * v_z;