Fix bouncing when staying on the ground.

Now, there is still a min_p that is respected.
This commit is contained in:
Rémi Oudin 2018-02-13 16:21:38 +01:00 committed by Théophile Bastian
parent a0db41689c
commit dc213cdeeb

View file

@ -31,10 +31,10 @@ void Ball::_compute_pos(double dt) {
); );
} else { } else {
double n_time = crt_time - stop_bouncing; double n_time = crt_time - stop_bouncing;
Center.y = ((radius * (1.0 - exp(-n_time)) + radius)/2.) + (radius - double min_rad = radius - min_height;
((radius * (1- exp(-n_time)) + radius)/2.)) * sin(5. * n_time); Center.y = min_height + ((min_rad * (1.0 - exp(-n_time)) + min_rad )/2.) +
v_x *= 0.99; (min_rad - ((min_rad* (1- exp(-n_time)) + min_rad)/2.)) * sin(5. *
v_z *= 0.99; n_time);
} }
Center.x += dt * v_x; Center.x += dt * v_x;
Center.z += dt * v_z; Center.z += dt * v_z;