Back to index

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

btSubsimplexConvexCast implements Gino van den Bergens' paper "Ray Casting against bteral Convex Objects with Application to Continuous Collision Detection" GJK based Ray Cast, optimized version Objects should not start in overlap, otherwise results are not defined. More...

#include <btSubSimplexConvexCast.h>

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

List of all members.

Public Member Functions

 btSubsimplexConvexCast (const btConvexShape *shapeA, const btConvexShape *shapeB, btSimplexSolverInterface *simplexSolver)
virtual bool calcTimeOfImpact (const btTransform &fromA, const btTransform &toA, const btTransform &fromB, const btTransform &toB, CastResult &result)
 SimsimplexConvexCast calculateTimeOfImpact calculates the time of impact+normal for the linear cast (sweep) between two moving objects. Precondition is that objects should not penetration/overlap at the start from the interval. Overlap can be tested using btGjkPairDetector.

Private Attributes

btSimplexSolverInterfacem_simplexSolver
const btConvexShape * m_convexA
const btConvexShape * m_convexB

Detailed Description

btSubsimplexConvexCast implements Gino van den Bergens' paper "Ray Casting against bteral Convex Objects with Application to Continuous Collision Detection" GJK based Ray Cast, optimized version Objects should not start in overlap, otherwise results are not defined.

Definition at line 28 of file btSubSimplexConvexCast.h.


Constructor & Destructor Documentation

btSubsimplexConvexCast::btSubsimplexConvexCast ( const btConvexShape *  shapeA,
const btConvexShape *  shapeB,
btSimplexSolverInterface simplexSolver 
)

Definition at line 25 of file btSubSimplexConvexCast.cpp.

:m_simplexSolver(simplexSolver),
m_convexA(convexA),m_convexB(convexB)
{
}

Member Function Documentation

bool btSubsimplexConvexCast::calcTimeOfImpact ( const btTransform fromA,
const btTransform toA,
const btTransform fromB,
const btTransform toB,
CastResult result 
) [virtual]

SimsimplexConvexCast calculateTimeOfImpact calculates the time of impact+normal for the linear cast (sweep) between two moving objects. Precondition is that objects should not penetration/overlap at the start from the interval. Overlap can be tested using btGjkPairDetector.

take relative motion

Implements btConvexCast.

Definition at line 38 of file btSubSimplexConvexCast.cpp.

{

       m_simplexSolver->reset();

       btVector3 linVelA,linVelB;
       linVelA = toA.getOrigin()-fromA.getOrigin();
       linVelB = toB.getOrigin()-fromB.getOrigin();

       btScalar lambda = btScalar(0.);

       btTransform interpolatedTransA = fromA;
       btTransform interpolatedTransB = fromB;

       btVector3 r = (linVelA-linVelB);
       btVector3 v;
       
       btVector3 supVertexA = fromA(m_convexA->localGetSupportingVertex(-r*fromA.getBasis()));
       btVector3 supVertexB = fromB(m_convexB->localGetSupportingVertex(r*fromB.getBasis()));
       v = supVertexA-supVertexB;
       int maxIter = MAX_ITERATIONS;

       btVector3 n;
       n.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
       bool hasResult = false;
       btVector3 c;

       btScalar lastLambda = lambda;


       btScalar dist2 = v.length2();
#ifdef BT_USE_DOUBLE_PRECISION
       btScalar epsilon = btScalar(0.0001);
#else
       btScalar epsilon = btScalar(0.0001);
#endif //BT_USE_DOUBLE_PRECISION
       btVector3     w,p;
       btScalar VdotR;
       
       while ( (dist2 > epsilon) && maxIter--)
       {
              supVertexA = interpolatedTransA(m_convexA->localGetSupportingVertex(-v*interpolatedTransA.getBasis()));
              supVertexB = interpolatedTransB(m_convexB->localGetSupportingVertex(v*interpolatedTransB.getBasis()));
              w = supVertexA-supVertexB;

              btScalar VdotW = v.dot(w);

              if ( VdotW > btScalar(0.))
              {
                     VdotR = v.dot(r);

                     if (VdotR >= -(SIMD_EPSILON*SIMD_EPSILON))
                            return false;
                     else
                     {
                            lambda = lambda - VdotW / VdotR;
                            //interpolate to next lambda
                            //     x = s + lambda * r;
                            interpolatedTransA.getOrigin().setInterpolate3(fromA.getOrigin(),toA.getOrigin(),lambda);
                            interpolatedTransB.getOrigin().setInterpolate3(fromB.getOrigin(),toB.getOrigin(),lambda);
                            //m_simplexSolver->reset();
                            //check next line
                             w = supVertexA-supVertexB;
                            lastLambda = lambda;
                            n = v;
                            hasResult = true;
                     }
              } 
              m_simplexSolver->addVertex( w, supVertexA , supVertexB);
              if (m_simplexSolver->closest(v))
              {
                     dist2 = v.length2();
                     hasResult = true;
                     //printf("V=%f , %f, %f\n",v[0],v[1],v[2]);
                     //printf("DIST2=%f\n",dist2);
                     //printf("numverts = %i\n",m_simplexSolver->numVertices());
              } else
              {
                     dist2 = btScalar(0.);
              } 
       }

       //int numiter = MAX_ITERATIONS - maxIter;
//     printf("number of iterations: %d", numiter);
       result.m_fraction = lambda;
       result.m_normal = n.normalized();
       btVector3 hitA,hitB;
       m_simplexSolver->compute_points(hitA,hitB);
       result.m_hitPoint=hitB;
       return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

const btConvexShape* btSubsimplexConvexCast::m_convexA [private]

Definition at line 31 of file btSubSimplexConvexCast.h.

const btConvexShape* btSubsimplexConvexCast::m_convexB [private]

Definition at line 32 of file btSubSimplexConvexCast.h.

Definition at line 30 of file btSubSimplexConvexCast.h.


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