Back to index

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

GL_Simplex1to4 is a class to debug a Simplex Solver with 1 to 4 points. Can be used by GJK. More...

#include <GL_Simplex1to4.h>

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

List of all members.

Public Member Functions

 GL_Simplex1to4 ()
void calcClosest (btScalar *m)
 Debugging method calcClosest calculates the closest point to the origin, using m_simplexSolver.
void setSimplexSolver (btSimplexSolverInterface *simplexSolver)
void reset ()
virtual int getShapeType () const
void addVertex (const btPoint3 &pt)
virtual int getNumVertices () const
virtual int getNumEdges () const
virtual void getEdge (int i, btPoint3 &pa, btPoint3 &pb) const
virtual void getVertex (int i, btPoint3 &vtx) const
virtual int getNumPlanes () const
virtual void getPlane (btVector3 &planeNormal, btPoint3 &planeSupport, int i) const
virtual int getIndex (int i) const
virtual bool isInside (const btPoint3 &pt, btScalar tolerance) const
virtual const char * getName () const
 getName is for debugging
virtual btVector3 localGetSupportingVertexWithoutMargin (const btVector3 &vec) const
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin (const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
virtual void calculateLocalInertia (btScalar mass, btVector3 &inertia) const
void getNonvirtualAabb (const btTransform &trans, btVector3 &aabbMin, btVector3 &aabbMax, btScalar margin) const
virtual void getAabb (const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
 getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
void recalcLocalAabb ()
virtual btVector3 localGetSupportingVertex (const btVector3 &vec) const
const btVector3getImplicitShapeDimensions () const
virtual void getAabbSlow (const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
virtual void setLocalScaling (const btVector3 &scaling)
virtual const btVector3getLocalScaling () const
const btVector3getLocalScalingNV () const
virtual void setMargin (btScalar margin)
virtual btScalar getMargin () const
btScalar getMarginNV () const
virtual int getNumPreferredPenetrationDirections () const
virtual void getPreferredPenetrationDirection (int index, btVector3 &penetrationVector) const

Public Attributes

class Hull * m_optionalHull
 optional Hull is for optional Separating Axis Test Hull collision detection, see Hull.cpp

Protected Attributes

int m_numVertices
btPoint3 m_vertices [4]
btVector3 m_localAabbMin
btVector3 m_localAabbMax
bool m_isLocalAabbValid
btVector3 m_localScaling
btVector3 m_implicitShapeDimensions
btScalar m_collisionMargin
btScalar m_padding

Private Attributes

btSimplexSolverInterfacem_simplexSolver

Detailed Description

GL_Simplex1to4 is a class to debug a Simplex Solver with 1 to 4 points. Can be used by GJK.

Definition at line 24 of file GL_Simplex1to4.h.


Constructor & Destructor Documentation

Definition at line 32 of file GL_Simplex1to4.cpp.


Member Function Documentation

void btBU_Simplex1to4::addVertex ( const btPoint3 pt) [inherited]

Definition at line 58 of file btTetrahedronShape.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin ( const btVector3 vectors,
btVector3 supportVerticesOut,
int  numVectors 
) const [virtual, inherited]

Implements btConvexInternalShape.

Reimplemented in btCylinderShapeZ, btCylinderShapeX, btTriangleShape, btBoxShape, btCylinderShape, and btConvexTriangleMeshShape.

Definition at line 65 of file btPolyhedralConvexShape.cpp.

{
       int i;

       btVector3 vtx;
       btScalar newDot;

       for (i=0;i<numVectors;i++)
       {
              supportVerticesOut[i][3] = btScalar(-1e30);
       }

       for (int j=0;j<numVectors;j++)
       {
       
              const btVector3& vec = vectors[j];

              for (i=0;i<getNumVertices();i++)
              {
                     getVertex(i,vtx);
                     newDot = vec.dot(vtx);
                     if (newDot > supportVerticesOut[j][3])
                     {
                            //WARNING: don't swap next lines, the w component would get overwritten!
                            supportVerticesOut[j] = vtx;
                            supportVerticesOut[j][3] = newDot;
                     }
              }
       }
}

Here is the call graph for this function:

Debugging method calcClosest calculates the closest point to the origin, using m_simplexSolver.

Definition at line 40 of file GL_Simplex1to4.cpp.

{
       btTransform tr;
       tr.setFromOpenGLMatrix(m);
       


                     GL_ShapeDrawer::drawCoordSystem();
                     
                     if (m_simplexSolver)
                     {
                            m_simplexSolver->reset();
                            bool res;

                            btVector3 v;

                            for (int i=0;i<m_numVertices;i++)
                            {
                                   v =  tr(m_vertices[i]);
                                   m_simplexSolver->addVertex(v,v,btPoint3(0.f,0.f,0.f));
                                   res = m_simplexSolver->closest(v);
                            }

                            //draw v?
                            glDisable(GL_LIGHTING);
                            glBegin(GL_LINES);
                            btglColor3(1.f, 0.f, 0.f);
                            btglVertex3(0.f, 0.f, 0.f);
                            btglVertex3(v.x(),v.y(),v.z());
                            glEnd();
                            
                            glEnable(GL_LIGHTING);


                     }

}

Here is the call graph for this function:

void btPolyhedralConvexShape::calculateLocalInertia ( btScalar  mass,
btVector3 inertia 
) const [virtual, inherited]

Reimplemented in btTriangleShape, and btBoxShape.

Definition at line 98 of file btPolyhedralConvexShape.cpp.

{
       //not yet, return box inertia

       btScalar margin = getMargin();

       btTransform ident;
       ident.setIdentity();
       btVector3 aabbMin,aabbMax;
       getAabb(ident,aabbMin,aabbMax);
       btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);

       btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
       btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
       btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
       const btScalar x2 = lx*lx;
       const btScalar y2 = ly*ly;
       const btScalar z2 = lz*lz;
       const btScalar scaledmass = mass * btScalar(0.08333333);

       inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));

}

Here is the call graph for this function:

void btPolyhedralConvexShape::getAabb ( const btTransform t,
btVector3 aabbMin,
btVector3 aabbMax 
) const [virtual, inherited]

getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version

Reimplemented from btConvexInternalShape.

Reimplemented in btBoxShape, btTriangleShape, and btCylinderShape.

Definition at line 124 of file btPolyhedralConvexShape.cpp.

{
       getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void btConvexInternalShape::getAabbSlow ( const btTransform t,
btVector3 aabbMin,
btVector3 aabbMax 
) const [virtual, inherited]

Definition at line 34 of file btConvexInternalShape.cpp.

{

       btScalar margin = getMargin();
       for (int i=0;i<3;i++)
       {
              btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
              vec[i] = btScalar(1.);

              btVector3 sv = localGetSupportingVertex(vec*trans.getBasis());

              btVector3 tmp = trans(sv);
              maxAabb[i] = tmp[i]+margin;
              vec[i] = btScalar(-1.);
              tmp = trans(localGetSupportingVertex(vec*trans.getBasis()));
              minAabb[i] = tmp[i]-margin;
       }
};

Here is the call graph for this function:

Here is the caller graph for this function:

void btBU_Simplex1to4::getEdge ( int  i,
btPoint3 pa,
btPoint3 pb 
) const [virtual, inherited]

Implements btPolyhedralConvexShape.

Definition at line 90 of file btTetrahedronShape.cpp.

{
       
    switch (m_numVertices)
       {

       case 2: 
              pa = m_vertices[0];
              pb = m_vertices[1];
              break;
       case 3:  
              switch (i)
              {
              case 0:
                     pa = m_vertices[0];
                     pb = m_vertices[1];
                     break;
              case 1:
                     pa = m_vertices[1];
                     pb = m_vertices[2];
                     break;
              case 2:
                     pa = m_vertices[2];
                     pb = m_vertices[0];
                     break;

              }
              break;
       case 4: 
              switch (i)
              {
              case 0:
                     pa = m_vertices[0];
                     pb = m_vertices[1];
                     break;
              case 1:
                     pa = m_vertices[1];
                     pb = m_vertices[2];
                     break;
              case 2:
                     pa = m_vertices[2];
                     pb = m_vertices[0];
                     break;
              case 3:
                     pa = m_vertices[0];
                     pb = m_vertices[3];
                     break;
              case 4:
                     pa = m_vertices[1];
                     pb = m_vertices[3];
                     break;
              case 5:
                     pa = m_vertices[2];
                     pb = m_vertices[3];
                     break;
              }

       }




}
const btVector3& btConvexInternalShape::getImplicitShapeDimensions ( ) const [inline, inherited]

Definition at line 40 of file btConvexInternalShape.h.

int btBU_Simplex1to4::getIndex ( int  i) const [virtual, inherited]

Definition at line 186 of file btTetrahedronShape.cpp.

{
       return 0;
}
virtual const btVector3& btConvexInternalShape::getLocalScaling ( ) const [inline, virtual, inherited]

Reimplemented in btConvexTriangleMeshShape.

Definition at line 57 of file btConvexInternalShape.h.

       {
              return m_localScaling;
       }
const btVector3& btConvexInternalShape::getLocalScalingNV ( ) const [inline, inherited]

Definition at line 62 of file btConvexInternalShape.h.

       {
              return m_localScaling;
       }
virtual btScalar btConvexInternalShape::getMargin ( ) const [inline, virtual, inherited]

Reimplemented in btMinkowskiSumShape.

Definition at line 71 of file btConvexInternalShape.h.

       {
              return m_collisionMargin;
       }

Here is the caller graph for this function:

btScalar btConvexInternalShape::getMarginNV ( ) const [inline, inherited]

Definition at line 76 of file btConvexInternalShape.h.

       {
              return m_collisionMargin;
       }
virtual const char* btBU_Simplex1to4::getName ( ) const [inline, virtual, inherited]

getName is for debugging

Definition at line 71 of file btTetrahedronShape.h.

{ return "btBU_Simplex1to4";}
void btPolyhedralConvexShape::getNonvirtualAabb ( const btTransform trans,
btVector3 aabbMin,
btVector3 aabbMax,
btScalar  margin 
) const [inline, inherited]

Definition at line 44 of file btPolyhedralConvexShape.h.

       {

              //lazy evaluation of local aabb
              btAssert(m_isLocalAabbValid);

              btAssert(m_localAabbMin.getX() <= m_localAabbMax.getX());
              btAssert(m_localAabbMin.getY() <= m_localAabbMax.getY());
              btAssert(m_localAabbMin.getZ() <= m_localAabbMax.getZ());


              btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
              btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
              
              btMatrix3x3 abs_b = trans.getBasis().absolute();  

              btPoint3 center = trans(localCenter);

              btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
                        abs_b[1].dot(localHalfExtents),
                       abs_b[2].dot(localHalfExtents));
              extent += btVector3(margin,margin,margin);

              aabbMin = center - extent;
              aabbMax = center + extent;

              
       }

Here is the call graph for this function:

Here is the caller graph for this function:

int btBU_Simplex1to4::getNumEdges ( ) const [virtual, inherited]

Implements btPolyhedralConvexShape.

Definition at line 71 of file btTetrahedronShape.cpp.

{
       //euler formula, F-E+V = 2, so E = F+V-2

       switch (m_numVertices)
       {
       case 0:
              return 0;
       case 1: return 0;
       case 2: return 1;
       case 3: return 3;
       case 4: return 6;


       }

       return 0;
}
int btBU_Simplex1to4::getNumPlanes ( ) const [virtual, inherited]

Implements btPolyhedralConvexShape.

Definition at line 159 of file btTetrahedronShape.cpp.

{
       switch (m_numVertices)
       {
       case 0:
                     return 0;
       case 1:
                     return 0;
       case 2:
                     return 0;
       case 3:
                     return 2;
       case 4:
                     return 4;
       default:
              {
              }
       }
       return 0;
}
virtual int btConvexInternalShape::getNumPreferredPenetrationDirections ( ) const [inline, virtual, inherited]

Reimplemented in btBoxShape, and btTriangleShape.

Definition at line 81 of file btConvexInternalShape.h.

       {
              return 0;
       }
int btBU_Simplex1to4::getNumVertices ( ) const [virtual, inherited]

Implements btPolyhedralConvexShape.

Definition at line 66 of file btTetrahedronShape.cpp.

{
       return m_numVertices;
}
void btBU_Simplex1to4::getPlane ( btVector3 planeNormal,
btPoint3 planeSupport,
int  i 
) const [virtual, inherited]

Implements btPolyhedralConvexShape.

Definition at line 181 of file btTetrahedronShape.cpp.

{
       
}
virtual void btConvexInternalShape::getPreferredPenetrationDirection ( int  index,
btVector3 penetrationVector 
) const [inline, virtual, inherited]

Reimplemented in btBoxShape, and btTriangleShape.

Definition at line 86 of file btConvexInternalShape.h.

       {
              (void)penetrationVector;
              (void)index;
              btAssert(0);
       }
virtual int btBU_Simplex1to4::getShapeType ( ) const [inline, virtual, inherited]

Definition at line 47 of file btTetrahedronShape.h.

void btBU_Simplex1to4::getVertex ( int  i,
btPoint3 vtx 
) const [virtual, inherited]

Implements btPolyhedralConvexShape.

Definition at line 154 of file btTetrahedronShape.cpp.

{
       vtx = m_vertices[i];
}
bool btBU_Simplex1to4::isInside ( const btPoint3 pt,
btScalar  tolerance 
) const [virtual, inherited]

Implements btPolyhedralConvexShape.

Definition at line 191 of file btTetrahedronShape.cpp.

{
       return false;
}
btVector3 btConvexInternalShape::localGetSupportingVertex ( const btVector3 vec) const [virtual, inherited]

Reimplemented in btBoxShape, btCylinderShape, btConeShape, and btConvexTriangleMeshShape.

Definition at line 54 of file btConvexInternalShape.cpp.

{
#ifndef __SPU__

        btVector3    supVertex = localGetSupportingVertexWithoutMargin(vec);

       if ( getMargin()!=btScalar(0.) )
       {
              btVector3 vecnorm = vec;
              if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
              {
                     vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
              } 
              vecnorm.normalize();
              supVertex+= getMargin() * vecnorm;
       }
       return supVertex;

#else
       return btVector3(0,0,0);
#endif //__SPU__

 }

Here is the call graph for this function:

Here is the caller graph for this function:

Implements btConvexInternalShape.

Reimplemented in btCylinderShapeZ, btCylinderShapeX, btTriangleShape, btBoxShape, btCylinderShape, and btConvexTriangleMeshShape.

Definition at line 29 of file btPolyhedralConvexShape.cpp.

{
       int i;
       btVector3 supVec(0,0,0);

       btScalar maxDot(btScalar(-1e30));

       btVector3 vec = vec0;
       btScalar lenSqr = vec.length2();
       if (lenSqr < btScalar(0.0001))
       {
              vec.setValue(1,0,0);
       } else
       {
              btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
              vec *= rlen;
       }

       btVector3 vtx;
       btScalar newDot;

       for (i=0;i<getNumVertices();i++)
       {
              getVertex(i,vtx);
              newDot = vec.dot(vtx);
              if (newDot > maxDot)
              {
                     maxDot = newDot;
                     supVec = vtx;
              }
       }

       return supVec;

}

Here is the call graph for this function:

Definition at line 132 of file btPolyhedralConvexShape.cpp.

{
       m_isLocalAabbValid = true;

       for (int i=0;i<3;i++)
       {
              btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
              vec[i] = btScalar(1.);
              btVector3 tmp = localGetSupportingVertex(vec);
              m_localAabbMax[i] = tmp[i]+m_collisionMargin;
              vec[i] = btScalar(-1.);
              tmp = localGetSupportingVertex(vec);
              m_localAabbMin[i] = tmp[i]-m_collisionMargin;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void btBU_Simplex1to4::reset ( ) [inline, inherited]

Definition at line 41 of file btTetrahedronShape.h.

       {
              m_numVertices = 0;
       }
void btConvexInternalShape::setLocalScaling ( const btVector3 scaling) [virtual, inherited]

Reimplemented in btBoxShape, and btConvexTriangleMeshShape.

Definition at line 27 of file btConvexInternalShape.cpp.

{
       m_localScaling = scaling;
}
virtual void btConvexInternalShape::setMargin ( btScalar  margin) [inline, virtual, inherited]

Reimplemented in btBoxShape.

Definition at line 67 of file btConvexInternalShape.h.

       {
              m_collisionMargin = margin;
       }

Here is the caller graph for this function:

void GL_Simplex1to4::setSimplexSolver ( btSimplexSolverInterface simplexSolver) [inline]

Definition at line 34 of file GL_Simplex1to4.h.

                                                                        {
              m_simplexSolver = simplexSolver;
       }

Member Data Documentation

Definition at line 18 of file btConvexInternalShape.h.

Definition at line 16 of file btConvexInternalShape.h.

bool btPolyhedralConvexShape::m_isLocalAabbValid [protected, inherited]

Definition at line 31 of file btPolyhedralConvexShape.h.

Definition at line 30 of file btPolyhedralConvexShape.h.

Definition at line 29 of file btPolyhedralConvexShape.h.

Definition at line 14 of file btConvexInternalShape.h.

int btBU_Simplex1to4::m_numVertices [protected, inherited]

Definition at line 29 of file btTetrahedronShape.h.

class Hull* btPolyhedralConvexShape::m_optionalHull [inherited]

optional Hull is for optional Separating Axis Test Hull collision detection, see Hull.cpp

Definition at line 89 of file btPolyhedralConvexShape.h.

Definition at line 20 of file btConvexInternalShape.h.

Definition at line 26 of file GL_Simplex1to4.h.

btPoint3 btBU_Simplex1to4::m_vertices[4] [protected, inherited]

Definition at line 30 of file btTetrahedronShape.h.


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