c++ - Testing for alignment with floating point -


this physics engine:

when object collides on slope, speed adjust accordingly parallel said slope.

to check if object moving towards or away slope, use dot product between slope's normal , velocity of object.

the problem arises due floating point math. sometimes, velocity of object parallel slope, not -perfectly- parallel, causing detected collision.

in cases, incorrect, velocity readjusted parallel, checked again , detected once more.

is there way avoid behavior without having store variables?

(i add copy of slope check hit, result in lot more checks every single object)

you can set minimum deviation slope leads collision detection check. i.e. if slopes verry similar, don't check collision. e.g. deviation less 0.01° should seen parallel.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -