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

Closed

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

description

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?
Closed Aug 30, 2014 at 10:35 PM by genbox

comments

DamonWall wrote Oct 21, 2013 at 10:38 AM

i already wrote about this here
https://farseerphysics.codeplex.com/workitem/34462
) glad i'm not the only one who noted this

wrote Dec 10, 2013 at 6:59 AM

sajjadgame wrote Mar 5, 2014 at 11:38 AM

i have this problem to
i use your Solution but it cause missing object i think a better answer is this
if (normal == Vector2.Zero)
{
        normal.X += 0.1f;
 }

 normal.Normalize();

jamesford42 wrote May 12, 2014 at 5:00 AM

WorldManifold.Initialize and PositionSolverManifold.Initialize should be using the same method for protecting against normalizing a zero length vector. One of them has the correct code the other does not.

wrote Aug 30, 2014 at 10:35 PM

Resolved with changeset 106574: Fixed issue 34552