This project has moved and is read-only. For the latest updates, please go here.


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


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


DamonWall wrote Oct 21, 2013 at 11:38 AM

i already wrote about this here
) glad i'm not the only one who noted this

wrote Dec 10, 2013 at 7:59 AM

sajjadgame wrote Mar 5, 2014 at 12:38 PM

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;


jamesford42 wrote May 12, 2014 at 6: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 11:35 PM

Resolved with changeset 106574: Fixed issue 34552

wrote Nov 28 at 10:39 AM