Finished rebase

This commit is contained in:
Rémi Oudin 2018-02-14 11:41:24 +01:00
parent d8dafd3823
commit 818aaf01a9
2 changed files with 13 additions and 4 deletions

View file

@ -42,6 +42,7 @@ void Ball::_compute_pos(double dt) {
} }
Center.x += dt * v_x; Center.x += dt * v_x;
Center.z += dt * v_z; Center.z += dt * v_z;
std::cout << (*this) <<"\n";
surface.update_center_pos(Center); surface.update_center_pos(Center);
surface.check_ground_collision(ground); surface.check_ground_collision(ground);
} }
@ -63,12 +64,18 @@ void Ball::_compute_U_n() {
} }
void Ball::_compute_v_x(Point normal) { 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); v_x *= (0.5 + factor);
} }
void Ball::_compute_v_z(Point normal) { 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); v_z *= (0.5 + factor);
} }
@ -83,6 +90,9 @@ void Ball::_compute_parameters() {
_compute_v_z(normal); _compute_v_z(normal);
min_height = fmin(radius, min_height + 0.2 * (radius - min_height)); min_height = fmin(radius, min_height + 0.2 * (radius - min_height));
std::cout << "U:" << U << "\n"; 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) { void Ball::update_pos(double dt) {

View file

@ -11,7 +11,7 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
PerlinGround* flat = new PerlinGround(); FlatGround* flat = new FlatGround();
GlutRender& render = GlutRender::get_instance(); GlutRender& render = GlutRender::get_instance();
render.init(&argc, argv, 640, 480, "Bouncing stuff"); 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.low(0), bbox.low(1), bbox.low(2),
bbox.high(0), bbox.high(1), bbox.high(2)); bbox.high(0), bbox.high(1), bbox.high(2));
render.add_surface(ball.get_surface(), bbox); render.add_surface(ball.get_surface(), bbox);
render.add_surface(flat->get_surface(), bbox_2);
render.set_idle_func(periodic_update); render.set_idle_func(periodic_update);
init_periodic_static(&ball); init_periodic_static(&ball);