Back to index

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

btSphereBoxCollisionAlgorithm provides sphere-box collision detection. Other features are frame-coherency (persistent data) and collision response. More...

#include <btConvexPlaneCollisionAlgorithm.h>

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

List of all members.

Classes

struct  CreateFunc

Public Member Functions

 btConvexPlaneCollisionAlgorithm (btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, btCollisionObject *col0, btCollisionObject *col1, bool isSwapped)
virtual ~btConvexPlaneCollisionAlgorithm ()
virtual void processCollision (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual btScalar calculateTimeOfImpact (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)

Protected Member Functions

int getDispatcherId ()

Protected Attributes

btDispatcherm_dispatcher

Private Attributes

bool m_ownManifold
btPersistentManifold * m_manifoldPtr
bool m_isSwapped

Detailed Description

btSphereBoxCollisionAlgorithm provides sphere-box collision detection. Other features are frame-coherency (persistent data) and collision response.

Definition at line 29 of file btConvexPlaneCollisionAlgorithm.h.


Constructor & Destructor Documentation

btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm ( btPersistentManifold *  mf,
const btCollisionAlgorithmConstructionInfo ci,
btCollisionObject *  col0,
btCollisionObject *  col1,
bool  isSwapped 
)

Definition at line 25 of file btConvexPlaneCollisionAlgorithm.cpp.

: btCollisionAlgorithm(ci),
m_ownManifold(false),
m_manifoldPtr(mf),
m_isSwapped(isSwapped)
{
       btCollisionObject* convexObj = m_isSwapped? col1 : col0;
       btCollisionObject* planeObj = m_isSwapped? col0 : col1;
       
       if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj))
       {
              m_manifoldPtr = m_dispatcher->getNewManifold(convexObj,planeObj);
              m_ownManifold = true;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 42 of file btConvexPlaneCollisionAlgorithm.cpp.

Here is the call graph for this function:


Member Function Documentation

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

Implements btCollisionAlgorithm.

Definition at line 99 of file btConvexPlaneCollisionAlgorithm.cpp.

{
       (void)resultOut;
       (void)dispatchInfo;
       (void)col0;
       (void)col1;

       //not yet
       return btScalar(1.);
}
int btCollisionAlgorithm::getDispatcherId ( ) [protected, inherited]
void btConvexPlaneCollisionAlgorithm::processCollision ( btCollisionObject *  body0,
btCollisionObject *  body1,
const btDispatcherInfo dispatchInfo,
btManifoldResult resultOut 
) [virtual]

report a contact. internally this will be kept persistent, and contact reduction is done

Implements btCollisionAlgorithm.

Definition at line 53 of file btConvexPlaneCollisionAlgorithm.cpp.

{
       (void)dispatchInfo;
       (void)resultOut;
       if (!m_manifoldPtr)
              return;

       btCollisionObject* convexObj = m_isSwapped? body1 : body0;
       btCollisionObject* planeObj = m_isSwapped? body0: body1;

       btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
       btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();

       bool hasCollision = false;
       const btVector3& planeNormal = planeShape->getPlaneNormal();
       const btScalar& planeConstant = planeShape->getPlaneConstant();
       btTransform planeInConvex;
       planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
       btTransform convexInPlaneTrans;
       convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();

       btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
       btVector3 vtxInPlane = convexInPlaneTrans(vtx);
       btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);

       btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
       btVector3 vtxInPlaneWorld = planeObj->getWorldTransform() * vtxInPlaneProjected;

       hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
       resultOut->setPersistentManifold(m_manifoldPtr);
       if (hasCollision)
       {
              btVector3 normalOnSurfaceB = planeObj->getWorldTransform().getBasis() * planeNormal;
              btVector3 pOnB = vtxInPlaneWorld;
              resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
       }
       if (m_ownManifold)
       {
              if (m_manifoldPtr->getNumContacts())
              {
                     resultOut->refreshContactPoints();
              }
       }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 57 of file btCollisionAlgorithm.h.

Definition at line 33 of file btConvexPlaneCollisionAlgorithm.h.

btPersistentManifold* btConvexPlaneCollisionAlgorithm::m_manifoldPtr [private]

Definition at line 32 of file btConvexPlaneCollisionAlgorithm.h.

Definition at line 31 of file btConvexPlaneCollisionAlgorithm.h.


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