I have been searching on the forum for answers to these questions, but could not find them.
I feel a bit silly, because I know these are basic questions... anyway here goes:
(Question 1)
I keep reading everywhere that btRigidBody is derived from btCollisionObject.
There should be an easy way to know which btRigidBody is linked to which btCollisionObject, but I cant find it.
I create my bodies using:
Code: Select all
Bullet_Objects[id].rigidBody = btRigidBody(mass, defaultmotionState, colShape, local_inertia);
m_dynamicsWorld->addRigidBody(&Bullet_Objects[id].rigidBody);
Code: Select all
int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds();
for (int i=0; i<numManifolds; i++)
{
btPersistentManifold* contactManifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
}
So, in the code above how can I find out the "id", in my array Bullet_Objects[id].rigidBody, of obA and obB?
(Question 2)
I know how to step through the simulation using m_dynamicsWorld->stepSimulation.
But how can I make instant collision detections using m_dynamicsWorld?
My reason for this is that I want to add objects, but I want to make sure they do not collide with existing objects, otherwise I create a "mini" explosion.
(Question 3)
The contact manifold tells me which object are currently in contact with each other, and at which points.
But how do I find out if 2 objects collided at speed?
This is because i want to play sound effects when I get collisions between say 2 wooden crates.
Thanks in advance for your help!