Back to index

supertuxkart  0.5+dfsg1
Classes | Static Public Member Functions
btGjkEpaSolver2 Struct Reference

btGjkEpaSolver contributed under zlib by Nathanael Presson More...

#include <btGjkEpa2.h>

List of all members.

Classes

struct  sResults

Static Public Member Functions

static int StackSizeRequirement ()
static btScalar Distance (const btConvexShape *shape0, const btTransform &wtrs0, const btConvexShape *shape1, const btTransform &wtrs1, sResults &results)
static btScalar SignedDistance (const btVector3 &position, btScalar margin, const btConvexShape *shape, const btTransform &wtrs, sResults &results)
static bool Penetration (const btConvexShape *shape0, const btTransform &wtrs0, const btConvexShape *shape1, const btTransform &wtrs1, const btVector3 &guess, sResults &results)

Detailed Description

btGjkEpaSolver contributed under zlib by Nathanael Presson

Definition at line 6 of file btGjkEpa2.h.


Member Function Documentation

btScalar btGjkEpaSolver2::Distance ( const btConvexShape *  shape0,
const btTransform wtrs0,
const btConvexShape *  shape1,
const btTransform wtrs1,
sResults results 
) [static]

Definition at line 752 of file btGjkEpa2.cpp.

{
tShape               shape;
Initialize(shape0,wtrs0,shape1,wtrs1,results,shape,false);
GJK                         gjk;   
GJK::eStatus::_      gjk_status=gjk.Evaluate(shape,btVector3(1,1,1));
if(gjk_status==GJK::eStatus::Valid)
       {
       btVector3     w0=btVector3(0,0,0);
       btVector3     w1=btVector3(0,0,0);
       for(U i=0;i<gjk.m_simplex->rank;++i)
              {
              const btScalar       p=gjk.m_simplex->p[i];
              w0+=shape.Support( gjk.m_simplex->c[i]->d,0)*p;
              w1+=shape.Support(-gjk.m_simplex->c[i]->d,1)*p;
              }
       results.witnesses[0] =      wtrs0*w0;
       results.witnesses[1] =      wtrs0*w1;
       return((w0-w1).length());
       }
       else
       {
       results.status       =      gjk_status==GJK::eStatus::Inside?
                                                 sResults::Penetrating       :
                                                 sResults::GJK_Failed ;
       return(-1);
       }
}

Here is the call graph for this function:

bool btGjkEpaSolver2::Penetration ( const btConvexShape *  shape0,
const btTransform wtrs0,
const btConvexShape *  shape1,
const btTransform wtrs1,
const btVector3 guess,
sResults results 
) [static]

Definition at line 837 of file btGjkEpa2.cpp.

{
tShape               shape;
Initialize(shape0,wtrs0,shape1,wtrs1,results,shape,true);
GJK                         gjk;   
GJK::eStatus::_      gjk_status=gjk.Evaluate(shape,-guess);
switch(gjk_status)
       {
       case   GJK::eStatus::Inside:
              {
              EPA                         epa;
              EPA::eStatus::_      epa_status=epa.Evaluate(gjk,-guess);
              if(epa_status!=EPA::eStatus::Failed)
                     {
                     btVector3     w0=btVector3(0,0,0);
                     for(U i=0;i<epa.m_result.rank;++i)
                            {
                            w0+=shape.Support(epa.m_result.c[i]->d,0)*epa.m_result.p[i];
                            }
                     results.status                     =      sResults::Penetrating;
                     results.witnesses[0] =      wtrs0*w0;
                     results.witnesses[1] =      wtrs0*(w0-epa.m_normal*epa.m_depth);
                     return(true);
                     } else results.status=sResults::EPA_Failed;
              }
       break;
       case   GJK::eStatus::Failed:
       results.status=sResults::GJK_Failed;
       break;
       }
return(false);
}

Here is the call graph for this function:

btScalar btGjkEpaSolver2::SignedDistance ( const btVector3 position,
btScalar  margin,
const btConvexShape *  shape,
const btTransform wtrs,
sResults results 
) [static]

Definition at line 786 of file btGjkEpa2.cpp.

{
tShape               shape;
btSphereShape shape1(margin);
btTransform          wtrs1(btQuaternion(0,0,0,1),position);
Initialize(shape0,wtrs0,&shape1,wtrs1,results,shape,false);
GJK                         gjk;   
GJK::eStatus::_      gjk_status=gjk.Evaluate(shape,btVector3(1,1,1));
if(gjk_status==GJK::eStatus::Valid)
       {
       btVector3     w0=btVector3(0,0,0);
       btVector3     w1=btVector3(0,0,0);
       for(U i=0;i<gjk.m_simplex->rank;++i)
              {
              const btScalar       p=gjk.m_simplex->p[i];
              w0+=shape.Support( gjk.m_simplex->c[i]->d,0)*p;
              w1+=shape.Support(-gjk.m_simplex->c[i]->d,1)*p;
              }
       results.witnesses[0] =      wtrs0*w0;
       results.witnesses[1] =      wtrs0*w1;
       const btVector3      delta= results.witnesses[1]-
                                                 results.witnesses[0];
       const btScalar       margin=       shape0->getMargin()+
                                                 shape1.getMargin();
       const btScalar       length=       delta.length();      
       results.normal                     =      delta/length;
       results.witnesses[0] +=     results.normal*margin;
       return(length-margin);
       }
       else
       {
       if(gjk_status==GJK::eStatus::Inside)
              {
              if(Penetration(shape0,wtrs0,&shape1,wtrs1,gjk.m_ray,results))
                     {
                     const btVector3      delta= results.witnesses[0]-
                                                               results.witnesses[1];
                     const btScalar       length=       delta.length();
                     results.normal       =      delta/length;               
                     return(-length);
                     }
              }      
       }
return(SIMD_INFINITY);
}

Here is the call graph for this function:

Definition at line 746 of file btGjkEpa2.cpp.

{
return(sizeof(GJK)+sizeof(EPA));
}

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