Back to index

supertuxkart  0.5+dfsg1
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
btCompoundCollisionAlgorithm Class Reference

btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes Place holder, not fully implemented yet More...

#include <btCompoundCollisionAlgorithm.h>

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

List of all members.

Classes

struct  CreateFunc
struct  SwappedCreateFunc

Public Member Functions

 btCompoundCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo &ci, btCollisionObject *body0, btCollisionObject *body1, bool isSwapped)
virtual ~btCompoundCollisionAlgorithm ()
virtual void processCollision (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btScalar calculateTimeOfImpact (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)

Protected Member Functions

int getDispatcherId ()

Protected Attributes

btDispatcherm_dispatcher

Private Attributes

btAlignedObjectArray
< btCollisionAlgorithm * > 
m_childCollisionAlgorithms
bool m_isSwapped

Detailed Description

btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes Place holder, not fully implemented yet

Definition at line 32 of file btCompoundCollisionAlgorithm.h.


Constructor & Destructor Documentation

btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm ( const btCollisionAlgorithmConstructionInfo ci,
btCollisionObject *  body0,
btCollisionObject *  body1,
bool  isSwapped 
)

Definition at line 21 of file btCompoundCollisionAlgorithm.cpp.

:btCollisionAlgorithm(ci),
m_isSwapped(isSwapped)
{
       btCollisionObject* colObj = m_isSwapped? body1 : body0;
       btCollisionObject* otherObj = m_isSwapped? body0 : body1;
       assert (colObj->getCollisionShape()->isCompound());
       
       btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
       int numChildren = compoundShape->getNumChildShapes();
       int i;
       
       m_childCollisionAlgorithms.resize(numChildren);
       for (i=0;i<numChildren;i++)
       {
              btCollisionShape* childShape = compoundShape->getChildShape(i);
              btCollisionShape* orgShape = colObj->getCollisionShape();
              colObj->setCollisionShape( childShape );
              m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj);
              colObj->setCollisionShape( orgShape );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 45 of file btCompoundCollisionAlgorithm.cpp.

{
       int numChildren = m_childCollisionAlgorithms.size();
       int i;
       for (i=0;i<numChildren;i++)
       {
              m_childCollisionAlgorithms[i]->~btCollisionAlgorithm();
              m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]);
       }
}

Here is the call graph for this function:


Member Function Documentation

btScalar btCompoundCollisionAlgorithm::calculateTimeOfImpact ( btCollisionObject *  body0,
btCollisionObject *  body1,
const btDispatcherInfo dispatchInfo,
btManifoldResult resultOut 
) [virtual]

Implements btCollisionAlgorithm.

Definition at line 94 of file btCompoundCollisionAlgorithm.cpp.

{

       btCollisionObject* colObj = m_isSwapped? body1 : body0;
       btCollisionObject* otherObj = m_isSwapped? body0 : body1;

       assert (colObj->getCollisionShape()->isCompound());
       
       btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());

       //We will use the OptimizedBVH, AABB tree to cull potential child-overlaps
       //If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals
       //given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means:
       //determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1
       //then use each overlapping node AABB against Tree0
       //and vise versa.

       btScalar hitFraction = btScalar(1.);

       int numChildren = m_childCollisionAlgorithms.size();
       int i;
       for (i=0;i<numChildren;i++)
       {
              //temporarily exchange parent btCollisionShape with childShape, and recurse
              btCollisionShape* childShape = compoundShape->getChildShape(i);

              //backup
              btTransform   orgTrans = colObj->getWorldTransform();
              btCollisionShape* orgShape = colObj->getCollisionShape();

              const btTransform& childTrans = compoundShape->getChildTransform(i);
              //btTransform newChildWorldTrans = orgTrans*childTrans ;
              colObj->setWorldTransform( orgTrans*childTrans );

              colObj->setCollisionShape( childShape );
              btScalar frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut);
              if (frac<hitFraction)
              {
                     hitFraction = frac;
              }
              //revert back
              colObj->setCollisionShape( orgShape);
              colObj->setWorldTransform( orgTrans);
       }
       return hitFraction;

}

Here is the call graph for this function:

int btCollisionAlgorithm::getDispatcherId ( ) [protected, inherited]
void btCompoundCollisionAlgorithm::processCollision ( btCollisionObject *  body0,
btCollisionObject *  body1,
const btDispatcherInfo dispatchInfo,
btManifoldResult resultOut 
) [virtual]

Implements btCollisionAlgorithm.

Definition at line 56 of file btCompoundCollisionAlgorithm.cpp.

{
       btCollisionObject* colObj = m_isSwapped? body1 : body0;
       btCollisionObject* otherObj = m_isSwapped? body0 : body1;

       assert (colObj->getCollisionShape()->isCompound());
       btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());

       //We will use the OptimizedBVH, AABB tree to cull potential child-overlaps
       //If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals
       //given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means:
       //determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1
       //then use each overlapping node AABB against Tree0
       //and vise versa.

       int numChildren = m_childCollisionAlgorithms.size();
       int i;
       for (i=0;i<numChildren;i++)
       {
              //temporarily exchange parent btCollisionShape with childShape, and recurse
              btCollisionShape* childShape = compoundShape->getChildShape(i);

              //backup
              btTransform   orgTrans = colObj->getWorldTransform();
              btCollisionShape* orgShape = colObj->getCollisionShape();

              const btTransform& childTrans = compoundShape->getChildTransform(i);
              //btTransform newChildWorldTrans = orgTrans*childTrans ;
              colObj->setWorldTransform( orgTrans*childTrans );
              //the contactpoint is still projected back using the original inverted worldtrans
              colObj->setCollisionShape( childShape );
              m_childCollisionAlgorithms[i]->processCollision(colObj,otherObj,dispatchInfo,resultOut);
              //revert back
              colObj->setCollisionShape( orgShape);
              colObj->setWorldTransform(  orgTrans );
       }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 34 of file btCompoundCollisionAlgorithm.h.

Definition at line 57 of file btCollisionAlgorithm.h.

Definition at line 35 of file btCompoundCollisionAlgorithm.h.


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