Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //hit_axis is vector of axis which object collided with
- std::vector<sf::Vector2f>::iterator it;
- for(it = hit_axes.begin();it != hit_axes.end();it++){
- sf::Vector2f n = *it;
- sf::Vector2f comp_u = sf::Vector2f(0,0);
- if(n != sf::Vector2f(0,0)){ //because -0 * (0 / 0) = undefined
- comp_u = n * (maths::dot(dir,n) / maths::dot(n,n)); //component of hit axis in dir
- }
- sf::Vector2f comp_w = dir - comp_u;
- dir = comp_w;
- }
Add Comment
Please, Sign In to add comment