from what I can see, the code is correct and it behaves the way it should?
After some tests I guess it does.. but it just doesn't fit my expectations :<
Damn... Thank you txesmi, and yes... thanks to your code, I can see that bounce get's fucked up when box hits the edge..
Another thing that I noticed, that it bounces off the surface different amount of time.. with fps 60 - 5 times, 20 - 6 times... If I lower fps while it's already bouncing, then it will cause to bounce off 7 times..
That sliding bounce effect was fixed by calculating bounce manually:
function get_bounce(VECTOR *speed, VECTOR *bounce_vec){
VECTOR temp_inverse;
vec_set(&temp_inverse, speed);
vec_inverse(&temp_inverse);
bounce_vec->x = speed->x + 2 * vec_dot(&normal, &temp_inverse) * normal.x;
bounce_vec->y = speed->y + 2 * vec_dot(&normal, &temp_inverse) * normal.y;
bounce_vec->z = speed->z + 2 * vec_dot(&normal, &temp_inverse) * normal.z;
}
Best regards! Thank you for your time guys.
Edit:
I think you need to implement a fourth order Runge-Kutta method to get correct results with large time_steps.
Or just dive into the world of game physics literature that can drive you crazy
(it depends on the knowledge you already have)
https://www.amazon.com/gp/aw/d/012381976...&ref=plSrch Thank you for the link! I'll take a look at it.