I use a BtGhostObject for my character and i want that my BtGhostObject collide with rigidBody and others BtGhostObject
so I try the collision test here http://www.bulletphysics.org/mediawiki- ... d_Triggers (2) btGhostObject).
It works but the collision test always give me Heightmap when i do manifold->getBody1(). there is already collision between BtGostObject and Heightmap so I want to exclude Heightmap from that test.
I try this:
Code: Select all
for (int j = 0; j<m_manifoldArray.size(); j++)
{
btPersistentManifold* manifold = m_manifoldArray[j];
btScalar directionSign = manifold->getBody0() == m_ghostObject ? btScalar(-1.0) : btScalar(1.0);
std::string *str = (std::string*)manifold->getBody1()->getCollisionShape()->getUserPointer();
if (*str!= "Heightmap"){
for (int p = 0; p < manifold->getNumContacts(); p++)
{
const btManifoldPoint&pt = manifold->getContactPoint(p);
if (pt.getDistance() < 0.f)
{
const btVector3& ptA = pt.getPositionWorldOnA();
const btVector3& ptB = pt.getPositionWorldOnB();
const btVector3& normalOnB = pt.m_normalWorldOnB;
//Move character out of intersection
btVector3 pos = m_ghostObject->getWorldTransform().getOrigin();
pos -= btVector3(0, pt.getDistance(), 0);
pos *= pt.m_normalWorldOnB;
m_ghostObject->getWorldTransform().setOrigin(btVector3(pos.x(), m_ghostObject->getWorldTransform().getOrigin().y(), pos.z()));
}
}
}
}
I thought about to use collision mask but I don't want my BtGhostObject cross throught the ground.
So what is the solution ?
A++