entropyExplorer wrote:So, at first, I'm going to take all the aabb's from the OTHER physics engine and test to see what objects they are in collision with in BULLET. I do not want to create a rigidbody in Bullet that represents the objects in the OTHER physics engine, so I'm only testing to see if their(objects from the foreign engine) aabb's are in collision with bullet objects.
Well, aabbTest(...) does not require a btRigidBody/btCollisionObject to be present, so it should work in your case. The problem is that aabbTest(...) is a broadphase test, and so it will report false positives (there is a contactTest(...) method for the narrowphase, but it needs a btCollisionShape inside a btCollisionObject to work).
On a closer look, about the implementation, I think that the btBroadphaseAabbCallback can be simplified a lot in this way:
Code: Select all
struct btMyBroadphaseAabbCallback : public btBroadphaseAabbCallback {
btAlignedObjectArray < btCollisionObject* >& m_collisionObjectArray;
short int m_collisionFilterGroup, m_collisionFilterMask;// Optional
btMyBroadphaseAabbCallback(btAlignedObjectArray < btCollisionObject* >& collisionObjectArray, short int collisionGroup=btBroadphaseProxy::DefaultFilter, short int collisionMask=btBroadphaseProxy::AllFilter) :
m_collisionObjectArray(collisionObjectArray), m_collisionFilterGroup(collisionGroup), m_collisionFilterMask(collisionMask)
{
m_collisionObjectArray.resize(0);
}
// Optional:
SIMD_FORCE_INLINE bool needsCollision(const btBroadphaseProxy* proxy) const {
bool collides = (proxy->m_collisionFilterGroup & m_collisionFilterMask) != 0;
collides = collides && (m_collisionFilterGroup & proxy->m_collisionFilterMask);
return collides;
}
virtual bool process (const btBroadphaseProxy *proxy) {
// Basically this is the only method to implement in btBroadphaseAabbCallback.
// If we don't need any filtering/excluding objects, we can just write:
// m_collisionObjectArray.push_back((btCollisionObject *)proxy->m_clientObject);return true;
// and we're done
if (needsCollision(proxy)) m_collisionObjectArray.push_back((btCollisionObject *)proxy->m_clientObject);
return true;
}
};
// Usage:
btAlignedObjectArray < btCollisionObject* > collisionObjectArray;
btMyBroadphaseAabbCallback callback(collisionObjectArray);
m_dynamicsWorld->getBroadphase()->aabbTest(min,max,callback);
// Now collisionObjectArray should be filled.
As you can see, the filtering is completely optional (and in the link I posted a collision object to exclude was present too). The only method to override is the 'process(...)' method.
PS. It might seem strange, but I've never used the above code myself, so I hope it works...
