Back to index

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

btShapeHull takes a btConvexShape, builds the convex hull using btConvexHull and provides triangle indices and vertices. More...

#include <btShapeHull.h>

Collaboration diagram for btShapeHull:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 btShapeHull (const btConvexShape *shape)
 ~btShapeHull ()
bool buildHull (btScalar margin)
int numTriangles () const
int numVertices () const
int numIndices () const
const btVector3getVertexPointer () const
const unsigned int * getIndexPointer () const

Protected Attributes

btAlignedObjectArray< btVector3m_vertices
btAlignedObjectArray< unsigned
int > 
m_indices
unsigned int m_numIndices
const btConvexShape * m_shape

Detailed Description

btShapeHull takes a btConvexShape, builds the convex hull using btConvexHull and provides triangle indices and vertices.

Definition at line 26 of file btShapeHull.h.


Constructor & Destructor Documentation

btShapeHull::btShapeHull ( const btConvexShape *  shape)

Definition at line 69 of file btShapeHull.cpp.

Here is the call graph for this function:

Definition at line 77 of file btShapeHull.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

bool btShapeHull::buildHull ( btScalar  margin)

Definition at line 84 of file btShapeHull.cpp.

{
       int numSampleDirections = NUM_UNITSPHERE_POINTS;
       {
              int numPDA = m_shape->getNumPreferredPenetrationDirections();
              if (numPDA)
              {
                     for (int i=0;i<numPDA;i++)
                     {
                            btVector3 norm;
                            m_shape->getPreferredPenetrationDirection(i,norm);
                            btUnitSpherePoints[numSampleDirections] = norm;
                            numSampleDirections++;
                     }
              }
       }

       btVector3 supportPoints[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2];
       int i;
       for (i = 0; i < numSampleDirections; i++)
       {
              supportPoints[i] = m_shape->localGetSupportingVertex(btUnitSpherePoints[i]);
       }

       HullDesc hd;
       hd.mFlags = QF_TRIANGLES;
       hd.mVcount = numSampleDirections;

#ifdef BT_USE_DOUBLE_PRECISION
       hd.mVertices = &supportPoints[0];
       hd.mVertexStride = sizeof(btVector3);
#else
       hd.mVertices = &supportPoints[0];
       hd.mVertexStride = sizeof (btVector3);
#endif

       HullLibrary hl;
       HullResult hr;
       if (hl.CreateConvexHull (hd, hr) == QE_FAIL)
       {
              return false;
       }

       m_vertices.resize (hr.mNumOutputVertices);


       for (i = 0; i < (int)hr.mNumOutputVertices; i++)
       {
              m_vertices[i] = hr.m_OutputVertices[i];
       }
       m_numIndices = hr.mNumIndices;
       m_indices.resize(m_numIndices);
       for (i = 0; i < (int)m_numIndices; i++)
       {
              m_indices[i] = hr.m_Indices[i];
       }

       // free temporary hull result that we just copied
       hl.ReleaseResult (hr);

       return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const unsigned int* btShapeHull::getIndexPointer ( ) const [inline]

Definition at line 42 of file btShapeHull.h.

       {
              return &m_indices[0];
       }

Here is the caller graph for this function:

const btVector3* btShapeHull::getVertexPointer ( ) const [inline]

Definition at line 38 of file btShapeHull.h.

       {
              return &m_vertices[0];
       }

Here is the caller graph for this function:

int btShapeHull::numIndices ( ) const

Definition at line 160 of file btShapeHull.cpp.

{
       return m_numIndices;
}

Definition at line 148 of file btShapeHull.cpp.

{
       return m_numIndices / 3;
}

Here is the caller graph for this function:

int btShapeHull::numVertices ( ) const

Definition at line 154 of file btShapeHull.cpp.

{
       return m_vertices.size ();
}

Here is the call graph for this function:


Member Data Documentation

btAlignedObjectArray<unsigned int> btShapeHull::m_indices [protected]

Definition at line 49 of file btShapeHull.h.

unsigned int btShapeHull::m_numIndices [protected]

Definition at line 50 of file btShapeHull.h.

const btConvexShape* btShapeHull::m_shape [protected]

Definition at line 51 of file btShapeHull.h.

Definition at line 48 of file btShapeHull.h.


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