This project has moved. For the latest updates, please go here.

Settings.MixFriction() behaviour on Windows 8 x86 and ARM

Topics: Developer Forum
Dec 5, 2012 at 6:12 AM

We are developing a game targeted at Windows 8 x86 and ARM.  We have discovered a difference in behaviour in the default implementation of Settings.MixFriction() when both friction values are very large.

On x86, Settings.MixFriction(float.MaxValue, float.MaxValue) returns float.MaxValue, as you would expect.

On ARM, the same call returns float.Infinity.  This makes constraint solving never return due to NANs in the calculations from dividing by infinity.

We figure this is because x86 may be implicitly upcasting each parameter to a double before the multiply in MixFriction, whereas ARM keeps them at single precision for the multiply resulting in an overflow.  Our quick fix was to explicitly upcast to double, i.e.

            return (float) Math.Sqrt((double)friction1 * (double)friction2);

This allows ARM to behave the same as x86.

Dec 6, 2012 at 11:15 PM

Heh, the wonders of working with different hardware platforms.

Thanks for the heads up.