Question about PendingContact

So,  I'm digging into this JBullet integration, making some good progress.  I got collision events wired up, and started wiring up the ContactCallbacks, where most of the materials effects happen.  That's when I started noticing oddness.

From what it appears, the contact information in ODE is part of a PhysicsSpace member variable . . . one that gets updated by ODE, iterated through, and appropriate contact information changes applied and pushed back at the ODE library.  That works, I can dig it, but then I get into the com.jmex.physics.PhysicsNodeTest test class, and I see this code . . .

        PendingContact testContact = new PendingContact() {
            public Vector3f getContactNormal( Vector3f store ) {
                return null;

            public Vector3f getContactPosition( Vector3f store ) {
                return null;

            public PhysicsCollisionGeometry getGeometry1() {
                return ballSphere;

            public PhysicsCollisionGeometry getGeometry2() {
                return fixedBox;

            public PhysicsNode getNode1() {
                return ball;

            public PhysicsNode getNode2() {
                return fixed;

            public float getPenetrationDepth() {
                return 0;

            public void getDefaultFrictionDirections( Vector3f primaryStore, Vector3f secondaryStore ) {
                primaryStore.set( Float.NaN, Float.NaN, Float.NaN );
                secondaryStore.set( Float.NaN, Float.NaN, Float.NaN );

            public float getTime() {
                return 0;
        physicsSpace.adjustContact( testContact );
        assertEquals( "mu", 100, testContact.getMu(), 0.001f );
        assertTrue( "bounce", Float.isNaN( testContact.getBounce() ) );

        physicsSpace.setDirectionalGravity( new Vector3f( 0, -10, 0 ) );

        rootNode.updateGeometricState( 0, true );
        physicsSpace.update( 0.8f );

And now I'm having a Whiskey Tango Foxtrot moment . . .

Am I reading this right?  You should be able to arbitrarily create a 'PendingContact', push it at the physics implementation, and have that modified contact info applied when those two bodies collide at some unspecified point in the future?  I mean . . . I guess that works, but it's a bit backwards from what I'm doing.

JBullet has a couple of contact callbacks . . . ContactAdded, ContactProcessed, and ContactDestroyed.  My current implementation is wiring into the ContactAdded callback to create a 'PendingContact' object, which gets stored in a 'persistentUserData' property of the JBullet contact info.  That same 'PendingContact' object gets handed through to the 'ContactProcessed' and 'ContactDestroyed' callbacks, so I'm only creating and releasing that object once per contact.  Granted, you'll get GC hits pretty quickly, but it's a good starting point, and it's easy enough to wire into a PendingContact cache.

I had understood that class to simply be an information carrier about the contact characteristics of an already detected, but not yet processed collision, providing the opportunity to change those characteristics.  If that's all it needs to be, I can do that.

But, if this is  supposed to be a cache of all potential contact properties between all potential geometries . . . that'd be a bit dicier, but I can do it.  I just need to know how it's used.  'Cause the current implementation will never pass the unit tests.

Advice?  Insight?


Looks like I got it wired up anyway.  I'm still curious how this class is intended to be used, though, if anybody has any insight.