Back to index

supertuxkart  0.5+dfsg1
Classes | Public Member Functions | Static Public Member Functions | Public Attributes
gjkepa_impl::GJK Struct Reference
Collaboration diagram for gjkepa_impl::GJK:
Collaboration graph
[legend]

List of all members.

Classes

struct  He
struct  Mkv

Public Member Functions

 GJK (btStackAlloc *psa, const Rotation &wrot0, const Vector3 &pos0, const btConvexShape *shape0, const Rotation &wrot1, const Vector3 &pos1, const btConvexShape *shape1, F pmargin=0)
 ~GJK ()
Vector3 LocalSupport (const Vector3 &d, U i) const
void Support (const Vector3 &d, Mkv &v) const
Z FetchSupport ()
Z SolveSimplex2 (const Vector3 &ao, const Vector3 &ab)
Z SolveSimplex3 (const Vector3 &ao, const Vector3 &ab, const Vector3 &ac)
Z SolveSimplex3a (const Vector3 &ao, const Vector3 &ab, const Vector3 &ac, const Vector3 &cabc)
Z SolveSimplex4 (const Vector3 &ao, const Vector3 &ab, const Vector3 &ac, const Vector3 &ad)
Z SearchOrigin (const Vector3 &initray=Vector3(1, 0, 0))
Z EncloseOrigin ()

Static Public Member Functions

static U Hash (const Vector3 &v)

Public Attributes

btStackAllocsa
btBlocksablock
Hetable [GJK_hashsize]
Rotation wrotations [2]
Vector3 positions [2]
const btConvexShape * shapes [2]
Mkv simplex [5]
Vector3 ray
U order
U iterations
F margin
Z failed

Detailed Description

Definition at line 109 of file btGjkEpa.cpp.


Class Documentation

struct gjkepa_impl::GJK::He

Definition at line 116 of file btGjkEpa.cpp.

Collaboration diagram for gjkepa_impl::GJK::He:
Class Members
He * n
Vector3 v
struct gjkepa_impl::GJK::Mkv

Definition at line 111 of file btGjkEpa.cpp.

Collaboration diagram for gjkepa_impl::GJK::Mkv:
Class Members
Vector3 r
Vector3 w

Constructor & Destructor Documentation

gjkepa_impl::GJK::GJK ( btStackAlloc psa,
const Rotation wrot0,
const Vector3 pos0,
const btConvexShape *  shape0,
const Rotation wrot1,
const Vector3 pos1,
const btConvexShape *  shape1,
F  pmargin = 0 
) [inline]

Definition at line 134 of file btGjkEpa.cpp.

              {
              wrotations[0]=wrot0;positions[0]=pos0;shapes[0]=shape0;
              wrotations[1]=wrot1;positions[1]=pos1;shapes[1]=shape1;
              sa            =psa;
              sablock       =sa->beginBlock();
              margin =pmargin;
              failed =false;
              }

Here is the call graph for this function:

gjkepa_impl::GJK::~GJK ( ) [inline]

Definition at line 147 of file btGjkEpa.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 272 of file btGjkEpa.cpp.

              {
              switch(order)
                     {
                     /* Point             */
                     case   0:     break;
                     /* Line                     */
                     case   1:
                            {
                            const Vector3 ab(SPXW(1)-SPXW(0));
                            const Vector3 b[]={  cross(ab,Vector3(1,0,0)),
                                                                      cross(ab,Vector3(0,1,0)),
                                                                      cross(ab,Vector3(0,0,1))};
                            const F                     m[]={b[0].length2(),b[1].length2(),b[2].length2()};
                            const Rotation       r(btQuaternion(ab.normalized(),cst2Pi/3));
                            Vector3                     w(b[m[0]>m[1]?m[0]>m[2]?0:2:m[1]>m[2]?1:2]);
                            Support(w.normalized(),simplex[4]);w=r*w;
                            Support(w.normalized(),simplex[2]);w=r*w;
                            Support(w.normalized(),simplex[3]);w=r*w;
                            order=4;
                            return(true);
                            }
                     break;
                     /* Triangle          */
                     case   2:
                            {
                            const 
Vector3       n(cross((SPXW(1)-SPXW(0)),(SPXW(2)-SPXW(0))).normalized());
                            Support( n,simplex[3]);
                            Support(-n,simplex[4]);
                            order=4;
                            return(true);
                            }
                     break;
                     /* Tetrahedron       */
                     case   3:     return(true);
                     /* Hexahedron */
                     case   4:     return(true);
                     }
              return(false);
              }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 174 of file btGjkEpa.cpp.

              {
              const U                     h(Hash(ray));
              He*                         e = (He*)(table[h]);
              while(e) { if(e->v==ray) { --order;return(false); } else e=e->n; }
              e=(He*)sa->allocate(sizeof(He));e->v=ray;e->n=table[h];table[h]=e;
              Support(ray,simplex[++order]);
              return(ray.dot(SPXW(order))>0);
              }

Here is the call graph for this function:

Here is the caller graph for this function:

static U gjkepa_impl::GJK::Hash ( const Vector3 v) [inline, static]

Definition at line 152 of file btGjkEpa.cpp.

              {
              //this doesn't compile under GCC 3.3.5, so add the ()...
              //const U     h(U(v[0]*15461)^U(v[1]*83003)^U(v[2]*15473));
              //return(((*((const U*)&h))*169639)&GJK_hashmask);
           const U h((U)(v[0]*15461)^(U)(v[1]*83003)^(U)(v[2]*15473));
           return(((*((const U*)&h))*169639)&GJK_hashmask);
              }

Here is the caller graph for this function:

Vector3 gjkepa_impl::GJK::LocalSupport ( const Vector3 d,
U  i 
) const [inline]

Definition at line 161 of file btGjkEpa.cpp.

              {
              return(wrotations[i]*shapes[i]->BTLOCALSUPPORT(d*wrotations[i])+positions[i]);
              }

Here is the caller graph for this function:

Z gjkepa_impl::GJK::SearchOrigin ( const Vector3 initray = Vector3(1,0,0)) [inline]

Definition at line 243 of file btGjkEpa.cpp.

              {
              iterations    =      0;
              order         =      (U)-1;
              failed        =      false;
              ray                  =      initray.normalized();
              ClearMemory(table,sizeof(void*)*GJK_hashsize);
              FetchSupport();
              ray                  =      -SPXW(0);
              for(;iterations<GJK_maxiterations;++iterations)
                     {
                     const F              rl(ray.length());
                     ray/=rl>0?rl:1;
                     if(FetchSupport())
                            {
                            Z      found(false);
                            switch(order)
                                   {
                                   case   1:     found=SolveSimplex2(-SPXW(1),SPXW(0)-SPXW(1));break;
                                   case   2:     found=SolveSimplex3(-SPXW(2),SPXW(1)-SPXW(2),SPXW(0)-SPXW(2));break;
                                   case   3:     found=SolveSimplex4(-SPXW(3),SPXW(2)-SPXW(3),SPXW(1)-SPXW(3),SPXW(0)-SPXW(3));break;
                                   }
                            if(found) return(true);
                            } else return(false);
                     }
              failed=true;
              return(false);
              }

Here is the call graph for this function:

Z gjkepa_impl::GJK::SolveSimplex2 ( const Vector3 ao,
const Vector3 ab 
) [inline]

Definition at line 184 of file btGjkEpa.cpp.

              {
              if(ab.dot(ao)>=0)
                     {
                     const Vector3 cabo(cross(ab,ao));
                     if(cabo.length2()>GJK_sqinsimplex_eps)
                            { ray=cross(cabo,ab); }
                            else
                            { return(true); }
                     }
                     else
                     { order=0;SPX(0)=SPX(1);ray=ao;    }
              return(false);
              }

Here is the call graph for this function:

Here is the caller graph for this function:

Z gjkepa_impl::GJK::SolveSimplex3 ( const Vector3 ao,
const Vector3 ab,
const Vector3 ac 
) [inline]

Definition at line 199 of file btGjkEpa.cpp.

              {
              return(SolveSimplex3a(ao,ab,ac,cross(ab,ac)));
              }

Here is the call graph for this function:

Here is the caller graph for this function:

Z gjkepa_impl::GJK::SolveSimplex3a ( const Vector3 ao,
const Vector3 ab,
const Vector3 ac,
const Vector3 cabc 
) [inline]

Definition at line 205 of file btGjkEpa.cpp.

              {
                            if((cross(cabc,ab)).dot(ao)<-GJK_insimplex_eps)
                     { order=1;SPX(0)=SPX(1);SPX(1)=SPX(2);return(SolveSimplex2(ao,ab));   }
              else   if((cross(cabc,ac)).dot(ao)>+GJK_insimplex_eps)
                     { order=1;SPX(1)=SPX(2);return(SolveSimplex2(ao,ac)); }
              else
                     {
                     const F                     d(cabc.dot(ao));
                     if(Abs(d)>GJK_insimplex_eps)
                            {
                            if(d>0)
                                   { ray=cabc; }
                                   else
                                   { ray=-cabc;Swap(SPX(0),SPX(1)); }
                            return(false);
                            } else return(true);
                     }
              }

Here is the call graph for this function:

Here is the caller graph for this function:

Z gjkepa_impl::GJK::SolveSimplex4 ( const Vector3 ao,
const Vector3 ab,
const Vector3 ac,
const Vector3 ad 
) [inline]

Definition at line 226 of file btGjkEpa.cpp.

              {
              Vector3                     crs;
                            if((crs=cross(ab,ac)).dot(ao)>GJK_insimplex_eps)
                     { 
order=2;SPX(0)=SPX(1);SPX(1)=SPX(2);SPX(2)=SPX(3);return(SolveSimplex3a(ao,ab,ac,crs)); 
}
              else   if((crs=cross(ac,ad)).dot(ao)>GJK_insimplex_eps)
                     { order=2;SPX(2)=SPX(3);return(SolveSimplex3a(ao,ac,ad,crs)); }
              else   if((crs=cross(ad,ab)).dot(ao)>GJK_insimplex_eps)
                     { 
order=2;SPX(1)=SPX(0);SPX(0)=SPX(2);SPX(2)=SPX(3);return(SolveSimplex3a(ao,ad,ab,crs)); 
}
              else   return(true);
              }

Here is the call graph for this function:

Here is the caller graph for this function:

void gjkepa_impl::GJK::Support ( const Vector3 d,
Mkv v 
) const [inline]

Definition at line 166 of file btGjkEpa.cpp.

              {
              v.r    =      d;
              v.w    =      LocalSupport(d,0)-LocalSupport(-d,1)+d*margin;
              }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 132 of file btGjkEpa.cpp.

Definition at line 130 of file btGjkEpa.cpp.

Definition at line 131 of file btGjkEpa.cpp.

Definition at line 129 of file btGjkEpa.cpp.

Definition at line 125 of file btGjkEpa.cpp.

Definition at line 128 of file btGjkEpa.cpp.

Definition at line 121 of file btGjkEpa.cpp.

Definition at line 122 of file btGjkEpa.cpp.

const btConvexShape* gjkepa_impl::GJK::shapes[2]

Definition at line 126 of file btGjkEpa.cpp.

Definition at line 127 of file btGjkEpa.cpp.

Definition at line 123 of file btGjkEpa.cpp.

Definition at line 124 of file btGjkEpa.cpp.


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