Back to index

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

btBoxShape implements both a feature based (vertex/edge/plane) and implicit (getSupportingVertex) Box More...

#include <btBoxShape.h>

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

List of all members.

Public Member Functions

btVector3 getHalfExtentsWithMargin () const
const btVector3getHalfExtentsWithoutMargin () const
virtual int getShapeType () const
virtual btVector3 localGetSupportingVertex (const btVector3 &vec) const
SIMD_FORCE_INLINE btVector3 localGetSupportingVertexWithoutMargin (const btVector3 &vec) const
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin (const btVector3 *vectors, btVector3 *supportVerticesOut, int numVectors) const
 btBoxShape (const btVector3 &boxHalfExtents)
virtual void setMargin (btScalar collisionMargin)
virtual void setLocalScaling (const btVector3 &scaling)
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
virtual void calculateLocalInertia (btScalar mass, btVector3 &inertia) const
virtual void getPlane (btVector3 &planeNormal, btPoint3 &planeSupport, int i) const
virtual int getNumPlanes () const
virtual int getNumVertices () const
virtual int getNumEdges () const
virtual void getVertex (int i, btVector3 &vtx) const
virtual void getPlaneEquation (btVector4 &plane, int i) const
virtual void getEdge (int i, btPoint3 &pa, btPoint3 &pb) const
virtual bool isInside (const btPoint3 &pt, btScalar tolerance) const
virtual const char * getName () const
virtual int getNumPreferredPenetrationDirections () const
virtual void getPreferredPenetrationDirection (int index, btVector3 &penetrationVector) const
void getNonvirtualAabb (const btTransform &trans, btVector3 &aabbMin, btVector3 &aabbMax, btScalar margin) const
void recalcLocalAabb ()
const btVector3getImplicitShapeDimensions () const
virtual void getAabbSlow (const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
virtual const btVector3getLocalScaling () const
const btVector3getLocalScalingNV () const
virtual btScalar getMargin () const
btScalar getMarginNV () 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

Detailed Description

btBoxShape implements both a feature based (vertex/edge/plane) and implicit (getSupportingVertex) Box

Definition at line 26 of file btBoxShape.h.


Constructor & Destructor Documentation

btBoxShape::btBoxShape ( const btVector3 boxHalfExtents) [inline]

Definition at line 85 of file btBoxShape.h.

       {
              btVector3 margin(getMargin(),getMargin(),getMargin());
              m_implicitShapeDimensions = (boxHalfExtents * m_localScaling) - margin;
       };

Here is the call graph for this function:


Member Function Documentation

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

Reimplemented from btPolyhedralConvexShape.

Reimplemented in btCylinderShapeZ, btCylinderShapeX, and btCylinderShape.

Definition at line 70 of file btBoxShape.h.

       {
              const btVector3& halfExtents = getHalfExtentsWithoutMargin();
       
              for (int i=0;i<numVectors;i++)
              {
                     const btVector3& vec = vectors[i];
                     supportVerticesOut[i].setValue(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
                            btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
                            btFsels(vec.z(), halfExtents.z(), -halfExtents.z())); 
              }

       }

Here is the call graph for this function:

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

Reimplemented from btPolyhedralConvexShape.

Definition at line 40 of file btBoxShape.cpp.

{
       //btScalar margin = btScalar(0.);
       btVector3 halfExtents = getHalfExtentsWithMargin();

       btScalar lx=btScalar(2.)*(halfExtents.x());
       btScalar ly=btScalar(2.)*(halfExtents.y());
       btScalar lz=btScalar(2.)*(halfExtents.z());

       inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz),
                                   mass/(btScalar(12.0)) * (lx*lx + lz*lz),
                                   mass/(btScalar(12.0)) * (lx*lx + ly*ly));

}

Here is the call graph for this function:

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

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

Reimplemented from btPolyhedralConvexShape.

Reimplemented in btCylinderShape.

Definition at line 22 of file btBoxShape.cpp.

