Hi,
It seems that there's no direct AABB checking API (Correct me if I'm wrong). So I'm using btGhostObject to iterate over all objects within ghost's shape at every simulation step. For AABB only, you can remove iteration code related to narrowphase and manifold iteration.
With a ghost object you can iterate something like this:
Code:
void OverlapAABB(btPairCachingGhostObject* ghost, std::vector<btCollisionObject*>& results)
{
btBroadphasePairArray& pairs = ghost->getOverlappingPairCache()->getOverlappingPairArray();
for (int i=0; i<pairs.size(); ++i)
{
const btBroadphasePair& pair = pairs[i];
btBroadphaseProxy* proxy = pair.m_pProxy0->m_ClientObject != ghost ? pair.m_pProxy0 : pair.m_pProxy1;
btCollisionObject* obj = (btCollisionObject*)proxy->m_clientObject;
// Now you have one object. Do something here
results.push_back(obj); // <-- this is just an example.
}
}
This is similar to wiki page describing btGhostObject, except that broadphase with AABB takes place only, which means other than the broadphase pair caching (the thing you point as 'internal space partitioning'), there's no additional calculations.
Note that a ghost object should be added to world prior, but simulationStep() may need not be called. (pair caching is occurred during addCollisionObject())
In other word, one time checking possible like:
Code:
world->addCollisionObject(ghost);
OverlapAABB(ghost, results);
world->removeCollisionObject(ghost);
I had about 2000 objects (static, dynamic) and 20~30 ghosts. In my case, it was a lot faster using this than checking every object in world.
(One thing to care about is that I had to carefully adjust collision group and filter to speed up even further.)
Thanks