|
本帖最后由 srrew 于 2014-5-26 18:05 编辑
我把我的两个模型(上图中分别表示为黄色和蓝色)的node转换成了btConvexHullShape,初始化collision world的代码为:
_collisionConfiguration = new btDefaultCollisionConfiguration();
_dispatcher = new btCollisionDispatcher(_collisionConfiguration);
_solver = new btSequentialImpulseConstraintSolver;
_broadphase = new btDbvtBroadphase();
_collisionWorld = new btDiscreteDynamicsWorld(_dispatcher, _broadphase, _solver , _collisionConfiguration);
_debugDrawer = new CollisionDebugDrawer();
_collisionWorld->setDebugDrawer(_debugDrawer);
两个node本身只是在边界上有线重合,而osgBullet却检测到了碰撞,但这种情况是我不需要的碰撞。
判定碰撞的代码为:
unsigned int numManifolds = _collisionWorld->getDispatcher()->getNumManifolds();
for (unsigned int i = 0; i < numManifolds; i++)
{
btPersistentManifold* contactManifold = _collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
unsigned int numContacts = contactManifold->getNumContacts();
for (unsigned int j = 0; j < numContacts; j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
if (pt.getDistance() <= 0.f)
{
// I think there is a collision here
.....
}
}
}
我应该怎么更改代码来过滤掉这种两个node只有边界重合的情况呢? |
|