JBullet Collider Feedback Question

I’m trying to learn JBullet here, so please be patient with me.

I’ve setup CollisionWorld and CollisionObject wrappers so I can take my game entities and “plug” them into JBullet. I’m having a hard time figuring out how to get feedback from the library however.

First, I update all of my entities (if they need updating) and set their new locations and rotations. I then “synchronize” all of CollisionWorld’s objects with my entities (each entity has a reference to their collisionobject). I then use collisionWorld.performDiscreteCollisionDetection().

I can then collect all of the manifolds into an array, but how do I link them back to my entities? Also, is there any kind of feedback in the manifolds to let me know how far the entity is embedded into another (so I can perform sliding and scoot back)?

Any help is GREATLY appreciated!!!

BTW, my current way around this is to build a hashmap that gives me a link for each collisionobject to it’s respective entity. I now iterate through all of the manifolds, find the collisionobjects involved, grab the collisionobject-to-entity link in the hashmap, then add the manifold to an array in each entity to be dealt with accordingly.

I’m just not sure that’s an optimized way of doing it. I’m not very familiar with hashmap performance issues if there are any.

You can use get/setUserPointer on CollisionObject for this purpose.

Perfect! Thank you!