It looks like you are using spaces to perform collision filtering (exclude collisions using some condition, in your case if they are in the same space).
The easiest is to use collision group and mask, but then you can only have a limited number of vehicles.
Another solution is to create your custom collision filter and assign it to the broadphase using setOverlapFilterCallback(btOverlapFilterCallback* callback).
Just derive a class from btOverlapFilterCallback and implement needsBroadphaseCollision, with your custom rules.
Here is the default implementation:
Code: Select all
inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
{
if (m_overlapFilterCallback)
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
return collides;
}
One way to recognize that a vehicle part is colliding against a part of the same vehicle is by using user pointer stored in the btRigidBody, and store the information there.
(you can access the btRigidBody from the broadphase proxy)
I wouldn't worry about performance implications, the default btDbvtBroadphase is pretty well optimized. Unlike OpenDE, Bullet's overlapping pairs are incrementally added and removed, so there are no duplicate checks.
Hope this helps,
Erwin