Search in sources :

Example 1 with ShapeType

use of org.jbox2d.collision.shapes.ShapeType in project libgdx by libgdx.

the class WorldRayCastWrapper method pushContact.

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[type1.ordinal()][type2.ordinal()].creator;
    creator.push(contact);
}
Also used : ShapeType(org.jbox2d.collision.shapes.ShapeType) ParticleContact(org.jbox2d.particle.ParticleContact) Contact(org.jbox2d.dynamics.contacts.Contact) ParticleBodyContact(org.jbox2d.particle.ParticleBodyContact)

Example 2 with ShapeType

use of org.jbox2d.collision.shapes.ShapeType in project libgdx by libgdx.

the class WorldRayCastWrapper method popContact.

public Contact popContact(Fixture fixtureA, int indexA, Fixture fixtureB, int indexB) {
    final ShapeType type1 = fixtureA.getType();
    final ShapeType type2 = fixtureB.getType();
    final ContactRegister reg = contactStacks[type1.ordinal()][type2.ordinal()];
    if (reg != null) {
        if (reg.primary) {
            Contact c = reg.creator.pop();
            c.init(fixtureA, indexA, fixtureB, indexB);
            return c;
        } else {
            Contact c = reg.creator.pop();
            c.init(fixtureB, indexB, fixtureA, indexA);
            return c;
        }
    } else {
        return null;
    }
}
Also used : ShapeType(org.jbox2d.collision.shapes.ShapeType) ContactRegister(org.jbox2d.dynamics.contacts.ContactRegister) ParticleContact(org.jbox2d.particle.ParticleContact) Contact(org.jbox2d.dynamics.contacts.Contact) ParticleBodyContact(org.jbox2d.particle.ParticleBodyContact)

Aggregations

ShapeType (org.jbox2d.collision.shapes.ShapeType)2 Contact (org.jbox2d.dynamics.contacts.Contact)2 ParticleBodyContact (org.jbox2d.particle.ParticleBodyContact)2 ParticleContact (org.jbox2d.particle.ParticleContact)2 ContactRegister (org.jbox2d.dynamics.contacts.ContactRegister)1