Kinenatics and collision detection

noon
Posts: 6
Joined: Wed Jun 01, 2011 1:05 am

Kinenatics and collision detection

Post by noon »

Hello,

I'm trying to get collision information between :
- Kinematic VS Static
- Kinematic VS Kinematic

Here is the code:

Create kinematic object:

Code: Select all

btCollisionShape* shape = new btCapsuleShape(0.2f, 0.5f);
m_motionState = new MyMotionState();
btRigidBody::btRigidBodyConstructionInfo rigidInfo(0, m_motionState, shape, btVector3(0, 0, 0));
m_RigidBody = new btRigidBody(rigidInfo);
m_RigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_NO_CONTACT_RESPONSE);
m_RigidBody->setActivationState(DISABLE_DEACTIVATION)
Step Simulation and check collisions:

Code: Select all

m_dynamicsWorld->stepSimulation(deltaTime, subStep, fixedTimeStep);

btDispatcher* dispatcher = m_dynamicsWorld->getDispatcher();
int numManifolds = dispatcher->getNumManifolds();
for (int i = 0; i < numManifolds; ++i)
{
    btPersistentManifold* contactManifold = dispatcher->getManifoldByIndexInternal(i);
    btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
    btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
}
I do not get any contactManifold. (I do not enter the for loop)
If instead I create a normal rigid body (remove the flags and give a mass > 0), I do get contactManifold.

Any idea ?

Thanks !
noon
Posts: 6
Joined: Wed Jun 01, 2011 1:05 am

Re: Kinenatics and collision detection

Post by noon »

No idea ? Anyone ?
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Kinenatics and collision detection

Post by Flix »

noon wrote:I'm trying to get collision information between :
- Kinematic VS Static
- Kinematic VS Kinematic
Excluding soft bodies, collisions are reported only between rigid and static/kinematic bodies.
...maybe you can set one of the two bodies to dynamic and apply to it a very big mass an a zero-vector inertia tensor.

P.S. As far as I know, the only way to detect collisions between two "static" bodies is to use a ghost object approach (see the kinematic character controller, that inherits from a ghost object and can detect collisions with both dynamic and static objects), but this solution is not very easy to implement (manual collision resolving).

That's all I know, good luck :?
noon
Posts: 6
Joined: Wed Jun 01, 2011 1:05 am

Re: Kinenatics and collision detection

Post by noon »

Thanks for the help !