Finished rebase
This commit is contained in:
parent
d8dafd3823
commit
818aaf01a9
2 changed files with 13 additions and 4 deletions
14
Ball.cpp
14
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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue