Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Protected Attributes
btSortedOverlappingPairCache Class Reference

btSortedOverlappingPairCache maintains the objects with overlapping AABB Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase More...

#include <btOverlappingPairCache.h>

Inheritance diagram for btSortedOverlappingPairCache:
Inheritance graph
[legend]
Collaboration diagram for btSortedOverlappingPairCache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 btSortedOverlappingPairCache ()
virtual ~btSortedOverlappingPairCache ()
virtual void processAllOverlappingPairs (btOverlapCallback *, btDispatcher *dispatcher)
void * removeOverlappingPair (btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1, btDispatcher *dispatcher)
void cleanOverlappingPair (btBroadphasePair &pair, btDispatcher *dispatcher)
btBroadphasePair * addOverlappingPair (btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
btBroadphasePair * findPair (btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
 this findPair becomes really slow. Either sort the list to speedup the query, or use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed. we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address) Also we can use a 2D bitmap, which can be useful for a future GPU implementation
void cleanProxyFromPairs (btBroadphaseProxy *proxy, btDispatcher *dispatcher)
void removeOverlappingPairsContainingProxy (btBroadphaseProxy *proxy, btDispatcher *dispatcher)
bool needsBroadphaseCollision (btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1) const
btBroadphasePairArraygetOverlappingPairArray ()
const btBroadphasePairArraygetOverlappingPairArray () const
btBroadphasePair * getOverlappingPairArrayPtr ()
const btBroadphasePair * getOverlappingPairArrayPtr () const
int getNumOverlappingPairs () const
btOverlapFilterCallbackgetOverlapFilterCallback ()
void setOverlapFilterCallback (btOverlapFilterCallback *callback)
virtual bool hasDeferredRemoval ()

Protected Attributes

btBroadphasePairArray m_overlappingPairArray
bool m_blockedForChanges
bool m_hasDeferredRemoval
 by default, do the removal during the pair traversal
btOverlapFilterCallbackm_overlapFilterCallback

Detailed Description

btSortedOverlappingPairCache maintains the objects with overlapping AABB Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase

Definition at line 265 of file btOverlappingPairCache.h.


Constructor & Destructor Documentation

Definition at line 481 of file btOverlappingPairCache.cpp.

                                                          :
       m_overlapFilterCallback(0),
       m_blockedForChanges(false),
       m_hasDeferredRemoval(true)
{
       int initialAllocatedSize= 2;
       m_overlappingPairArray.reserve(initialAllocatedSize);
}

Here is the call graph for this function:

Definition at line 490 of file btOverlappingPairCache.cpp.

{
       //todo/test: show we erase/delete data, or is it automatic
}

Member Function Documentation

btBroadphasePair * btSortedOverlappingPairCache::addOverlappingPair ( btBroadphaseProxy *  proxy0,
btBroadphaseProxy *  proxy1 
) [virtual]

Implements btOverlappingPairCallback.

Definition at line 408 of file btOverlappingPairCache.cpp.

{
       //don't add overlap with own
       assert(proxy0 != proxy1);

       if (!needsBroadphaseCollision(proxy0,proxy1))
              return 0;
       
       void* mem = &m_overlappingPairArray.expand();
       btBroadphasePair* pair = new (mem) btBroadphasePair(*proxy0,*proxy1);
       gOverlappingPairs++;
       return pair;
       
}

Here is the call graph for this function:

void btSortedOverlappingPairCache::cleanOverlappingPair ( btBroadphasePair &  pair,
btDispatcher dispatcher 
) [virtual]

Implements btOverlappingPairCache.

Definition at line 495 of file btOverlappingPairCache.cpp.

{
       if (pair.m_algorithm)
       {
              {
                     pair.m_algorithm->~btCollisionAlgorithm();
                     dispatcher->freeCollisionAlgorithm(pair.m_algorithm);
                     pair.m_algorithm=0;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void btSortedOverlappingPairCache::cleanProxyFromPairs ( btBroadphaseProxy *  proxy,
btDispatcher dispatcher 
) [virtual]

Implements btOverlappingPairCache.

Definition at line 508 of file btOverlappingPairCache.cpp.

{

       class  CleanPairCallback : public btOverlapCallback
       {
              btBroadphaseProxy* m_cleanProxy;
              btOverlappingPairCache*     m_pairCache;
              btDispatcher* m_dispatcher;

       public:
              CleanPairCallback(btBroadphaseProxy* cleanProxy,btOverlappingPairCache* pairCache,btDispatcher* dispatcher)
                     :m_cleanProxy(cleanProxy),
                     m_pairCache(pairCache),
                     m_dispatcher(dispatcher)
              {
              }
              virtual       bool   processOverlap(btBroadphasePair& pair)
              {
                     if ((pair.m_pProxy0 == m_cleanProxy) ||
                            (pair.m_pProxy1 == m_cleanProxy))
                     {
                            m_pairCache->cleanOverlappingPair(pair,m_dispatcher);
                     }
                     return false;
              }
              
       };

       CleanPairCallback cleanPairs(proxy,this,dispatcher);

       processAllOverlappingPairs(&cleanPairs,dispatcher);

}

Here is the call graph for this function:

btBroadphasePair * btSortedOverlappingPairCache::findPair ( btBroadphaseProxy *  proxy0,
btBroadphaseProxy *  proxy1 
) [virtual]

this findPair becomes really slow. Either sort the list to speedup the query, or use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed. we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address) Also we can use a 2D bitmap, which can be useful for a future GPU implementation

Implements btOverlappingPairCache.

Definition at line 427 of file btOverlappingPairCache.cpp.

{
       if (!needsBroadphaseCollision(proxy0,proxy1))
              return 0;

       btBroadphasePair tmpPair(*proxy0,*proxy1);
       int findIndex = m_overlappingPairArray.findLinearSearch(tmpPair);

       if (findIndex < m_overlappingPairArray.size())
       {
              //assert(it != m_overlappingPairSet.end());
               btBroadphasePair* pair = &m_overlappingPairArray[findIndex];
              return pair;
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements btOverlappingPairCache.

Definition at line 335 of file btOverlappingPairCache.h.

Here is the call graph for this function:

Definition at line 340 of file btOverlappingPairCache.h.

Implements btOverlappingPairCache.

Definition at line 312 of file btOverlappingPairCache.h.

Definition at line 317 of file btOverlappingPairCache.h.

btBroadphasePair* btSortedOverlappingPairCache::getOverlappingPairArrayPtr ( ) [inline, virtual]

Implements btOverlappingPairCache.

Definition at line 325 of file btOverlappingPairCache.h.

              {
                     return &m_overlappingPairArray[0];
              }
const btBroadphasePair* btSortedOverlappingPairCache::getOverlappingPairArrayPtr ( ) const [inline, virtual]

Implements btOverlappingPairCache.

Definition at line 330 of file btOverlappingPairCache.h.

              {
                     return &m_overlappingPairArray[0];
              }
virtual bool btSortedOverlappingPairCache::hasDeferredRemoval ( ) [inline, virtual]

Implements btOverlappingPairCache.

Definition at line 350 of file btOverlappingPairCache.h.

              {
                     return m_hasDeferredRemoval;
              }

Here is the caller graph for this function:

bool btSortedOverlappingPairCache::needsBroadphaseCollision ( btBroadphaseProxy *  proxy0,
btBroadphaseProxy *  proxy1 
) const [inline]

Definition at line 301 of file btOverlappingPairCache.h.

              {
                     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;
              }

Here is the call graph for this function:

Here is the caller graph for this function:

Implements btOverlappingPairCache.

Definition at line 455 of file btOverlappingPairCache.cpp.

{

       int i;

       for (i=0;i<m_overlappingPairArray.size();)
       {
       
              btBroadphasePair* pair = &m_overlappingPairArray[i];
              if (callback->processOverlap(*pair))
              {
                     cleanOverlappingPair(*pair,dispatcher);

                     m_overlappingPairArray.swap(i,m_overlappingPairArray.capacity()-1);
                     m_overlappingPairArray.pop_back();
                     gOverlappingPairs--;
              } else
              {
                     i++;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void * btSortedOverlappingPairCache::removeOverlappingPair ( btBroadphaseProxy *  proxy0,
btBroadphaseProxy *  proxy1,
btDispatcher dispatcher 
) [virtual]

Implements btOverlappingPairCallback.

Definition at line 378 of file btOverlappingPairCache.cpp.

{
       if (!hasDeferredRemoval())
       {
              btBroadphasePair findPair(*proxy0,*proxy1);

              int findIndex = m_overlappingPairArray.findLinearSearch(findPair);
              if (findIndex < m_overlappingPairArray.size())
              {
                     gOverlappingPairs--;
                     btBroadphasePair& pair = m_overlappingPairArray[findIndex];
                     void* userData = pair.m_userInfo;
                     cleanOverlappingPair(pair,dispatcher);
                     
                     m_overlappingPairArray.swap(findIndex,m_overlappingPairArray.capacity()-1);
                     m_overlappingPairArray.pop_back();
                     return userData;
              }
       }

       return 0;
}

Here is the call graph for this function:

void btSortedOverlappingPairCache::removeOverlappingPairsContainingProxy ( btBroadphaseProxy *  proxy,
btDispatcher dispatcher 
) [virtual]

Implements btOverlappingPairCallback.

Definition at line 543 of file btOverlappingPairCache.cpp.

{

       class  RemovePairCallback : public btOverlapCallback
       {
              btBroadphaseProxy* m_obsoleteProxy;

       public:
              RemovePairCallback(btBroadphaseProxy* obsoleteProxy)
                     :m_obsoleteProxy(obsoleteProxy)
              {
              }
              virtual       bool   processOverlap(btBroadphasePair& pair)
              {
                     return ((pair.m_pProxy0 == m_obsoleteProxy) ||
                            (pair.m_pProxy1 == m_obsoleteProxy));
              }
              
       };

       RemovePairCallback removeCallback(proxy);

       processAllOverlappingPairs(&removeCallback,dispatcher);
}

Here is the call graph for this function:

Implements btOverlappingPairCache.

Definition at line 345 of file btOverlappingPairCache.h.

              {
                     m_overlapFilterCallback = callback;
              }

Member Data Documentation

Definition at line 272 of file btOverlappingPairCache.h.

by default, do the removal during the pair traversal

Definition at line 275 of file btOverlappingPairCache.h.

Definition at line 278 of file btOverlappingPairCache.h.

Definition at line 269 of file btOverlappingPairCache.h.


The documentation for this class was generated from the following files: