It benefits me a lot to simply put OnCollision inside of StoreImpulses() inside of ContactSolver.
In fact, I had it in there while I was using the 3.0 beta, and after moving up to the release version
of 3.0, I still find that having it in there is more useful, and from what I can tell, faster.
To be more specific, This is where I've got it:
public void StoreImpulses()
for (int i = 0; i < _constraintCount; ++i)
ContactConstraint c = Constraints[i];
Manifold m = c.Manifold;
for (int j = 0; j < c.PointCount; ++j)
var pj = m.Points[j];
var cp = c.Points[j];
pj.NormalImpulse = cp.NormalImpulse;
pj.TangentImpulse = cp.TangentImpulse;
m.Points[j] = pj;
c.Manifold = m;
_contacts[i].Manifold = m;
//Oranjoose code start
Contact tempContact = _contacts[i];
Fixture fixA = tempContact.FixtureA;
Fixture fixB = tempContact.FixtureB;
if (fixA.OnCollision != null)
fixA.OnCollision(fixA, fixB, tempContact);
if (fixB.OnCollision != null)
fixB.OnCollision(fixB, fixA, tempContact);
//Oranjoose code stop
Having the OnCollision methods fire here gives me access to the Impulse values right here on the fly.
Any thoughts on the idea?