Back to index

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

  btStridingMeshInterface is the interface class for high performance access to triangle meshes

It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory. More...

#include <btStridingMeshInterface.h>

Collaboration diagram for btStridingMeshInterface:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 btStridingMeshInterface ()
virtual ~btStridingMeshInterface ()
void InternalProcessAllTriangles (btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
void calculateAabbBruteForce (btVector3 &aabbMin, btVector3 &aabbMax)
 brute force method to calculate aabb
virtual void getLockedVertexIndexBase (unsigned char **vertexbase, int &numverts, PHY_ScalarType &type, int &stride, unsigned char **indexbase, int &indexstride, int &numfaces, PHY_ScalarType &indicestype, int subpart=0)=0
 get read and write access to a subpart of a triangle mesh this subpart has a continuous array of vertices and indices in this way the mesh can be handled as chunks of memory with striding very similar to OpenGL vertexarray support make a call to unLockVertexBase when the read and write access is finished
virtual void getLockedReadOnlyVertexIndexBase (const unsigned char **vertexbase, int &numverts, PHY_ScalarType &type, int &stride, const unsigned char **indexbase, int &indexstride, int &numfaces, PHY_ScalarType &indicestype, int subpart=0) const =0
virtual void unLockVertexBase (int subpart)=0
 unLockVertexBase finishes the access to a subpart of the triangle mesh make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished
virtual void unLockReadOnlyVertexBase (int subpart) const =0
virtual int getNumSubParts () const =0
 getNumSubParts returns the number of seperate subparts each subpart has a continuous array of vertices and indices
virtual void preallocateVertices (int numverts)=0
virtual void preallocateIndices (int numindices)=0
const btVector3getScaling () const
void setScaling (const btVector3 &scaling)

Protected Attributes

btVector3 m_scaling

Detailed Description

  btStridingMeshInterface is the interface class for high performance access to triangle meshes

It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.

Definition at line 34 of file btStridingMeshInterface.h.


Constructor & Destructor Documentation

Definition at line 41 of file btStridingMeshInterface.h.

                                        :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.))
              {

              }

Definition at line 18 of file btStridingMeshInterface.cpp.

{

}

Member Function Documentation

brute force method to calculate aabb

Definition at line 88 of file btStridingMeshInterface.cpp.

{

       struct AabbCalculationCallback : public btInternalTriangleIndexCallback
       {
              btVector3     m_aabbMin;
              btVector3     m_aabbMax;

              AabbCalculationCallback()
              {
                     m_aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
                     m_aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
              }

              virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int  triangleIndex)
              {
                     (void)partId;
                     (void)triangleIndex;

                     m_aabbMin.setMin(triangle[0]);
                     m_aabbMax.setMax(triangle[0]);
                     m_aabbMin.setMin(triangle[1]);
                     m_aabbMax.setMax(triangle[1]);
                     m_aabbMin.setMin(triangle[2]);
                     m_aabbMax.setMax(triangle[2]);
              }
       };

              //first calculate the total aabb for all triangles
       AabbCalculationCallback     aabbCallback;
       aabbMin.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
       aabbMax.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
       InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax);

       aabbMin = aabbCallback.m_aabbMin;
       aabbMax = aabbCallback.m_aabbMax;
}

Here is the call graph for this function:

virtual void btStridingMeshInterface::getLockedReadOnlyVertexIndexBase ( const unsigned char **  vertexbase,
int &  numverts,
PHY_ScalarType type,
int &  stride,
const unsigned char **  indexbase,
int &  indexstride,
int &  numfaces,
PHY_ScalarType indicestype,
int  subpart = 0 
) const [pure virtual]

Here is the caller graph for this function:

virtual void btStridingMeshInterface::getLockedVertexIndexBase ( unsigned char **  vertexbase,
int &  numverts,
PHY_ScalarType type,
int &  stride,
unsigned char **  indexbase,
int &  indexstride,
int &  numfaces,
PHY_ScalarType indicestype,
int  subpart = 0 
) [pure virtual]

get read and write access to a subpart of a triangle mesh this subpart has a continuous array of vertices and indices in this way the mesh can be handled as chunks of memory with striding very similar to OpenGL vertexarray support make a call to unLockVertexBase when the read and write access is finished

virtual int btStridingMeshInterface::getNumSubParts ( ) const [pure virtual]

getNumSubParts returns the number of seperate subparts each subpart has a continuous array of vertices and indices

Here is the caller graph for this function:

Definition at line 78 of file btStridingMeshInterface.h.

                                                      {
                     return m_scaling;
              }

Here is the caller graph for this function:

void btStridingMeshInterface::InternalProcessAllTriangles ( btInternalTriangleIndexCallback callback,
const btVector3 aabbMin,
const btVector3 aabbMax 
) const

if the number of parts is big, the performance might drop due to the innerloop switch on indextype

Definition at line 24 of file btStridingMeshInterface.cpp.

{
       (void)aabbMin;
       (void)aabbMax;
       int numtotalphysicsverts = 0;
       int part,graphicssubparts = getNumSubParts();
       const unsigned char * vertexbase;
       const unsigned char * indexbase;
       int indexstride;
       PHY_ScalarType type;
       PHY_ScalarType gfxindextype;
       int stride,numverts,numtriangles;
       int gfxindex;
       btVector3 triangle[3];
       btScalar* graphicsbase;

       btVector3 meshScaling = getScaling();

       for (part=0;part<graphicssubparts ;part++)
       {
              getLockedReadOnlyVertexIndexBase(&vertexbase,numverts,type,stride,&indexbase,indexstride,numtriangles,gfxindextype,part);
              numtotalphysicsverts+=numtriangles*3; //upper bound

              switch (gfxindextype)
              {
              case PHY_INTEGER:
                     {
                            for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
                            {
                                   int* tri_indices= (int*)(indexbase+gfxindex*indexstride);
                                   graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
                                   triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
                                   graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
                                   triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),       graphicsbase[2]*meshScaling.getZ());
                                   graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
                                   triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),       graphicsbase[2]*meshScaling.getZ());
                                   callback->internalProcessTriangleIndex(triangle,part,gfxindex);
                            }
                            break;
                     }
              case PHY_SHORT:
                     {
                            for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
                            {
                                   short int* tri_indices= (short int*)(indexbase+gfxindex*indexstride);
                                   graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
                                   triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
                                   graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
                                   triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),       graphicsbase[2]*meshScaling.getZ());
                                   graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
                                   triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),       graphicsbase[2]*meshScaling.getZ());
                                   callback->internalProcessTriangleIndex(triangle,part,gfxindex);
                            }
                            break;
                     }
              default:
                     btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
              }

              unLockReadOnlyVertexBase(part);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void btStridingMeshInterface::preallocateIndices ( int  numindices) [pure virtual]
virtual void btStridingMeshInterface::preallocateVertices ( int  numverts) [pure virtual]
void btStridingMeshInterface::setScaling ( const btVector3 scaling) [inline]

Definition at line 81 of file btStridingMeshInterface.h.

              {
                     m_scaling = scaling;
              }

Here is the caller graph for this function:

virtual void btStridingMeshInterface::unLockReadOnlyVertexBase ( int  subpart) const [pure virtual]

Here is the caller graph for this function:

virtual void btStridingMeshInterface::unLockVertexBase ( int  subpart) [pure virtual]

unLockVertexBase finishes the access to a subpart of the triangle mesh make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished


Member Data Documentation

Definition at line 38 of file btStridingMeshInterface.h.


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