at first i like to thank you for making this wonderful lib and releasing it to the public.
i'm trying to use bullet for collision detection in my current project, but i'm having some problems with resolving the collisions right.
in my project, you control a character though a 3d world using the keyboard, so the characters (a btCylinderShape right now) position gets updated every frame and then collision detection is performed.
this is how i try to resolve the collisions now (i've taken that from the collisionInterfaceDemo):
Code: Select all
mCollisionWorld->performDiscreteCollisionDetection();
int numManifolds = mCollisionWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = mCollisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
contactManifold->refreshContactPoints(obA->getWorldTransform(),obB->getWorldTransform());
int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
btVector3 translate = pt.m_normalWorldOnB * (-pt.getDistance());
//apply translate Vector to ObjectA
}
}
so my question is, is there anything wrong with the above code? or is it bettewr to use the dynamics part of bullet for that? i'm a totally newb on both, 3d and physics.