How to clear all pairs in btOverlappingPairCache ?

User avatar
johnny_sun
Posts: 3
Joined: Wed May 04, 2011 7:19 am

How to clear all pairs in btOverlappingPairCache ?

Post by johnny_sun »

In calculateOverlappingPairs process, addOverlappingPair or removeOverlappingPair must first findPair, whether directly clear pairCache before calculateOverlappingPairs ?
Mr.Orange
Posts: 11
Joined: Mon Apr 18, 2011 10:03 am

Re: How to clear all pairs in btOverlappingPairCache ?

Post by Mr.Orange »

Hi johnny_sun!

I'm not sure if I got your question properly, but If you want to clear your overlapping pair cache, you can iterate over your collision objects and delete them from the proxy:

Code: Select all

for (unsigned int i=0; i<rigidBodies.size(); i++) // get the number of rigid bodies of your simulation somehow, i store their references in an array...
{
   btRigidBody* currentRigidBody = rigidBodies[i];
   if (dynamicsWorld->getBroadphase()->getOverlappingPairCache())
			dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(currentRigidBody->getBroadphaseHandle(),dynamicsWorld->getDispatcher());
}
Hope I could help!
Cya,
Mr.Orange
User avatar
johnny_sun
Posts: 3
Joined: Wed May 04, 2011 7:19 am

Re: How to clear all pairs in btOverlappingPairCache ?

Post by johnny_sun »

Hi, Mr.Orange.

Your code can achieve the functions I need. I mean the beginning of each loop empty the overlappingPairCache, can avoid a lot of times findPair, may be able to improve efficiency.

Thank you very much.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: How to clear all pairs in btOverlappingPairCache ?

Post by Erwin Coumans »

Bullet keeps information in the pairs, such as contact points and warm starting information for the constraint solver (previous frames applied impulse). So generally it is not a good idea to clear the pair cache.

Thanks,
Erwin