Simple JBullet collision of two Nodes / Geometries

With jme 3.1 collision has stopped working and i just cannot find the right changes to adapt.

Here my collision method which worked flawlesssly until 3.1. The
addCollisionObject method seems to have changed, but i have no idea
where to get a com.bulletphysics.collision.dispatch.CollisionObject
from?

public boolean collideDirect(Node node_1, Geometry geom_1, Node node_2, Geometry geom_2)
    {
        initCollsionDetection(false);

        CollisionShape shape_1 = CollisionShapeFactory.createDynamicMeshShape(geom_1);
        CollisionShape shape_2 = CollisionShapeFactory.createDynamicMeshShape(geom_2);

        PhysicsRigidBody body_1 = new PhysicsRigidBody(shape_1);
        PhysicsRigidBody body_2 = new PhysicsRigidBody(shape_2);

        body_1.setPhysicsLocation(node_1.getWorldTranslation());
        body_1.setPhysicsRotation(node_1.getWorldRotation());

        body_2.setPhysicsLocation(node_2.getWorldTranslation());
        body_2.setPhysicsRotation(node_2.getWorldRotation());

        this.collision_world.addCollisionObject(body_1.getObjectId());
        this.collision_world.addCollisionObject(body_2.getObjectId());

        CollisionAlgorithm algo = this.collision_world.getDispatcher().findAlgorithm(body_1.getObjectId(),
                body_2.getObjectId());
        ManifoldResult contact_point_result = new ManifoldResult(body_1.getObjectId(), body_2.getObjectId());
        algo.processCollision(body_1.getObjectId(), body_2.getObjectId(), this.collision_world.getDispatchInfo(),
                contact_point_result);

        boolean collide = false;

        ObjectArrayList<PersistentManifold> manifolds = new ObjectArrayList<PersistentManifold>();
        algo.getAllContactManifolds(manifolds);

        for (PersistentManifold manifold : manifolds)
        {
            int num_contacts = manifold.getNumContacts();
            if (num_contacts > 0)
            {
                collide = true;
            }
        }

        this.collision_world.removeCollisionObject(body_1.getObjectId());
        this.collision_world.removeCollisionObject(body_2.getObjectId());

        return collide;
    }

CollisionWorld is initalized by this method:

public void initCollsionDetection(boolean force)
    {
        DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
        CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
        this.world_aabb_min = new Vector3f(-1000, -1000, -1000);
        this.world_aabb_max = new Vector3f(1000, 1000, 1000);

        AxisSweep3 broadphase = new AxisSweep3(this.world_aabb_min, this.world_aabb_max);

        this.collision_world = new CollisionWorld(dispatcher, broadphase, collisionConfiguration);
    }

Maybe there is a better way to do this, what i need is a simple method
that tells if two nodes collide with each other, but accurate collision
based on meshes not on bounding boxes.

Any ideas?

You’re using the jbullet library directly which you’re not meant to in jME so I guess your question would be for the jbullet or bullet developers. Furthermore this won’t work at all for jME’s native bullet binding. In jME you simply add a PhysicsCollisionListener to the PhysicsSpace. Just read the manual of jME.

Kind of expected such an answer. Yes, this is not the way it is meant in JME and described in the manual.

But what i need here is to be able to say if two geometries are colliding in an structural analysis of an arbitary model.
Event based collision detection is of no use here, as i am not doing any movements at all.

Just want to know if two static objects collide (or align each other) and that with more precision than boundaries.

So maybe someone familiar with jbullet stuff may help …

Nothing has changed in out jbullet library since 3.0

At least PhysicsRigidBody.getObjectId() has changed. It now returns long, which before returned an instance of RigidBody.

That is exactly my problem, cannot find where to get the RigidBody instance from now. Seems logic to me that the .getObjectId() returns a long value, but this was not the case before.

Looks like you’re using native bullet instead of jbullet then.

Sorry, but i do net get the difference of native or not …
I’m using jme3 classes, as “com.jme3.bullet.collision.PhysicsCollisionObject.getObjectId()”. Is this not jbullet?

No, com.bulletphysics classes are from the jbullet library. Just remove jme3-bullet.jar jme3-bullet-natives.jar and include jme3-jbullet.jar, jbullet.jar, stack-alloc.jar and vecmath.jar in your project.

the com.jme3.bullet classes are from jME and wrap either jbullet or bullet depending on what you use. This is also why its suggested NOT to use com.bulletphysics classes directly. If you don’t you can simply move from jbullet to native bullet by changing the libraries (and not your code).

Again, read the manual: http://wiki.jmonkeyengine.org/doku.php/jme3:jme3_source_structure