// djm pooling public void update(ContactListener listener) { oldManifold.set(m_manifold); // Re-enable this contact. m_flags |= ENABLED_FLAG; bool touching = false; bool wasTouching = (m_flags & TOUCHING_FLAG) == TOUCHING_FLAG; bool sensorA = m_fixtureA.isSensor(); bool sensorB = m_fixtureB.isSensor(); bool sensor = sensorA || sensorB; Body bodyA = m_fixtureA.getBody(); Body bodyB = m_fixtureB.getBody(); Transform xfA = bodyA.getTransform(); Transform xfB = bodyB.getTransform(); // log.debug("TransformA: "+xfA); // log.debug("TransformB: "+xfB); if (sensor) { Shape shapeA = m_fixtureA.getShape(); Shape shapeB = m_fixtureB.getShape(); touching = pool.getCollision().testOverlap(shapeA, m_indexA, shapeB, m_indexB, xfA, xfB); // Sensors don't generate manifolds. m_manifold.pointCount = 0; } else { evaluate(m_manifold, xfA, xfB); touching = m_manifold.pointCount > 0; // Match old contact ids to new contact ids and copy the // stored impulses to warm start the solver. for (int i = 0; i < m_manifold.pointCount; ++i) { ManifoldPoint mp2 = m_manifold.points[i]; mp2.normalImpulse = 0.0d; mp2.tangentImpulse = 0.0d; ContactID id2 = mp2.id; for (int j = 0; j < oldManifold.pointCount; ++j) { ManifoldPoint mp1 = oldManifold.points[j]; if (mp1.id.isEqual(id2)) { mp2.normalImpulse = mp1.normalImpulse; mp2.tangentImpulse = mp1.tangentImpulse; break; } } } if (touching != wasTouching) { bodyA.setAwake(true); bodyB.setAwake(true); } } if (touching) { m_flags |= TOUCHING_FLAG; } else { m_flags &= ~TOUCHING_FLAG; } if (listener == null) { return; } if (wasTouching == false && touching) { listener.beginContact(this); } if (wasTouching && touching == false) { listener.endContact(this); } if (sensor == false && touching) { listener.preSolve(this, oldManifold); } }
public virtual void update(ContactListener listener) { oldManifold.set_Renamed(m_manifold); // Re-enable this contact. m_flags |= ENABLED_FLAG; bool touching = false; bool wasTouching = (m_flags & TOUCHING_FLAG) == TOUCHING_FLAG; bool sensorA = m_fixtureA.Sensor; bool sensorB = m_fixtureB.Sensor; bool sensor = sensorA || sensorB; Body bodyA = m_fixtureA.Body; Body bodyB = m_fixtureB.Body; Transform xfA = bodyA.getTransform(); Transform xfB = bodyB.getTransform(); // log.debug("TransformA: "+xfA); // log.debug("TransformB: "+xfB); if (sensor) { Shape shapeA = m_fixtureA.Shape; Shape shapeB = m_fixtureB.Shape; touching = pool.getCollision().testOverlap(shapeA, m_indexA, shapeB, m_indexB, xfA, xfB); // Sensors don't generate manifolds. m_manifold.pointCount = 0; } else { evaluate(m_manifold, xfA, xfB); touching = m_manifold.pointCount > 0; // Match old contact ids to new contact ids and copy the // stored impulses to warm start the solver. for (int i = 0; i < m_manifold.pointCount; ++i) { ManifoldPoint mp2 = m_manifold.points[i]; mp2.normalImpulse = 0.0f; mp2.tangentImpulse = 0.0f; ContactID id2 = mp2.id; for (int j = 0; j < oldManifold.pointCount; ++j) { ManifoldPoint mp1 = oldManifold.points[j]; if (mp1.id.isEqual(id2)) { mp2.normalImpulse = mp1.normalImpulse; mp2.tangentImpulse = mp1.tangentImpulse; break; } } } if (touching != wasTouching) { bodyA.Awake = true; bodyB.Awake = true; } } if (touching) { m_flags |= TOUCHING_FLAG; } else { m_flags &= ~TOUCHING_FLAG; } if (listener == null) { return; } if (wasTouching == false && touching == true) { listener.beginContact(this); } if (wasTouching == true && touching == false) { listener.endContact(this); } if (sensor == false && touching) { listener.preSolve(this, oldManifold); } }
public void destroy(Contact c) { Fixture fixtureA = c.getFixtureA(); Fixture fixtureB = c.getFixtureB(); Body bodyA = fixtureA.getBody(); Body bodyB = fixtureB.getBody(); if (m_contactListener != null && c.isTouching()) { m_contactListener.endContact(c); } // Remove from the world. if (c.m_prev != null) { c.m_prev.m_next = c.m_next; } if (c.m_next != null) { c.m_next.m_prev = c.m_prev; } if (c == m_contactList) { m_contactList = c.m_next; } // Remove from body 1 if (c.m_nodeA.prev != null) { c.m_nodeA.prev.next = c.m_nodeA.next; } if (c.m_nodeA.next != null) { c.m_nodeA.next.prev = c.m_nodeA.prev; } if (c.m_nodeA == bodyA.m_contactList) { bodyA.m_contactList = c.m_nodeA.next; } // Remove from body 2 if (c.m_nodeB.prev != null) { c.m_nodeB.prev.next = c.m_nodeB.next; } if (c.m_nodeB.next != null) { c.m_nodeB.next.prev = c.m_nodeB.prev; } if (c.m_nodeB == bodyB.m_contactList) { bodyB.m_contactList = c.m_nodeB.next; } // Call the factory. pool.pushContact(c); --m_contactCount; }