One of the weirdest bugs of my life
So inexplicably, two days ago animation stopped working on all my Mac machines. I checked out the graphics module, looked in the surface class, the animation routine, and couldn't fine anything wrong. The same code ran fine on Windows, and all the animation is on the CPU, anyways, so it couldn't be a graphics issue.
I noticed if I explicitly set the frame number instead of using the time as the frame, it worked fine. So I start printing out the frame number in the animation routine. The frame the user specifies gets modulated by the frame count and that final number is used to determine an upper and lower frame, which get blended in between and used as the final orientation.
The final frame numbers were negative, meaning they were being read from well outside the array of animation data. This is because modf can returns a number between -n and +n, where n is the modulus. This only came up because on Windows, time is returned as a 32-bit integer, which then gets converted to a float value for the frame number, so it is always positive. Macs return a 64-bit long integer which can result in a negative float value, which then resulted in a negative frame index. (Time::GetCurrent returns a long value for this reason.)
I fixed my own Math::Mod() function to account for negative results, and everything works fine now.
Just a little bit further.
5 Comments
Recommended Comments