I'm using a standard Box2D ContactListener
to listen on collision events. What I want is to calculate the strength of the impact of the collision between Bodies.
I've read many different descriptions of how people calculate it. Some use the preSolve
callback, others use postSolve
. Some use the Manifold
, others the ContactImpulse
. Some take only the first point's normalImpulse+tangentImpulse, others take the sum of all points and others, again, take the maximum. Some people ignore tangentImpulses completely...
I cannot get my head around this problem. Sometimes I get only impulses in postSolve
and the impulses in preSolve
are 0 in total. Sometimes it's the other way around. Sometimes I get ridiculously high values (say 1E15 to 1E30) and sometimes they are ridiculously low (say -1E15 to -1E30). I even had the case that one of the impulses was NaN
(Not a Number).
Is there anyone who can explain to me how to solve this problem and maybe explain how to interpret those impulses? Or maybe point me to any kind of open source game which uses Box2D and also needs to calculate the impact for any kind of damage system?