org.jbox2d.collision.Manifold Java Examples

The following examples show how to use org.jbox2d.collision.Manifold. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OneSidedTest.java    From jbox2d with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
  super.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);
  }
}
 
Example #2
Source File: ChainAndPolygonContact.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  ChainShape chain = (ChainShape) m_fixtureA.getShape();
  chain.getChildEdge(edge, m_indexA);
  pool.getCollision().collideEdgeAndPolygon(manifold, edge, xfA,
      (PolygonShape) m_fixtureB.getShape(), xfB);
}
 
Example #3
Source File: ContactSolver.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void storeImpulses() {
  for (int i = 0; i < m_count; i++) {
    final ContactVelocityConstraint vc = m_velocityConstraints[i];
    final Manifold manifold = m_contacts[vc.contactIndex].getManifold();

    for (int j = 0; j < vc.pointCount; j++) {
      manifold.points[j].normalImpulse = vc.points[j].normalImpulse;
      manifold.points[j].tangentImpulse = vc.points[j].tangentImpulse;
    }
  }
}
 
Example #4
Source File: Contact.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected Contact(IWorldPool argPool) {
  m_fixtureA = null;
  m_fixtureB = null;
  m_nodeA = new ContactEdge();
  m_nodeB = new ContactEdge();
  m_manifold = new Manifold();
  pool = argPool;
}
 
Example #5
Source File: ChainAndCircleContact.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  ChainShape chain = (ChainShape) m_fixtureA.getShape();
  chain.getChildEdge(edge, m_indexA);
  pool.getCollision().collideEdgeAndCircle(manifold, edge, xfA,
      (CircleShape) m_fixtureB.getShape(), xfB);
}
 
Example #6
Source File: ConveyorBelt.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
  super.preSolve(contact, oldManifold);

  Fixture fixtureA = contact.getFixtureA();
  Fixture fixtureB = contact.getFixtureB();

  if (fixtureA == m_platform || fixtureB == m_platform) {
    contact.setTangentSpeed(5.0f);
  }
}
 
Example #7
Source File: TestbedTest.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void preSolve(Contact contact, Manifold oldManifold) {
  Manifold manifold = contact.getManifold();

  if (manifold.pointCount == 0) {
    return;
  }

  Fixture fixtureA = contact.getFixtureA();
  Fixture fixtureB = contact.getFixtureB();

  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;
  }
}
 
Example #8
Source File: Box2DContactListener.java    From Form-N-Fun with MIT License 4 votes vote down vote up
@Override
public void preSolve(Contact arg0, Manifold arg1) {
    // TODO Auto-generated method stub

}
 
Example #9
Source File: PolygonAndCircleContact.java    From jbox2d with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  pool.getCollision().collidePolygonAndCircle(manifold, (PolygonShape) m_fixtureA.getShape(),
      xfA, (CircleShape) m_fixtureB.getShape(), xfB);
}
 
Example #10
Source File: Contact.java    From jbox2d with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Get the contact manifold. Do not set the point count to zero. Instead call Disable.
 */
public Manifold getManifold() {
  return m_manifold;
}
 
Example #11
Source File: CircleContact.java    From jbox2d with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  pool.getCollision().collideCircles(manifold, (CircleShape) m_fixtureA.getShape(), xfA,
      (CircleShape) m_fixtureB.getShape(), xfB);
}
 
Example #12
Source File: EdgeAndPolygonContact.java    From jbox2d with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  pool.getCollision().collideEdgeAndPolygon(manifold, (EdgeShape) m_fixtureA.getShape(), xfA,
      (PolygonShape) m_fixtureB.getShape(), xfB);
}
 
Example #13
Source File: PolygonContact.java    From jbox2d with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  pool.getCollision().collidePolygons(manifold, (PolygonShape) m_fixtureA.getShape(), xfA,
      (PolygonShape) m_fixtureB.getShape(), xfB);
}
 
Example #14
Source File: EdgeAndCircleContact.java    From jbox2d with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void evaluate(Manifold manifold, Transform xfA, Transform xfB) {
  pool.getCollision().collideEdgeAndCircle(manifold, (EdgeShape) m_fixtureA.getShape(), xfA,
      (CircleShape) m_fixtureB.getShape(), xfB);
}
 
Example #15
Source File: ContactListener.java    From jbox2d with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * This is called after a contact is updated. This allows you to inspect a
 * contact before it goes to the solver. If you are careful, you can modify the
 * contact manifold (e.g. disable contact).
 * A copy of the old manifold is provided so that you can detect changes.
 * Note: this is called only for awake bodies.
 * Note: this is called even when the number of contact points is zero.
 * Note: this is not called for sensors.
 * Note: if you set the number of contact points to zero, you will not
 * get an EndContact callback. However, you may get a BeginContact callback
 * the next step.
 * Note: the oldManifold parameter is pooled, so it will be the same object for every callback
 * for each thread.
 * @param contact
 * @param oldManifold
 */
public void preSolve(Contact contact, Manifold oldManifold);
 
Example #16
Source File: Contact.java    From jbox2d with BSD 2-Clause "Simplified" License votes vote down vote up
public abstract void evaluate(Manifold manifold, Transform xfA, Transform xfB);