Bullet Collision Detection & Physics Library: btTriangleMesh Class Reference

Bullet Collision Detection & Physics Library

Public Member Functions | Public Attributes | Private Attributes | List of all members
btTriangleMesh Class Reference

The btTriangleMesh class is a convenience class derived from btTriangleIndexVertexArray, that provides storage for a concave triangle mesh. More...

`#include <btTriangleMesh.h>`

Inheritance diagram for btTriangleMesh:
[legend]
Collaboration diagram for btTriangleMesh:
[legend]

## Public Member Functions
| btTriangleMesh (bool use32bitIndices=true, bool use4componentVertices=true)
bool | getUse32bitIndices () const
bool | getUse4componentVertices () const
void | addTriangle (const btVector3 &vertex0, const btVector3 &vertex1, const btVector3 &vertex2, bool removeDuplicateVertices=false)
| By default addTriangle won't search for duplicate vertices, because the search is very slow for large triangle meshes.
void | addTriangleIndices (int index1, int index2, int index3)
| Add a triangle using its indices. Make sure the indices are pointing within the vertices array, so add the vertices first (and to be sure, avoid removal of duplicate vertices).
int | getNumTriangles () const
virtual void | preallocateVertices (int numverts)
virtual void | preallocateIndices (int numindices)
int | findOrAddVertex (const btVector3 &vertex, bool removeDuplicateVertices)
| findOrAddVertex is an internal method, use addTriangle instead
void | addIndex (int index)
| addIndex is an internal method, use addTriangle instead
Public Member Functions inherited from btTriangleIndexVertexArray
| BT_DECLARE_ALIGNED_ALLOCATOR ()
| btTriangleIndexVertexArray ()
virtual | ~btTriangleIndexVertexArray ()
| btTriangleIndexVertexArray (int numTriangles, int *triangleIndexBase, int triangleIndexStride, int numVertices, btScalar *vertexBase, int vertexStride)
void | addIndexedMesh (const btIndexedMesh &mesh, PHY_ScalarType indexType=PHY_INTEGER)
virtual void | getLockedVertexIndexBase (unsigned char **vertexbase, int &numverts, PHY_ScalarType &type, int &vertexStride, unsigned char **indexbase, int &indexstride, int &numfaces, PHY_ScalarType &indicestype, int subpart=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 &vertexStride, const unsigned char **indexbase, int &indexstride, int &numfaces, PHY_ScalarType &indicestype, int subpart=0) const
virtual void | unLockVertexBase (int subpart)
| 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
virtual int | getNumSubParts () const
| getNumSubParts returns the number of separate subparts each subpart has a continuous array of vertices and indices
IndexedMeshArray & | getIndexedMeshArray ()
const IndexedMeshArray & | getIndexedMeshArray () const
virtual bool | hasPremadeAabb () const
virtual void | setPremadeAabb (const btVector3 &aabbMin, const btVector3 &aabbMax) const
virtual void | getPremadeAabb (btVector3 *aabbMin, btVector3 *aabbMax) const
Public Member Functions inherited from btStridingMeshInterface
| BT_DECLARE_ALIGNED_ALLOCATOR ()
| btStridingMeshInterface ()
virtual | ~btStridingMeshInterface ()
virtual void | InternalProcessAllTriangles (btInternalTriangleIndexCallback *callback, const btVector3 &aabbMin, const btVector3 &aabbMax) const
void | calculateAabbBruteForce (btVector3 &aabbMin, btVector3 &aabbMax)
| brute force method to calculate aabb
const btVector3 & | getScaling () const
void | setScaling (const btVector3 &scaling)
virtual int | calculateSerializeBufferSize () const
virtual const char * | serialize (void *dataBuffer, btSerializer *serializer) const
| fills the dataBuffer and returns the struct name (and 0 on failure)

## Public Attributes
btScalar | m_weldingThreshold

## Private Attributes
btAlignedObjectArray< btVector3 > | m_4componentVertices
btAlignedObjectArray< btScalar > | m_3componentVertices
btAlignedObjectArray< unsigned int > | m_32bitIndices
btAlignedObjectArray< unsigned short int > | m_16bitIndices
bool | m_use32bitIndices
bool | m_use4componentVertices

## Additional Inherited Members
Protected Attributes inherited from btTriangleIndexVertexArray
IndexedMeshArray | m_indexedMeshes
int | m_pad [2]
int | m_hasAabb
btVector3 | m_aabbMin
btVector3 | m_aabbMax
Protected Attributes inherited from btStridingMeshInterface
btVector3 | m_scaling

## Detailed Description

The btTriangleMesh class is a convenience class derived from btTriangleIndexVertexArray, that provides storage for a concave triangle mesh.

It can be used as data for the btBvhTriangleMeshShape. It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices. If you want to share triangle/index data between graphics mesh and collision mesh (btBvhTriangleMeshShape), you can directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface. Performance of btTriangleMesh and btTriangleIndexVertexArray used in a btBvhTriangleMeshShape is the same.

Definition at line 27 of file btTriangleMesh.h.

## Constructor & Destructor Documentation

## ◆ btTriangleMesh()

btTriangleMesh::btTriangleMesh | ( | bool | use32bitIndices = true,
|  | bool | use4componentVertices = true )

Definition at line 18 of file btTriangleMesh.cpp.

## Member Function Documentation

## ◆ addIndex()

void btTriangleMesh::addIndex | ( | int | index | ) |

addIndex is an internal method, use addTriangle instead

Definition at line 62 of file btTriangleMesh.cpp.

## ◆ addTriangle()

void btTriangleMesh::addTriangle | ( | const btVector3 & | vertex0,
|  | const btVector3 & | vertex1,
|  | const btVector3 & | vertex2,
|  | bool | removeDuplicateVertices = false )

By default addTriangle won't search for duplicate vertices, because the search is very slow for large triangle meshes.

In general it is better to directly use btTriangleIndexVertexArray instead.

Definition at line 128 of file btTriangleMesh.cpp.

## ◆ addTriangleIndices()

void btTriangleMesh::addTriangleIndices | ( | int | index1,
|  | int | index2,
|  | int | index3 )

Add a triangle using its indices. Make sure the indices are pointing within the vertices array, so add the vertices first (and to be sure, avoid removal of duplicate vertices).

Definition at line 76 of file btTriangleMesh.cpp.

## ◆ findOrAddVertex()

int btTriangleMesh::findOrAddVertex | ( | const btVector3 & | vertex,
|  | bool | removeDuplicateVertices )

findOrAddVertex is an internal method, use addTriangle instead

Definition at line 84 of file btTriangleMesh.cpp.

## ◆ getNumTriangles()

int btTriangleMesh::getNumTriangles | ( |  | ) | const

Definition at line 136 of file btTriangleMesh.cpp.

## ◆ getUse32bitIndices()

bool btTriangleMesh::getUse32bitIndices | ( |  | ) | const
| inline

Definition at line 42 of file btTriangleMesh.h.

## ◆ getUse4componentVertices()

bool btTriangleMesh::getUse4componentVertices | ( |  | ) | const
| inline

Definition at line 47 of file btTriangleMesh.h.

## ◆ preallocateIndices()

void btTriangleMesh::preallocateIndices | ( | int | numindices | ) |
| virtual

Reimplemented from btTriangleIndexVertexArray.

Definition at line 157 of file btTriangleMesh.cpp.

## ◆ preallocateVertices()

void btTriangleMesh::preallocateVertices | ( | int | numverts | ) |
| virtual

Reimplemented from btTriangleIndexVertexArray.

Definition at line 145 of file btTriangleMesh.cpp.

## Member Data Documentation

## ◆ m_16bitIndices

btAlignedObjectArray<unsigned short int> btTriangleMesh::m_16bitIndices
| private

Definition at line 33 of file btTriangleMesh.h.

## ◆ m_32bitIndices

btAlignedObjectArray<unsigned int> btTriangleMesh::m_32bitIndices
| private

Definition at line 32 of file btTriangleMesh.h.

## ◆ m_3componentVertices

btAlignedObjectArray<btScalar> btTriangleMesh::m_3componentVertices
| private

Definition at line 30 of file btTriangleMesh.h.

## ◆ m_4componentVertices

btAlignedObjectArray<btVector3> btTriangleMesh::m_4componentVertices
| private

Definition at line 29 of file btTriangleMesh.h.

## ◆ m_use32bitIndices

bool btTriangleMesh::m_use32bitIndices
| private

Definition at line 34 of file btTriangleMesh.h.

## ◆ m_use4componentVertices

bool btTriangleMesh::m_use4componentVertices
| private

Definition at line 35 of file btTriangleMesh.h.

## ◆ m_weldingThreshold

btScalar btTriangleMesh::m_weldingThreshold

Definition at line 38 of file btTriangleMesh.h.

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

- btTriangleMesh.h
- btTriangleMesh.cpp