Jump to content
  • entries
    945
  • comments
    5,899
  • views
    930,141

One of the weirdest bugs of my life


Josh

2,340 views

 Share

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.)

 

blink.png

 

I fixed my own Math::Mod() function to account for negative results, and everything works fine now.

 

Just a little bit further. happy.png

 Share

5 Comments


Recommended Comments

Maybe your Mac has a 64-bit OS, and you are still using a 32-bit Windows?

I am using 64-bit Windows and 64-bit Linux, so I hope LE3 will work with them too.

Link to comment

I've ran into this problem whenever I've declared generic "int" values that are determined by the OS. I have forced myself into the habit of always declaring integer (32) and long (64) explicitly so I never get unexpected negative numbers. Woot, number bugs!

Link to comment

In C++ one should always use their own typedefs for all types, because the core types may vary between OS and different C++ compilers. Sometimes the dynamic behaviour is also wanted, and then you should use the native types.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...