Back to index

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

ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations. More...

#include <btConvexConvexAlgorithm.h>

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

List of all members.

Classes

struct  CreateFunc

Public Member Functions

 btConvexConvexAlgorithm (btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, btCollisionObject *body0, btCollisionObject *body1, btSimplexSolverInterface *simplexSolver, btConvexPenetrationDepthSolver *pdSolver)
virtual ~btConvexConvexAlgorithm ()
virtual void processCollision (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual btScalar calculateTimeOfImpact (btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
void setLowLevelOfDetail (bool useLowLevel)
const btPersistentManifold * getManifold ()

Public Attributes

bool m_ownManifold
btPersistentManifold * m_manifoldPtr
bool m_lowLevelOfDetail

Protected Member Functions

int getDispatcherId ()

Protected Attributes

btDispatcherm_dispatcher

Private Attributes

btGjkPairDetector m_gjkPairDetector

Detailed Description

ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.

Definition at line 30 of file btConvexConvexAlgorithm.h.


Constructor & Destructor Documentation

btConvexConvexAlgorithm::btConvexConvexAlgorithm ( btPersistentManifold *  mf,
const btCollisionAlgorithmConstructionInfo ci,
btCollisionObject *  body0,
btCollisionObject *  body1,
btSimplexSolverInterface simplexSolver,
btConvexPenetrationDepthSolver pdSolver 
)

Definition at line 62 of file btConvexConvexAlgorithm.cpp.

: btCollisionAlgorithm(ci),
m_gjkPairDetector(0,0,simplexSolver,pdSolver),
m_ownManifold (false),
m_manifoldPtr(mf),
m_lowLevelOfDetail(false)
{
       (void)body0;
       (void)body1;


}

Here is the caller graph for this function:

Definition at line 78 of file btConvexConvexAlgorithm.cpp.

Here is the call graph for this function:


Member Function Documentation

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

Rather then checking ALL pairs, only calculate TOI when motion exceeds threshold

Linear motion for one of objects needs to exceed m_ccdSquareMotionThreshold col0->m_worldTransform,

Convex0 against sphere for Convex1

Simplification, one object is simplified as a sphere

Sphere (for convex0) against Convex1

Simplification, one object is simplified as a sphere

Implements btCollisionAlgorithm.

Definition at line 154 of file btConvexConvexAlgorithm.cpp.

{
       (void)resultOut;
       (void)dispatchInfo;
    
       btScalar resultFraction = btScalar(1.);


       btScalar squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).length2();
       btScalar squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).length2();
    
       if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
              squareMot1 < col1->getCcdSquareMotionThreshold())
              return resultFraction;

       if (disableCcd)
              return btScalar(1.);


       //An adhoc way of testing the Continuous Collision Detection algorithms
       //One object is approximated as a sphere, to simplify things
       //Starting in penetration should report no time of impact
       //For proper CCD, better accuracy and handling of 'allowed' penetration should be added
       //also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies)

              
       {
              btConvexShape* convex0 = static_cast<btConvexShape*>(col0->getCollisionShape());

              btSphereShape sphere1(col1->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation
              btConvexCast::CastResult result;
              btVoronoiSimplexSolver voronoiSimplex;
              //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
              btGjkConvexCast ccd1( convex0 ,&sphere1,&voronoiSimplex);
              //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0);
              if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(),
                     col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result))
              {
              
                     //store result.m_fraction in both bodies
              
                     if (col0->getHitFraction()> result.m_fraction)
                            col0->setHitFraction( result.m_fraction );

                     if (col1->getHitFraction() > result.m_fraction)
                            col1->setHitFraction( result.m_fraction);

                     if (resultFraction > result.m_fraction)
                            resultFraction = result.m_fraction;

              }
              
              


       }

       {
              btConvexShape* convex1 = static_cast<btConvexShape*>(col1->getCollisionShape());

              btSphereShape sphere0(col0->getCcdSweptSphereRadius()); //todo: allow non-zero sphere sizes, for better approximation
              btConvexCast::CastResult result;
              btVoronoiSimplexSolver voronoiSimplex;
              //SubsimplexConvexCast ccd0(&sphere,min0,&voronoiSimplex);
              btGjkConvexCast ccd1(&sphere0,convex1,&voronoiSimplex);
              //ContinuousConvexCollision ccd(min0,min1,&voronoiSimplex,0);
              if (ccd1.calcTimeOfImpact(col0->getWorldTransform(),col0->getInterpolationWorldTransform(),
                     col1->getWorldTransform(),col1->getInterpolationWorldTransform(),result))
              {
              
                     //store result.m_fraction in both bodies
              
                     if (col0->getHitFraction()  > result.m_fraction)
                            col0->setHitFraction( result.m_fraction);

                     if (col1->getHitFraction() > result.m_fraction)
                            col1->setHitFraction( result.m_fraction);

                     if (resultFraction > result.m_fraction)
                            resultFraction = result.m_fraction;

              }
       }
       
       return resultFraction;

}

Here is the call graph for this function:

int btCollisionAlgorithm::getDispatcherId ( ) [protected, inherited]
const btPersistentManifold* btConvexConvexAlgorithm::getManifold ( ) [inline]

Definition at line 53 of file btConvexConvexAlgorithm.h.

       {
              return m_manifoldPtr;
       }
void btConvexConvexAlgorithm::processCollision ( btCollisionObject *  body0,
btCollisionObject *  body1,
const btDispatcherInfo dispatchInfo,
btManifoldResult resultOut 
) [virtual]

Implements btCollisionAlgorithm.

Definition at line 99 of file btConvexConvexAlgorithm.cpp.

{

       if (!m_manifoldPtr)
       {
              //swapped?
              m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1);
              m_ownManifold = true;
       }
       resultOut->setPersistentManifold(m_manifoldPtr);

#ifdef USE_BT_GJKEPA
       btConvexShape*                            shape0(static_cast<btConvexShape*>(body0->getCollisionShape()));
       btConvexShape*                            shape1(static_cast<btConvexShape*>(body1->getCollisionShape()));
       const btScalar                            radialmargin(0/*shape0->getMargin()+shape1->getMargin()*/);
       btGjkEpaSolver::sResults    results;
       if(btGjkEpaSolver::Collide( shape0,body0->getWorldTransform(),
                                                        shape1,body1->getWorldTransform(),
                                                        radialmargin,results))
              {
              dispatchInfo.m_debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
              resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
              }
#else

       btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
       btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
       
       btGjkPairDetector::ClosestPointInput input;

       //TODO: if (dispatchInfo.m_useContinuous)
       m_gjkPairDetector.setMinkowskiA(min0);
       m_gjkPairDetector.setMinkowskiB(min1);
       input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
       input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
       input.m_stackAlloc = dispatchInfo.m_stackAllocator;

//     input.m_maximumDistanceSquared = btScalar(1e30);
       
       input.m_transformA = body0->getWorldTransform();
       input.m_transformB = body1->getWorldTransform();
       
       m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
#endif

       if (m_ownManifold)
       {
              resultOut->refreshContactPoints();
       }

}

Here is the call graph for this function:

Definition at line 87 of file btConvexConvexAlgorithm.cpp.

{
       m_lowLevelOfDetail = useLowLevel;
}

Member Data Documentation

Definition at line 57 of file btCollisionAlgorithm.h.

Definition at line 32 of file btConvexConvexAlgorithm.h.

Definition at line 37 of file btConvexConvexAlgorithm.h.

Definition at line 36 of file btConvexConvexAlgorithm.h.

Definition at line 35 of file btConvexConvexAlgorithm.h.


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