Search in sources :

Example 1 with ContactRegister

use of org.jbox2d.dynamics.contacts.ContactRegister in project libgdx by libgdx.

the class WorldRayCastWrapper method addType.

private void addType(IDynamicStack<Contact> creator, ShapeType type1, ShapeType type2) {
    ContactRegister register = new ContactRegister();
    register.creator = creator;
    register.primary = true;
    contactStacks[type1.ordinal()][type2.ordinal()] = register;
    if (type1 != type2) {
        ContactRegister register2 = new ContactRegister();
        register2.creator = creator;
        register2.primary = false;
        contactStacks[type2.ordinal()][type1.ordinal()] = register2;
    }
}
Also used : ContactRegister(org.jbox2d.dynamics.contacts.ContactRegister)

Example 2 with ContactRegister

use of org.jbox2d.dynamics.contacts.ContactRegister 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

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