{
       const btVector3& halfExtents = getHalfExtentsWithoutMargin();

       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:

virtual void btBoxShape::getEdge ( int  i,
btPoint3 pa,
btPoint3 pb 
) const [inline, virtual]

Implements btPolyhedralConvexShape.

Definition at line 193 of file btBoxShape.h.

       {
              int edgeVert0 = 0;
              int edgeVert1 = 0;

              switch (i)
              {
              case 0:
                            edgeVert0 = 0;
                            edgeVert1 = 1;
                     break;
              case 1:
                            edgeVert0 = 0;
                            edgeVert1 = 2;
                     break;
              case 2:
                     edgeVert0 = 1;
                     edgeVert1 = 3;

                     break;
              case 3:
                     edgeVert0 = 2;
                     edgeVert1 = 3;
                     break;
              case 4:
                     edgeVert0 = 0;
                     edgeVert1 = 4;
                     break;
              case 5:
                     edgeVert0 = 1;
                     edgeVert1 = 5;

                     break;
              case 6:
                     edgeVert0 = 2;
                     edgeVert1 = 6;
                     break;
              case 7:
                     edgeVert0 = 3;
                     edgeVert1 = 7;
                     break;
              case 8:
                     edgeVert0 = 4;
                     edgeVert1 = 5;
                     break;
              case 9:
                     edgeVert0 = 4;
                     edgeVert1 = 6;
                     break;
              case 10:
                     edgeVert0 = 5;
                     edgeVert1 = 7;
                     break;
              case 11:
                     edgeVert0 = 6;
                     edgeVert1 = 7;
                     break;
              default:
                     btAssert(0);

              }

              getVertex(edgeVert0,pa );
              getVertex(edgeVert1,pb );
       }

Here is the call graph for this function:

Definition at line 34 of file btBoxShape.h.

       {
              btVector3 halfExtents = getHalfExtentsWithoutMargin();
              btVector3 margin(getMargin(),getMargin(),getMargin());
              halfExtents += margin;
              return halfExtents;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 42 of file btBoxShape.h.

       {
              return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included
       }

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

Reimplemented in btCylinderShapeZ, btCylinderShapeX, and btCylinderShape.

Definition at line 282 of file btBoxShape.h.

       {
              return "Box";
       }
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:

virtual int btBoxShape::getNumEdges ( ) const [inline, virtual]

Implements btPolyhedralConvexShape.

Definition at line 140 of file btBoxShape.h.

       {
              return 12;
       }
virtual int btBoxShape::getNumPlanes ( ) const [inline, virtual]

Implements btPolyhedralConvexShape.

Definition at line 130 of file btBoxShape.h.

       {
              return 6;
       }      
virtual int btBoxShape::getNumPreferredPenetrationDirections ( ) const [inline, virtual]

Reimplemented from btConvexInternalShape.

Definition at line 287 of file btBoxShape.h.

       {
              return 6;
       }
virtual int btBoxShape::getNumVertices ( ) const [inline, virtual]

Implements btPolyhedralConvexShape.

Definition at line 135 of file btBoxShape.h.

       {
              return 8;
       }
virtual void btBoxShape::getPlane ( btVector3 planeNormal,
btPoint3 planeSupport,
int  i 
) const [inline, virtual]

Implements btPolyhedralConvexShape.

Definition at line 120 of file btBoxShape.h.

       {
              //this plane might not be aligned...
              btVector4 plane ;
              getPlaneEquation(plane,i);
              planeNormal = btVector3(plane.getX(),plane.getY(),plane.getZ());
              planeSupport = localGetSupportingVertex(-planeNormal);
       }

Here is the call graph for this function:

virtual void btBoxShape::getPlaneEquation ( btVector4 plane,
int  i 
) const [inline, virtual]

Definition at line 157 of file btBoxShape.h.

       {
              btVector3 halfExtents = getHalfExtentsWithoutMargin();

              switch (i)
              {
              case 0:
                     plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
                     plane[3] = -halfExtents.x();
                     break;
              case 1:
                     plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
                     plane[3] = -halfExtents.x();
                     break;
              case 2:
                     plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
                     plane[3] = -halfExtents.y();
                     break;
              case 3:
                     plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
                     plane[3] = -halfExtents.y();
                     break;
              case 4:
                     plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
                     plane[3] = -halfExtents.z();
                     break;
              case 5:
                     plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
                     plane[3] = -halfExtents.z();
                     break;
              default:
                     assert(0);
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void btBoxShape::getPreferredPenetrationDirection ( int  index,
btVector3 penetrationVector 
) const [inline, virtual]

Reimplemented from btConvexInternalShape.

Definition at line 292 of file btBoxShape.h.

       {
              switch (index)
              {
              case 0:
                     penetrationVector.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
                     break;
              case 1:
                     penetrationVector.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
                     break;
              case 2:
                     penetrationVector.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
                     break;
              case 3:
                     penetrationVector.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
                     break;
              case 4:
                     penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
                     break;
              case 5:
                     penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
                     break;
              default:
                     assert(0);
              }
       }

Here is the call graph for this function:

virtual int btBoxShape::getShapeType ( ) const [inline, virtual]

Reimplemented in btCylinderShape.

Definition at line 48 of file btBoxShape.h.

virtual void btBoxShape::getVertex ( int  i,
btVector3 vtx 
) const [inline, virtual]

Implements btPolyhedralConvexShape.

Definition at line 146 of file btBoxShape.h.

       {
              btVector3 halfExtents = getHalfExtentsWithoutMargin();

              vtx = btVector3(
                            halfExtents.x() * (1-(i&1)) - halfExtents.x() * (i&1),
                            halfExtents.y() * (1-((i&2)>>1)) - halfExtents.y() * ((i&2)>>1),
                            halfExtents.z() * (1-((i&4)>>2)) - halfExtents.z() * ((i&4)>>2));
       }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool btBoxShape::isInside ( const btPoint3 pt,
btScalar  tolerance 
) const [inline, virtual]

Implements btPolyhedralConvexShape.

Definition at line 264 of file btBoxShape.h.

       {
              btVector3 halfExtents = getHalfExtentsWithoutMargin();

              //btScalar minDist = 2*tolerance;
              
              bool result = (pt.x() <= (halfExtents.x()+tolerance)) &&
                                          (pt.x() >= (-halfExtents.x()-tolerance)) &&
                                          (pt.y() <= (halfExtents.y()+tolerance)) &&
                                          (pt.y() >= (-halfExtents.y()-tolerance)) &&
                                          (pt.z() <= (halfExtents.z()+tolerance)) &&
                                          (pt.z() >= (-halfExtents.z()-tolerance));
              
              return result;
       }

Here is the call graph for this function:

virtual btVector3 btBoxShape::localGetSupportingVertex ( const btVector3 vec) const [inline, virtual]

Reimplemented from btConvexInternalShape.

Reimplemented in btCylinderShape.

Definition at line 50 of file btBoxShape.h.

       {
              btVector3 halfExtents = getHalfExtentsWithoutMargin();
              btVector3 margin(getMargin(),getMargin(),getMargin());
              halfExtents += margin;
              
              return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
                     btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
                     btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from btPolyhedralConvexShape.

Reimplemented in btCylinderShapeZ, btCylinderShapeX, and btCylinderShape.

Definition at line 61 of file btBoxShape.h.

       {
              const btVector3& halfExtents = getHalfExtentsWithoutMargin();
              
              return btVector3(btFsels(vec.x(), halfExtents.x(), -halfExtents.x()),
                     btFsels(vec.y(), halfExtents.y(), -halfExtents.y()),
                     btFsels(vec.z(), halfExtents.z(), -halfExtents.z()));
       }

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:

virtual void btBoxShape::setLocalScaling ( const btVector3 scaling) [inline, virtual]

Reimplemented from btConvexInternalShape.

Definition at line 102 of file btBoxShape.h.

       {
              btVector3 oldMargin(getMargin(),getMargin(),getMargin());
              btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
              btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;

              btConvexInternalShape::setLocalScaling(scaling);

              m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;

       }

Here is the call graph for this function:

virtual void btBoxShape::setMargin ( btScalar  collisionMargin) [inline, virtual]

Reimplemented from btConvexInternalShape.

Definition at line 91 of file btBoxShape.h.

       {
              //correct the m_implicitShapeDimensions for the margin
              btVector3 oldMargin(getMargin(),getMargin(),getMargin());
              btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
              
              btConvexInternalShape::setMargin(collisionMargin);
              btVector3 newMargin(getMargin(),getMargin(),getMargin());
              m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;

       }

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


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