// Implement contact listener. public override void beginContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA == m_sensor) { Object userData = fixtureB.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = true; } } if (fixtureB == m_sensor) { Object userData = fixtureA.getBody().getUserData(); if (userData != null) { ((BoolWrapper) userData).tf = true; } } }
public override void preSolve(Contact contact, Manifold oldManifold) { base.preSolve(contact, oldManifold); Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA == m_platform || fixtureB == m_platform) { contact.setTangentSpeed(5.0f); } }
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; }
public override void preSolve(Contact contact, Manifold oldManifold) { base.preSolve(contact, oldManifold); Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (fixtureA != m_platform && fixtureA != m_character) { return; } if (fixtureB != m_character && fixtureB != m_character) { return; } Vec2 position = m_character.getBody().getPosition(); if (position.y < m_top + m_radius - 3.0f*Settings.linearSlop) { contact.setEnabled(false); } }
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; } }
public void pushContact(Contact contact) { Fixture fixtureA = contact.getFixtureA(); Fixture fixtureB = contact.getFixtureB(); if (contact.m_manifold.pointCount > 0 && !fixtureA.isSensor() && !fixtureB.isSensor()) { fixtureA.getBody().setAwake(true); fixtureB.getBody().setAwake(true); } ShapeType type1 = fixtureA.getType(); ShapeType type2 = fixtureB.getType(); IDynamicStack<Contact> creator = contactStacks[(int) type1][(int) type2].creator; creator.push(contact); }