Back to index

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

btConvexTriangleMeshShape is a convex hull of a triangle mesh. If you just have a point cloud, you can use btConvexHullShape instead. It uses the btStridingMeshInterface instead of a point cloud. This can avoid the duplication of the triangle mesh data. More...

#include <btConvexTriangleMeshShape.h>

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

List of all members.

Public Member Functions

 btConvexTriangleMeshShape (btStridingMeshInterface *meshInterface)
class btStridingMeshInterfacegetMeshInterface ()
class btStridingMeshInterfacegetMeshInterface () const
virtual btVector3 localGetSupportingVertex (const btVector3 &vec) const
virtual btVector3 localGetSupportingVertexWithoutMargin (const btVector3 &vec) const
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin (const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
virtual int getShapeType () const
virtual const char * getName () const
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 bool isInside (const btPoint3 &pt, btScalar tolerance) const
virtual void setLocalScaling (const btVector3 &scaling)
virtual const btVector3getLocalScaling () 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 ()
const btVector3getImplicitShapeDimensions () const
virtual void getAabbSlow (const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) 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

btVector3 m_localAabbMin
btVector3 m_localAabbMax
bool m_isLocalAabbValid
btVector3 m_localScaling
btVector3 m_implicitShapeDimensions
btScalar m_collisionMargin
btScalar m_padding

Private Attributes

class btStridingMeshInterfacem_stridingMesh

Detailed Description

btConvexTriangleMeshShape is a convex hull of a triangle mesh. If you just have a point cloud, you can use btConvexHullShape instead. It uses the btStridingMeshInterface instead of a point cloud. This can avoid the duplication of the triangle mesh data.

Definition at line 11 of file btConvexTriangleMeshShape.h.


Constructor & Destructor Documentation

Definition at line 22 of file btConvexTriangleMeshShape.cpp.

:m_stridingMesh(meshInterface)
{
       recalcLocalAabb();
}

Here is the call graph for this function:


Member Function Documentation

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

Reimplemented from btPolyhedralConvexShape.

Definition at line 99 of file btConvexTriangleMeshShape.cpp.

{
       //use 'w' component of supportVerticesOut?
       {
              for (int i=0;i<numVectors;i++)
              {
                     supportVerticesOut[i][3] = btScalar(-1e30);
              }
       }
       
       //todo: could do the batch inside the callback!


       for (int j=0;j<numVectors;j++)
       {
              const btVector3& vec = vectors[j];
              LocalSupportVertexCallback  supportCallback(vec);
              btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
              m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
              supportVerticesOut[j] = supportCallback.GetSupportVertexLocal();
       }
       
}

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 btConvexTriangleMeshShape::getEdge ( int  i,
btPoint3 pa,
btPoint3 pb 
) const [virtual]

Implements btPolyhedralConvexShape.

Definition at line 164 of file btConvexTriangleMeshShape.cpp.

{
       btAssert(0);  
}
const btVector3& btConvexInternalShape::getImplicitShapeDimensions ( ) const [inline, inherited]

Definition at line 40 of file btConvexInternalShape.h.

Reimplemented from btConvexInternalShape.

Definition at line 202 of file btConvexTriangleMeshShape.cpp.

{
       return m_stridingMesh->getScaling();
}

Here is the call graph for this function:

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;
       }

Definition at line 19 of file btConvexTriangleMeshShape.h.

       {
              return m_stridingMesh;
       }

Here is the caller graph for this function:

Definition at line 23 of file btConvexTriangleMeshShape.h.

       {
              return m_stridingMesh;
       }
virtual const char* btConvexTriangleMeshShape::getName ( ) const [inline, virtual]

Definition at line 35 of file btConvexTriangleMeshShape.h.

{return "ConvexTrimesh";}
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 btConvexTriangleMeshShape::getNumEdges ( ) const [virtual]

Implements btPolyhedralConvexShape.

Definition at line 159 of file btConvexTriangleMeshShape.cpp.

{
       return 0;
}
int btConvexTriangleMeshShape::getNumPlanes ( ) const [virtual]

Implements btPolyhedralConvexShape.

Definition at line 174 of file btConvexTriangleMeshShape.cpp.

{
       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;
       }

Implements btPolyhedralConvexShape.

Definition at line 152 of file btConvexTriangleMeshShape.cpp.

{
       //cache this?
       return 0;
       
}
void btConvexTriangleMeshShape::getPlane ( btVector3 planeNormal,
btPoint3 planeSupport,
int  i 
) const [virtual]

Implements btPolyhedralConvexShape.

Definition at line 179 of file btConvexTriangleMeshShape.cpp.

{
       btAssert(0);
}
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 btConvexTriangleMeshShape::getShapeType ( ) const [inline, virtual]

Definition at line 32 of file btConvexTriangleMeshShape.h.

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

Implements btPolyhedralConvexShape.

Definition at line 169 of file btConvexTriangleMeshShape.cpp.

{
       btAssert(0);
}
bool btConvexTriangleMeshShape::isInside ( const btPoint3 pt,
btScalar  tolerance 
) const [virtual]

Implements btPolyhedralConvexShape.

Definition at line 185 of file btConvexTriangleMeshShape.cpp.

{
       btAssert(0);
       return false;
}

Reimplemented from btConvexInternalShape.

Definition at line 125 of file btConvexTriangleMeshShape.cpp.

{
       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;
}

Here is the call graph for this function:

Reimplemented from btPolyhedralConvexShape.

Definition at line 76 of file btConvexTriangleMeshShape.cpp.

{
       btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));

       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;
       }

       LocalSupportVertexCallback  supportCallback(vec);
       btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
       m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
       supVec = supportCallback.GetSupportVertexLocal();

       return supVec;
}

Here is the call graph for this function:

Here is the caller 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 btConvexTriangleMeshShape::setLocalScaling ( const btVector3 scaling) [virtual]

Reimplemented from btConvexInternalShape.

Definition at line 193 of file btConvexTriangleMeshShape.cpp.

Here is the call graph for this function:

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:


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.

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 14 of file btConvexTriangleMeshShape.h.


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