kinematic issue again
Posted: Thu Nov 08, 2007 4:03 pm
I'm using ConcavePhysicsDemo.ccp with the following modification inside shootTrimesh():
mass =0.f;
body->setCollisionFlags( body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT );
body->setActivationState(DISABLE_DEACTIVATION);
and the follwing function called just after renderme() in clientMoveAndDisplay():
void ConcaveDemo::updateExtMesh()
{
int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds();
for( int j = 0; j < numManifolds; j++ )
{
// Get collision structures
btPersistentManifold* contactManifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(j);
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 k = 0; k < numContacts; k++ )
{
btManifoldPoint& pt = contactManifold->getContactPoint(k);
// Get contact points
btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
btVector3 normal = pt.m_normalWorldOnB;
btVector3 vel;
if( obA->isKinematicObject() && obB->isStaticObject() )
std::cout << "B STATIC vs A KINEMATIC" << std::endl;
if( obB->isKinematicObject() && obA->isStaticObject() )
std::cout << "A STATIC vs B KINEMATIC" << std::endl;
if( obA->isKinematicObject() && (obB->isStaticOrKinematicObject() == false) )
std::cout << "B DYNAMIC vs A KINEMATIC" << std::endl;
if( obB->isKinematicObject() && (obA->isStaticOrKinematicObject() == false) )
std::cout << "A DYNAMIC vs B KINEMATIC" << std::endl;
}
}
}
The result is totally non-deterministic: when I shoot blocks (with the right button) against the bunny even though they always realistically collide, sometimes I get one of the messages, sometimes not, and also it happens to continue to get them when the collision is over. Has someone got a solution/explanation for this?
Thanks,
Alessio
mass =0.f;
body->setCollisionFlags( body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT );
body->setActivationState(DISABLE_DEACTIVATION);
and the follwing function called just after renderme() in clientMoveAndDisplay():
void ConcaveDemo::updateExtMesh()
{
int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds();
for( int j = 0; j < numManifolds; j++ )
{
// Get collision structures
btPersistentManifold* contactManifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(j);
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 k = 0; k < numContacts; k++ )
{
btManifoldPoint& pt = contactManifold->getContactPoint(k);
// Get contact points
btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
btVector3 normal = pt.m_normalWorldOnB;
btVector3 vel;
if( obA->isKinematicObject() && obB->isStaticObject() )
std::cout << "B STATIC vs A KINEMATIC" << std::endl;
if( obB->isKinematicObject() && obA->isStaticObject() )
std::cout << "A STATIC vs B KINEMATIC" << std::endl;
if( obA->isKinematicObject() && (obB->isStaticOrKinematicObject() == false) )
std::cout << "B DYNAMIC vs A KINEMATIC" << std::endl;
if( obB->isKinematicObject() && (obA->isStaticOrKinematicObject() == false) )
std::cout << "A DYNAMIC vs B KINEMATIC" << std::endl;
}
}
}
The result is totally non-deterministic: when I shoot blocks (with the right button) against the bunny even though they always realistically collide, sometimes I get one of the messages, sometimes not, and also it happens to continue to get them when the collision is over. Has someone got a solution/explanation for this?
Thanks,
Alessio