Code: Select all
btCollisionObject* obja = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* objb = static_cast<btCollisionObject*>(contactManifold->getBody1());
btVector3 aPos = obja->getWorldTransform().getOrigin();
btVector3 bPos = objb->getWorldTransform().getOrigin();
btAlignedObjectArray<btCollisionObject*> collisionBodies = collisionWorld->getCollisionObjectArray();
int index1 = collisionBodies.findBinarySearch(obja);
int index2 = collisionBodies.findBinarySearch(objb);
My application requires me to detect which boxes are colliding with each other and then save their 'IDs'. So is there some way to be able to always access 'object 1' for example using collisionBodies[1] such that this would always refer to the same box regardless of its new position in the world or its collisions? I don't understand how the objects are ordered in that array and would appreciate any clarification. Thanks a lot.
Regards,
Nick