setRestitution(0), rounding error (maybe)
Posted: Sun Apr 25, 2010 8:42 am
What I THINK is happening is that setRestitution(0.0) gets interpreted as a very small but non-zero number. This is making a mass thrown at the floor at a high velocity bounce slightly. The surprising part is that it continues to bounce. This is just a guess as to what is happening. The full details are below.
Can anyone confirm/deny this bug? Or even better, provide best-practice workarounds?
DETAILS:
I am currently playing with a platformer (I know, I know) of sorts, and need to know if I am able to jump. To do this I need to know if I am currently in contact with any objects. To do this I keep a list of objects that I am in contact with via the world.addCallbacks callbacks, being careful not to add the same object mutliple times.
At times my character is thrown quite quickly, bounces off a few objects, and winds up landing (usually) on the ground. The ground and the character have had their restitution set to 0.0.
When this happens my character visually does what I expect, he slams into the ground, maybe slides left/right a bit, but does not bounce upward. Jumping then becomes "glitchy" however. Debugging shows that my "objects I am in contact with" counter is bouncing rapidly between 1 and 0. I can jump when it's at 1, but not when it's at 0. The only way this could be happening is if Box2d is rapidly sending me contact begin and contact end notices for me and the ground. The only logical reason I can surmise is if restitution floating point is failing me at high velocities.
Can anyone confirm/deny this bug? Or even better, provide best-practice workarounds?
DETAILS:
I am currently playing with a platformer (I know, I know) of sorts, and need to know if I am able to jump. To do this I need to know if I am currently in contact with any objects. To do this I keep a list of objects that I am in contact with via the world.addCallbacks callbacks, being careful not to add the same object mutliple times.
At times my character is thrown quite quickly, bounces off a few objects, and winds up landing (usually) on the ground. The ground and the character have had their restitution set to 0.0.
When this happens my character visually does what I expect, he slams into the ground, maybe slides left/right a bit, but does not bounce upward. Jumping then becomes "glitchy" however. Debugging shows that my "objects I am in contact with" counter is bouncing rapidly between 1 and 0. I can jump when it's at 1, but not when it's at 0. The only way this could be happening is if Box2d is rapidly sending me contact begin and contact end notices for me and the ground. The only logical reason I can surmise is if restitution floating point is failing me at high velocities.