public override void postSolve(Contact contact, ContactImpulse impulse) { if (m_broke) { // The body already broke. return; } // Should the body break? int count = contact.getManifold().pointCount; float maxImpulse = 0.0f; for (int i = 0; i < count; ++i) { maxImpulse = MathUtils.max(maxImpulse, impulse.normalImpulses[i]); } if (maxImpulse > 40.0f) { // Flag the body for breaking. m_break = true; } }
public virtual void preSolve(Contact contact, Manifold oldManifold) { Manifold manifold = contact.getManifold(); if (manifold.pointCount == 0) { return; } Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); Collision.Collision.getPointStates(state1, state2, oldManifold, manifold); contact.getWorldManifold(worldManifold); for (int i = 0; i < manifold.pointCount && pointCount < MAX_CONTACT_POINTS; i++) { ContactPoint cp = points[pointCount]; cp.fixtureA = fixtureA; cp.fixtureB = fixtureB; cp.position.set(worldManifold.points[i]); cp.normal.set(worldManifold.normal); cp.state = state2[i]; cp.normalImpulse = manifold.points[i].normalImpulse; cp.tangentImpulse = manifold.points[i].tangentImpulse; cp.separation = worldManifold.separations[i]; ++pointCount; } }