Search in sources :

Example 1 with WorldManifold

use of spacegraph.space2d.phys.collision.WorldManifold in project narchy by automenta.

the class Fracture method fractureCheck.

// /**
// * Kontrolue, ci je kolizia kriticka, ak je, tak ju prida do hashovacej tabulky
// * kritickych kolizii. Treba zauvazit aj multimaterialove telesa. Materialy
// * tvoria spojovy zoznam, pre triestenie sa vsak pouzije len jeden
// */
// private static final MyList<Material> materials = new MyList<>();
private static void fractureCheck(final Fixture f1, final Fixture f2, final float iml, Dynamics2D w, Contact contact, int i) {
    // materials.clear();
    // for (Material m = f1.material; m != null; m = m.m_fragments) {
    // if (materials.contains(m)) {
    // return;
    // }
    Material m = f1.material;
    if (m != null && m.m_rigidity < iml) {
        f1.body.m_fractureTransformUpdate = f2.body.m_fractureTransformUpdate = false;
        if (f1.body.m_massArea > Material.MINMASSDESCTRUCTION) {
            WorldManifold wm = new WorldManifold();
            // vola sa iba raz
            contact.getWorldManifold(wm);
            w.addFracture(new Fracture(f1, f2, m, contact, iml, new v2(wm.points[i])));
        } else if (f1.body.type != BodyType.DYNAMIC) {
            w.addFracture(new Fracture(f1, f2, m, null, 0, null));
        }
    }
// materials.add(m);
// }
}
Also used : WorldManifold(spacegraph.space2d.phys.collision.WorldManifold) spacegraph.util.math.v2(spacegraph.util.math.v2)

Example 2 with WorldManifold

use of spacegraph.space2d.phys.collision.WorldManifold in project narchy by automenta.

the class TestQueryCallback method preSolve.

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;
    }
}
Also used : WorldManifold(spacegraph.space2d.phys.collision.WorldManifold) Manifold(spacegraph.space2d.phys.collision.Manifold) MouseJoint(spacegraph.space2d.phys.dynamics.joints.MouseJoint)

Aggregations

WorldManifold (spacegraph.space2d.phys.collision.WorldManifold)2 Manifold (spacegraph.space2d.phys.collision.Manifold)1 MouseJoint (spacegraph.space2d.phys.dynamics.joints.MouseJoint)1 spacegraph.util.math.v2 (spacegraph.util.math.v2)1