From 818aaf01a94d038e4013de51751af4d271951d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Oudin?= Date: Wed, 14 Feb 2018 11:41:24 +0100 Subject: [PATCH] Finished rebase --- Ball.cpp | 14 ++++++++++++-- main_bounce.cpp | 3 +-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Ball.cpp b/Ball.cpp index fb6395c..d04c309 100644 --- a/Ball.cpp +++ b/Ball.cpp @@ -42,6 +42,7 @@ void Ball::_compute_pos(double dt) { } Center.x += dt * v_x; Center.z += dt * v_z; + std::cout << (*this) <<"\n"; surface.update_center_pos(Center); surface.check_ground_collision(ground); } @@ -63,12 +64,18 @@ void Ball::_compute_U_n() { } void Ball::_compute_v_x(Point normal) { - double factor = normal.x / (4*(normal.x + normal.z)); + double factor = 0; + if (normal.x + normal.z != 0) { + factor = normal.x / (4*(normal.x + normal.z)); + } v_x *= (0.5 + factor); } void Ball::_compute_v_z(Point normal) { - double factor = normal.z / (4*(normal.x + normal.z)); + double factor = 0; + if (normal.x + normal.z != 0) { + factor = normal.z / (4*(normal.x + normal.z)); + } v_z *= (0.5 + factor); } @@ -83,6 +90,9 @@ void Ball::_compute_parameters() { _compute_v_z(normal); min_height = fmin(radius, min_height + 0.2 * (radius - min_height)); std::cout << "U:" << U << "\n"; + std::cout << "B:" << B << "\n"; + std::cout << "A:" << A << "\n"; + std::cout << "T:" << T << "\n"; } void Ball::update_pos(double dt) { diff --git a/main_bounce.cpp b/main_bounce.cpp index 61b9f96..d4245ae 100644 --- a/main_bounce.cpp +++ b/main_bounce.cpp @@ -11,7 +11,7 @@ int main(int argc, char** argv) { - PerlinGround* flat = new PerlinGround(); + FlatGround* flat = new FlatGround(); GlutRender& render = GlutRender::get_instance(); render.init(&argc, argv, 640, 480, "Bouncing stuff"); @@ -23,7 +23,6 @@ int main(int argc, char** argv) { bbox.low(0), bbox.low(1), bbox.low(2), bbox.high(0), bbox.high(1), bbox.high(2)); render.add_surface(ball.get_surface(), bbox); - render.add_surface(flat->get_surface(), bbox_2); render.set_idle_func(periodic_update); init_periodic_static(&ball);