Back to index

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

btCapsuleShapeZ represents a capsule around the Z axis the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps. More...

#include <btCapsuleShape.h>

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

List of all members.

Public Member Functions

 btCapsuleShapeZ (btScalar radius, btScalar height)
virtual const char * getName () const
virtual void calculateLocalInertia (btScalar mass, btVector3 &inertia) const
 CollisionShape Interface.
virtual btVector3 localGetSupportingVertexWithoutMargin (const btVector3 &vec) const
 btConvexShape Interface
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin (const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
virtual int getShapeType () 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
int getUpAxis () const
btScalar getRadius () const
btScalar getHalfHeight () const
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

Protected Attributes

int m_upAxis
btVector3 m_localScaling
btVector3 m_implicitShapeDimensions
btScalar m_collisionMargin
btScalar m_padding

Detailed Description

btCapsuleShapeZ represents a capsule around the Z axis the total height is height+2*radius, so the height is just the height between the center of each 'sphere' of the capsule caps.

Definition at line 103 of file btCapsuleShape.h.


Constructor & Destructor Documentation

Definition at line 162 of file btCapsuleShape.cpp.

{
       m_upAxis = 2;
       m_implicitShapeDimensions.setValue(radius,radius,0.5f*height);
}

Here is the call graph for this function:


Member Function Documentation

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

Implements btConvexInternalShape.

Definition at line 82 of file btCapsuleShape.cpp.

{

       
       btScalar radius = getRadius();

       for (int j=0;j<numVectors;j++)
       {
              btScalar maxDot(btScalar(-1e30));
              const btVector3& vec = vectors[j];

              btVector3 vtx;
              btScalar newDot;
              {
                     btVector3 pos(0,0,0);
                     pos[getUpAxis()] = getHalfHeight();
                     vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
                     newDot = vec.dot(vtx);
                     if (newDot > maxDot)
                     {
                            maxDot = newDot;
                            supportVerticesOut[j] = vtx;
                     }
              }
              {
                     btVector3 pos(0,0,0);
                     pos[getUpAxis()] = -getHalfHeight();
                     vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
                     newDot = vec.dot(vtx);
                     if (newDot > maxDot)
                     {
                            maxDot = newDot;
                            supportVerticesOut[j] = vtx;
                     }
              }
              
       }
}

Here is the call graph for this function:

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

CollisionShape Interface.

Definition at line 122 of file btCapsuleShape.cpp.

{
       //as an approximation, take the inertia of the box that bounds the spheres

       btTransform ident;
       ident.setIdentity();

       
       btScalar radius = getRadius();

       btVector3 halfExtents(radius,radius,radius);
       halfExtents[getUpAxis()]+=getHalfHeight();

       btScalar margin = CONVEX_DISTANCE_MARGIN;

       btScalar lx=btScalar(2.)*(halfExtents[0]+margin);
       btScalar ly=btScalar(2.)*(halfExtents[1]+margin);
       btScalar lz=btScalar(2.)*(halfExtents[2]+margin);
       const btScalar x2 = lx*lx;
       const btScalar y2 = ly*ly;
       const btScalar z2 = lz*lz;
       const btScalar scaledmass = mass * btScalar(.08333333);

       inertia[0] = scaledmass * (y2+z2);
       inertia[1] = scaledmass * (x2+z2);
       inertia[2] = scaledmass * (x2+y2);

}

Here is the call graph for this function:

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

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

Reimplemented from btConvexInternalShape.

Definition at line 48 of file btCapsuleShape.h.

       {
                     btVector3 halfExtents(getRadius(),getRadius(),getRadius());
                     halfExtents[m_upAxis] = getRadius() + getHalfHeight();
                     btMatrix3x3 abs_b = t.getBasis().absolute();  
                     btPoint3 center = t.getOrigin();
                     btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));             
                     extent += btVector3(getMargin(),getMargin(),getMargin());
                     aabbMin = center - extent;
                     aabbMax = center + extent;
       }

Here is the call 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:

btScalar btCapsuleShape::getHalfHeight ( ) const [inline, inherited]

Definition at line 76 of file btCapsuleShape.h.

Here is the caller graph for this function:

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

Definition at line 40 of file btConvexInternalShape.h.

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* btCapsuleShapeZ::getName ( ) const [inline, virtual]

Reimplemented from btCapsuleShape.

Definition at line 109 of file btCapsuleShape.h.

       {
              return "CapsuleZ";
       }
virtual int btConvexInternalShape::getNumPreferredPenetrationDirections ( ) const [inline, virtual, inherited]

Reimplemented in btBoxShape, and btTriangleShape.

Definition at line 81 of file btConvexInternalShape.h.

       {
              return 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);
       }
btScalar btCapsuleShape::getRadius ( ) const [inline, inherited]

Definition at line 70 of file btCapsuleShape.h.

       {
              int radiusAxis = (m_upAxis+2)%3;
              return m_implicitShapeDimensions[radiusAxis];
       }

Here is the caller graph for this function:

virtual int btCapsuleShape::getShapeType ( ) const [inline, virtual, inherited]

Definition at line 46 of file btCapsuleShape.h.

int btCapsuleShape::getUpAxis ( ) const [inline, inherited]

Definition at line 65 of file btCapsuleShape.h.

       {
              return m_upAxis;
       }

Here is the caller graph for this function:

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:

btVector3 btCapsuleShape::localGetSupportingVertexWithoutMargin ( const btVector3 vec) const [virtual, inherited]

btConvexShape Interface

Implements btConvexInternalShape.

Definition at line 29 of file btCapsuleShape.cpp.

{

       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;
       
       btScalar radius = getRadius();


       {
              btVector3 pos(0,0,0);
              pos[getUpAxis()] = getHalfHeight();

              vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
              newDot = vec.dot(vtx);
              if (newDot > maxDot)
              {
                     maxDot = newDot;
                     supVec = vtx;
              }
       }
       {
              btVector3 pos(0,0,0);
              pos[getUpAxis()] = -getHalfHeight();

              vtx = pos +vec*m_localScaling*(radius) - vec * getMargin();
              newDot = vec.dot(vtx);
              if (newDot > maxDot)
              {
                     maxDot = newDot;
                     supVec = vtx;
              }
       }

       return supVec;

}

Here is the call graph for this function:

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:


Member Data Documentation

Definition at line 18 of file btConvexInternalShape.h.

Definition at line 16 of file btConvexInternalShape.h.

Definition at line 14 of file btConvexInternalShape.h.

Definition at line 20 of file btConvexInternalShape.h.

int btCapsuleShape::m_upAxis [protected, inherited]

Definition at line 29 of file btCapsuleShape.h.


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