Back to index

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

btMultiSphereShape represents implicit convex hull of a collection of spheres (using getSupportingVertex) More...

#include <btMultiSphereShape.h>

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

List of all members.

Public Member Functions

 btMultiSphereShape (const btVector3 &inertiaHalfExtents, const btVector3 *positions, const btScalar *radi, int numSpheres)
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
int getSphereCount () const
const btVector3getSpherePosition (int index) const
btScalar getSphereRadius (int index) const
virtual int getShapeType () const
virtual const char * getName () const
virtual btVector3 localGetSupportingVertex (const btVector3 &vec) const
const btVector3getImplicitShapeDimensions () const
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
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

btVector3 m_localScaling
btVector3 m_implicitShapeDimensions
btScalar m_collisionMargin
btScalar m_padding

Private Attributes

btVector3 m_localPositions [MAX_NUM_SPHERES]
btScalar m_radi [MAX_NUM_SPHERES]
btVector3 m_inertiaHalfExtents
int m_numSpheres

Detailed Description

btMultiSphereShape represents implicit convex hull of a collection of spheres (using getSupportingVertex)

Definition at line 25 of file btMultiSphereShape.h.


Constructor & Destructor Documentation

btMultiSphereShape::btMultiSphereShape ( const btVector3 inertiaHalfExtents,
const btVector3 positions,
const btScalar radi,
int  numSpheres 
)

Definition at line 20 of file btMultiSphereShape.cpp.

:m_inertiaHalfExtents(inertiaHalfExtents)
{
       btScalar startMargin = btScalar(1e30);

       m_numSpheres = numSpheres;
       for (int i=0;i<m_numSpheres;i++)
       {
              m_localPositions[i] = positions[i];
              m_radi[i] = radi[i];
              if (radi[i] < startMargin)
                     startMargin = radi[i];
       }
       setMargin(startMargin);

}

Here is the call graph for this function:


Member Function Documentation

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

Implements btConvexInternalShape.

Definition at line 82 of file btMultiSphereShape.cpp.

{

       for (int j=0;j<numVectors;j++)
       {
              btScalar maxDot(btScalar(-1e30));

              const btVector3& vec = vectors[j];

              btVector3 vtx;
              btScalar newDot;

              const btVector3* pos = &m_localPositions[0];
              const btScalar* rad = &m_radi[0];

              for (int i=0;i<m_numSpheres;i++)
              {
                     vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
                     pos++;
                     rad++;
                     newDot = vec.dot(vtx);
                     if (newDot > maxDot)
                     {
                            maxDot = newDot;
                            supportVerticesOut[j] = vtx;
                     }
              }
       }
}

Here is the call graph for this function:

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

CollisionShape Interface.

Definition at line 119 of file btMultiSphereShape.cpp.

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

       btTransform ident;
       ident.setIdentity();
//     btVector3 aabbMin,aabbMax;

//     getAabb(ident,aabbMin,aabbMax);

       btVector3 halfExtents = m_inertiaHalfExtents;//(aabbMax - aabbMin)* btScalar(0.5);

       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:

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

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

Reimplemented in btBoxShape, btPolyhedralConvexShape, btTriangleShape, btCapsuleShape, and btCylinderShape.

Definition at line 46 of file btConvexInternalShape.h.

       {
              getAabbSlow(t,aabbMin,aabbMax);
       }

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:

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

Definition at line 66 of file btMultiSphereShape.h.

       {
              return "MultiSphere";
       }
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);
       }
virtual int btMultiSphereShape::getShapeType ( ) const [inline, virtual]

Definition at line 64 of file btMultiSphereShape.h.

int btMultiSphereShape::getSphereCount ( ) const [inline]

Definition at line 49 of file btMultiSphereShape.h.

       {
              return m_numSpheres;
       }

Here is the caller graph for this function:

const btVector3& btMultiSphereShape::getSpherePosition ( int  index) const [inline]

Definition at line 54 of file btMultiSphereShape.h.

       {
              return m_localPositions[index];
       }

Here is the caller graph for this function:

btScalar btMultiSphereShape::getSphereRadius ( int  index) const [inline]

Definition at line 59 of file btMultiSphereShape.h.

       {
              return m_radi[index];
       }

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:

btConvexShape Interface

Implements btConvexInternalShape.

Definition at line 40 of file btMultiSphereShape.cpp.

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

       btScalar maxDot(btScalar(-1e30));


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

       btVector3 vtx;
       btScalar newDot;

       const btVector3* pos = &m_localPositions[0];
       const btScalar* rad = &m_radi[0];

       for (i=0;i<m_numSpheres;i++)
       {
              vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
              pos++;
              rad++;
              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 31 of file btMultiSphereShape.h.

Definition at line 29 of file btMultiSphereShape.h.

Definition at line 14 of file btConvexInternalShape.h.

Definition at line 33 of file btMultiSphereShape.h.

Definition at line 20 of file btConvexInternalShape.h.

Definition at line 30 of file btMultiSphereShape.h.


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