Spawning two bodies at (0, 0) results in position of NaN

Topics: Developer Forum
Sep 18, 2013 at 4:32 AM
Edited Sep 18, 2013 at 4:33 AM
Project demonstrating the bug.

Hey Guys,

I found a bug caused by spawning two circle bodies at (0, 0). I attached an example project that demonstrates the problem. The culprit is in ContactSolver.cs FarseerPhysics.Dynamics.Contacts.PositionSolverManifold.Initialize(...) which is trying to normalize a zero vector. Does anybody have any recommendations or opinions on how to solve this?

I was thinking something simple like:
if(normal != Vector2.Zero)
    normal.Normalize();
Thoughts?
Oct 10, 2013 at 9:40 PM
Edited Oct 10, 2013 at 9:42 PM
I can confirm this, just had a nice debugging session trying to determine what was causing the entire simulation to hang. Implemented poohshoes' solution and am now back working again.

Should happen in any case where both circle bodies have the same position.
Coordinator
Oct 12, 2013 at 4:07 PM
The bug does manifest itself in that particular line, but the problem should never arise in the first place. Thanks for reporting, I will copy it to a work item and fix it when possible.
Coordinator
Oct 12, 2013 at 4:08 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.