Back to index

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

btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection. Other features are frame-coherency (persistent data) and collision response. Also provides the most basic sample for custom/user btCollisionAlgorithm More...

#include <btSphereSphereCollisionAlgorithm.h>

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

List of all members.

Classes

struct  CreateFunc

Public Member Functions

 btSphereSphereCollisionAlgorithm (btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, btCollisionObject *body0, btCollisionObject *body1)
 btSphereSphereCollisionAlgorithm (const btCollisionAlgorithmConstructionInfo &ci)
virtual void processCollision (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual btScalar calculateTimeOfImpact (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual ~btSphereSphereCollisionAlgorithm ()

Protected Member Functions

int getDispatcherId ()

Protected Attributes

btDispatcherm_dispatcher

Private Attributes

bool m_ownManifold
btPersistentManifold * m_manifoldPtr

Detailed Description

btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection. Other features are frame-coherency (persistent data) and collision response. Also provides the most basic sample for custom/user btCollisionAlgorithm

Definition at line 29 of file btSphereSphereCollisionAlgorithm.h.


Constructor & Destructor Documentation

btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm ( btPersistentManifold *  mf,
const btCollisionAlgorithmConstructionInfo ci,
btCollisionObject *  body0,
btCollisionObject *  body1 
)

Definition at line 21 of file btSphereSphereCollisionAlgorithm.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 37 of file btSphereSphereCollisionAlgorithm.h.

Definition at line 33 of file btSphereSphereCollisionAlgorithm.cpp.

Here is the call graph for this function:


Member Function Documentation

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

Implements btCollisionAlgorithm.

Definition at line 89 of file btSphereSphereCollisionAlgorithm.cpp.

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

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

iff distance positive, don't generate a new contact

distance (negative means penetration)

point on A (worldspace)

point on B (worldspace)

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

Implements btCollisionAlgorithm.

Definition at line 42 of file btSphereSphereCollisionAlgorithm.cpp.

{
       (void)dispatchInfo;

       if (!m_manifoldPtr)
              return;

       resultOut->setPersistentManifold(m_manifoldPtr);

       btSphereShape* sphere0 = (btSphereShape*)col0->getCollisionShape();
       btSphereShape* sphere1 = (btSphereShape*)col1->getCollisionShape();

       btVector3 diff = col0->getWorldTransform().getOrigin()-  col1->getWorldTransform().getOrigin();
       btScalar len = diff.length();
       btScalar radius0 = sphere0->getRadius();
       btScalar radius1 = sphere1->getRadius();

       m_manifoldPtr->clearManifold();

       if ( len > (radius0+radius1))
       {
              return;
       }
       btScalar dist = len - (radius0+radius1);

       btVector3 normalOnSurfaceB(1,0,0);
       if (len > SIMD_EPSILON)
       {
              normalOnSurfaceB = diff / len;
       }

       btVector3 pos0 = col0->getWorldTransform().getOrigin() - radius0 * normalOnSurfaceB;
       btVector3 pos1 = col1->getWorldTransform().getOrigin() + radius1* normalOnSurfaceB;

       
       
       resultOut->addContactPoint(normalOnSurfaceB,pos1,dist);

       //no resultOut->refreshContactPoints(); needed, because of clearManifold (all points are new)

}

Here is the call graph for this function:


Member Data Documentation

Definition at line 57 of file btCollisionAlgorithm.h.

btPersistentManifold* btSphereSphereCollisionAlgorithm::m_manifoldPtr [private]

Definition at line 32 of file btSphereSphereCollisionAlgorithm.h.

Definition at line 31 of file btSphereSphereCollisionAlgorithm.h.


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