Catastrophic error in Simulator.Update()

Topics: Developer Forum
Feb 3, 2010 at 7:39 PM

I got an error :

System.ArithmeticException: Function does not accept floating point Not-a-Number values.
   at System.Math.Sign(Single value)
   at FarseerGames.FarseerPhysics.Dynamics.Body.IntegrateVelocity(Single dt) in D:\Code\Imagin8\3rdParty\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\Dynamics\Body.cs:line 882
   at FarseerGames.FarseerPhysics.PhysicsSimulator.ApplyForces(Single dt, Single dtReal) in D:\Code\Imagin8\3rdParty\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 558
   at FarseerGames.FarseerPhysics.PhysicsSimulator.Update(Single dt, Single dtReal) in D:\Code\Imagin8\3rdParty\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 403
   at FarseerGames.FarseerPhysics.PhysicsSimulator.Update(Single dt) in D:\Code\Imagin8\3rdParty\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 352

 

This is the line that causes the error in Body.cs:

_rotationalDrag = AngularVelocity * AngularVelocity * Math.Sign(AngularVelocity);

This is a catastrophic error because the simulator does not recover and halts completely.
Once AngularVelocity is becomes NaN, every call to Update() will crash.

Any ideas how to deal with this ?
Maybe scan all bodies every frame to try to detect "bad" ones ?