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

Force of collision

Topics: Developer Forum
Jul 11, 2013 at 7:55 AM
Edited Jul 11, 2013 at 7:56 AM
Hi, I've figured out how to measure the force of collisions in farseer - I tried googling first and none of the proposed solutions for either Farseer or Box2d were working. In the end, I was able to figure it out but unfortunately it required a change to the Farseer source. Genbox, maybe you could fix this for 3.5? Looking forward to that release!

The manifold in AfterCollission(Fixture fixturea, Fixture fixtureb, Contact contact) doesn't get properly updated with the impulse - well, it does every once in a while but not consistently. In the code that's calling AfterCollision there is another manifold that does contain the impulse, and that's the ContactConstraint. Instead of updating the manifolds in Contact I added the ContactConstraint to the callback because I didn't know what I'd break otherwise;

public class Island:
 private void Report(ContactConstraint[] constraints)
            if (_contactManager == null)

            for (int i = 0; i < ContactCount; ++i)
                Contact c = _contacts[i];
                ContactConstraint cc = constraints[i];

                if (c.FixtureA.AfterCollision != null)
                    c.FixtureA.AfterCollision(c.FixtureA, c.FixtureB, c, cc);

                if (c.FixtureB.AfterCollision != null)
                    c.FixtureB.AfterCollision(c.FixtureB, c.FixtureA, c, cc);

                if (_contactManager.PostSolve != null)

                    _contactManager.PostSolve(c, cc);
Figure out collision strength / impulse;
    private void AfterCollission(Fixture fixturea, Fixture fixtureb, Contact contact, ContactConstraint contactConstraint)
            float maxImpulse = 0f;
            for (int i = 0; i < contactConstraint.PointCount; i++)
                maxImpulse = Math.Max(maxImpulse, contactConstraint.Points[i].NormalImpulse);

            Proxy.CollisionImpulse = Math.Max(Proxy.CollisionImpulse, maxImpulse);
Jul 16, 2013 at 3:50 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.