Handling of bounces for perlin noise surfaces

This commit is contained in:
Rémi Oudin 2018-02-12 17:41:12 +01:00
parent 0987290111
commit f2f6e9cb76
2 changed files with 11 additions and 8 deletions

View file

@ -41,24 +41,27 @@ void Ball::_compute_U_n() {
U *= 0.5;
}
void Ball::_compute_v_x() {
v_x *= 0.5;
void Ball::_compute_v_x(Point normal) {
double factor = normal.x / (4*(normal.x + normal.y));
v_x *= (0.5 + factor);
}
void Ball::_compute_v_y() {
v_y *= 0.5;
void Ball::_compute_v_y(Point normal) {
double factor = normal.x / (4*(normal.x + normal.y));
v_y *= (0.5 + factor);
}
void Ball::update_pos(double dt) {
crt_time += dt;
if (crt_time >= T) {
Point normal = surface.getNormalVector();
bounce_number += 1;
_compute_U_n();
_compute_A_n();
_compute_B_n();
_compute_T_n();
_compute_v_x();
_compute_v_y();
_compute_v_x(normal);
_compute_v_y(normal);
std::cout << "New bounce :";
std::cout << "U:" << U << ":";
std::cout << "A:" << A << ":";

View file

@ -26,8 +26,8 @@ class Ball {
double A, B, U, T; // Coefficients for the physical model.
double v_x, v_y;
void _compute_pos(double dt);
void _compute_v_x();
void _compute_v_y();
void _compute_v_x(Point normal);
void _compute_v_y(Point normal);
void _compute_A_n();
void _compute_B_n();
void _compute_U_n();