by peterstock » Tue Nov 20, 2007 5:39 pm
I've tracked down this bug now - here's an explanation of what's going on:
The problem in this case is in the armadillo-link collision code. A collision is flagged when the armadillo and the relevant part of the link are close enough and their relative velocity along the collision normal axis is positive (i.e. they are moving together, not apart). Then the velocities are stored for the collision and used in the collision resolution calculations later on.
The problem is that because of floating point optimisations, at the point when the test for relative velocity being positive is made, the velocity variables are held at a higher precision than normal floats are stored at. Then the later calculations use these numbers after they've been rounded to the normal floating point precision, but at this point they are equal. Unfortunately this breaks the code which assumes that it can use the relative velocity as a divisor, and hence infinite velocity and thus infinite position in later calculations.
I really should have done some research into the problems that can arise from floating point compiler optimisations before I released the game. Now any change I make will affect the way all levels/solutions play out, so I'm saving up all the simulation-affecting bug fixes to be fixed in a new release.