Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Static Public Member Functions | Private Attributes
btCollisionDispatcher Class Reference

btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs. Time of Impact, Closest Points and Penetration Depth. More...

#include <btCollisionDispatcher.h>

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

List of all members.

Public Member Functions

void registerCollisionCreateFunc (int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
 registerCollisionCreateFunc allows registration of custom/alternative collision create functions
int getNumManifolds () const
btPersistentManifold ** getInternalManifoldPointer ()
btPersistentManifold * getManifoldByIndexInternal (int index)
const btPersistentManifold * getManifoldByIndexInternal (int index) const
 btCollisionDispatcher (btCollisionConfiguration *collisionConfiguration)
virtual ~btCollisionDispatcher ()
virtual btPersistentManifold * getNewManifold (void *b0, void *b1)
virtual void releaseManifold (btPersistentManifold *manifold)
virtual void clearManifold (btPersistentManifold *manifold)
btCollisionAlgorithmfindAlgorithm (btCollisionObject *body0, btCollisionObject *body1, btPersistentManifold *sharedManifold=0)
virtual bool needsCollision (btCollisionObject *body0, btCollisionObject *body1)
virtual bool needsResponse (btCollisionObject *body0, btCollisionObject *body1)
virtual void dispatchAllCollisionPairs (btOverlappingPairCache *pairCache, btDispatcherInfo &dispatchInfo, btDispatcher *dispatcher)
void setNearCallback (btNearCallback nearCallback)
btNearCallback getNearCallback () const
virtual void * allocateCollisionAlgorithm (int size)
virtual void freeCollisionAlgorithm (void *ptr)
btCollisionConfigurationgetCollisionConfiguration ()
const btCollisionConfigurationgetCollisionConfiguration () const
void setCollisionConfiguration (btCollisionConfiguration *config)

Static Public Member Functions

static void defaultNearCallback (btBroadphasePair &collisionPair, btCollisionDispatcher &dispatcher, btDispatcherInfo &dispatchInfo)

Private Attributes

int m_count
btAlignedObjectArray
< btPersistentManifold * > 
m_manifoldsPtr
bool m_useIslands
bool m_staticWarningReported
btManifoldResult m_defaultManifoldResult
btNearCallback m_nearCallback
btPoolAllocatorm_collisionAlgorithmPoolAllocator
btPoolAllocatorm_persistentManifoldPoolAllocator
btCollisionAlgorithmCreateFuncm_doubleDispatch [MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]
btCollisionConfigurationm_collisionConfiguration

Detailed Description

btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs. Time of Impact, Closest Points and Penetration Depth.

Definition at line 43 of file btCollisionDispatcher.h.


Constructor & Destructor Documentation

Definition at line 36 of file btCollisionDispatcher.cpp.

Here is the call graph for this function:

Definition at line 68 of file btCollisionDispatcher.cpp.

{
}

Member Function Documentation

void * btCollisionDispatcher::allocateCollisionAlgorithm ( int  size) [virtual]

Implements btDispatcher.

Definition at line 275 of file btCollisionDispatcher.cpp.

{
       if (m_collisionAlgorithmPoolAllocator->getFreeCount())
       {
              return m_collisionAlgorithmPoolAllocator->allocate(size);
       }
       
       //warn user for overflow?
       return btAlignedAlloc(size,16);
}

Here is the call graph for this function:

void btCollisionDispatcher::clearManifold ( btPersistentManifold *  manifold) [virtual]

Implements btDispatcher.

Definition at line 99 of file btCollisionDispatcher.cpp.

{
       manifold->clearManifold();
}

Here is the caller graph for this function:

void btCollisionDispatcher::defaultNearCallback ( btBroadphasePair &  collisionPair,
btCollisionDispatcher dispatcher,
btDispatcherInfo dispatchInfo 
) [static]

Definition at line 240 of file btCollisionDispatcher.cpp.

{
              btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
              btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;

              if (dispatcher.needsCollision(colObj0,colObj1))
              {
                     //dispatcher will keep algorithms persistent in the collision pair
                     if (!collisionPair.m_algorithm)
                     {
                            collisionPair.m_algorithm = dispatcher.findAlgorithm(colObj0,colObj1);
                     }

                     if (collisionPair.m_algorithm)
                     {
                            btManifoldResult contactPointResult(colObj0,colObj1);
                            
                            if (dispatchInfo.m_dispatchFunc ==               btDispatcherInfo::DISPATCH_DISCRETE)
                            {
                                   //discrete collision detection query
                                   collisionPair.m_algorithm->processCollision(colObj0,colObj1,dispatchInfo,&contactPointResult);
                            } else
                            {
                                   //continuous collision detection query, time of impact (toi)
                                   btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
                                   if (dispatchInfo.m_timeOfImpact > toi)
                                          dispatchInfo.m_timeOfImpact = toi;

                            }
                     }
              }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void btCollisionDispatcher::dispatchAllCollisionPairs ( btOverlappingPairCache pairCache,
btDispatcherInfo dispatchInfo,
btDispatcher dispatcher 
) [virtual]

Implements btDispatcher.

Definition at line 224 of file btCollisionDispatcher.cpp.

{
       //m_blockedForChanges = true;

       btCollisionPairCallback     collisionCallback(dispatchInfo,this);

       pairCache->processAllOverlappingPairs(&collisionCallback,dispatcher);

       //m_blockedForChanges = false;

}

Here is the call graph for this function:

btCollisionAlgorithm * btCollisionDispatcher::findAlgorithm ( btCollisionObject *  body0,
btCollisionObject *  body1,
btPersistentManifold *  sharedManifold = 0 
) [virtual]

Implements btDispatcher.

Definition at line 132 of file btCollisionDispatcher.cpp.

{
       
       btCollisionAlgorithmConstructionInfo ci;

       ci.m_dispatcher1 = this;
       ci.m_manifold = sharedManifold;
       btCollisionAlgorithm* algo = m_doubleDispatch[body0->getCollisionShape()->getShapeType()][body1->getCollisionShape()->getShapeType()]->CreateCollisionAlgorithm(ci,body0,body1);

       return algo;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void btCollisionDispatcher::freeCollisionAlgorithm ( void *  ptr) [virtual]

Implements btDispatcher.

Definition at line 286 of file btCollisionDispatcher.cpp.

Here is the call graph for this function:

Definition at line 129 of file btCollisionDispatcher.h.

Definition at line 134 of file btCollisionDispatcher.h.

btPersistentManifold** btCollisionDispatcher::getInternalManifoldPointer ( ) [inline, virtual]

Implements btDispatcher.

Definition at line 77 of file btCollisionDispatcher.h.

       {
              return &m_manifoldsPtr[0];
       }
btPersistentManifold* btCollisionDispatcher::getManifoldByIndexInternal ( int  index) [inline, virtual]

Implements btDispatcher.

Definition at line 82 of file btCollisionDispatcher.h.

       {
              return m_manifoldsPtr[index];
       }
const btPersistentManifold* btCollisionDispatcher::getManifoldByIndexInternal ( int  index) const [inline]

Definition at line 87 of file btCollisionDispatcher.h.

       {
              return m_manifoldsPtr[index];
       }

Definition at line 117 of file btCollisionDispatcher.h.

       {
              return m_nearCallback;
       }

Here is the caller graph for this function:

btPersistentManifold * btCollisionDispatcher::getNewManifold ( void *  b0,
void *  b1 
) [virtual]

Implements btDispatcher.

Definition at line 72 of file btCollisionDispatcher.cpp.

{ 
       gNumManifold++;
       
       //btAssert(gNumManifold < 65535);
       

       btCollisionObject* body0 = (btCollisionObject*)b0;
       btCollisionObject* body1 = (btCollisionObject*)b1;
       
       void* mem = 0;
       
       if (m_persistentManifoldPoolAllocator->getFreeCount())
       {
              mem = m_persistentManifoldPoolAllocator->allocate(sizeof(btPersistentManifold));
       } else
       {
              mem = btAlignedAlloc(sizeof(btPersistentManifold),16);

       }
       btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0);
       manifold->m_index1a = m_manifoldsPtr.size();
       m_manifoldsPtr.push_back(manifold);

       return manifold;
}

Here is the call graph for this function:

int btCollisionDispatcher::getNumManifolds ( ) const [inline, virtual]

Implements btDispatcher.

Definition at line 72 of file btCollisionDispatcher.h.

       { 
              return int( m_manifoldsPtr.size());
       }

Here is the call graph for this function:

Here is the caller graph for this function:

bool btCollisionDispatcher::needsCollision ( btCollisionObject *  body0,
btCollisionObject *  body1 
) [virtual]

Implements btDispatcher.

Definition at line 159 of file btCollisionDispatcher.cpp.

{
       assert(body0);
       assert(body1);

       bool needsCollision = true;

#ifdef BT_DEBUG
       if (!m_staticWarningReported)
       {
              //broadphase filtering already deals with this
              if ((body0->isStaticObject() || body0->isKinematicObject()) &&
                     (body1->isStaticObject() || body1->isKinematicObject()))
              {
                     m_staticWarningReported = true;
                     printf("warning btCollisionDispatcher::needsCollision: static-static collision!\n");
              }
       }
#endif //BT_DEBUG

       if ((!body0->isActive()) && (!body1->isActive()))
              needsCollision = false;
       else if (!body0->checkCollideWith(body1))
              needsCollision = false;
       
       return needsCollision ;

}

Here is the caller graph for this function:

bool btCollisionDispatcher::needsResponse ( btCollisionObject *  body0,
btCollisionObject *  body1 
) [virtual]

Implements btDispatcher.

Definition at line 148 of file btCollisionDispatcher.cpp.

{
       //here you can do filtering
       bool hasResponse = 
              (body0->hasContactResponse() && body1->hasContactResponse());
       //no response between two static/kinematic bodies:
       hasResponse = hasResponse &&
              ((!body0->isStaticOrKinematicObject()) ||(! body1->isStaticOrKinematicObject()));
       return hasResponse;
}
void btCollisionDispatcher::registerCollisionCreateFunc ( int  proxyType0,
int  proxyType1,
btCollisionAlgorithmCreateFunc createFunc 
)

registerCollisionCreateFunc allows registration of custom/alternative collision create functions

Definition at line 63 of file btCollisionDispatcher.cpp.

{
       m_doubleDispatch[proxyType0][proxyType1] = createFunc;
}
void btCollisionDispatcher::releaseManifold ( btPersistentManifold *  manifold) [virtual]

Implements btDispatcher.

Definition at line 105 of file btCollisionDispatcher.cpp.

{
       
       gNumManifold--;

       //printf("releaseManifold: gNumManifold %d\n",gNumManifold);
       clearManifold(manifold);

       int findIndex = manifold->m_index1a;
       btAssert(findIndex < m_manifoldsPtr.size());
       m_manifoldsPtr.swap(findIndex,m_manifoldsPtr.size()-1);
       m_manifoldsPtr[findIndex]->m_index1a = findIndex;
       m_manifoldsPtr.pop_back();

       manifold->~btPersistentManifold();
       if (m_persistentManifoldPoolAllocator->validPtr(manifold))
       {
              m_persistentManifoldPoolAllocator->freeMemory(manifold);
       } else
       {
              btAlignedFree(manifold);
       }
       
}

Here is the call graph for this function:

Definition at line 139 of file btCollisionDispatcher.h.

       {
              m_collisionConfiguration = config;
       }
void btCollisionDispatcher::setNearCallback ( btNearCallback  nearCallback) [inline]

Definition at line 112 of file btCollisionDispatcher.h.

       {
              m_nearCallback = nearCallback; 
       }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 57 of file btCollisionDispatcher.h.

Definition at line 64 of file btCollisionDispatcher.h.

Definition at line 45 of file btCollisionDispatcher.h.

Definition at line 53 of file btCollisionDispatcher.h.

Definition at line 61 of file btCollisionDispatcher.h.

Definition at line 47 of file btCollisionDispatcher.h.

Definition at line 55 of file btCollisionDispatcher.h.

Definition at line 59 of file btCollisionDispatcher.h.

Definition at line 51 of file btCollisionDispatcher.h.

Definition at line 49 of file btCollisionDispatcher.h.


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