add method to add triangle by its indices for btTriangleMesh

See also https://github.com/bulletphysics/bullet3/pull/315
thanks to quiasmo   for the contribution
This commit is contained in:
Erwin Coumans
2015-02-04 10:47:13 -08:00
parent d84afc11b9
commit c7671779c2
2 changed files with 11 additions and 1 deletions

View File

@@ -75,6 +75,13 @@ void btTriangleMesh::addIndex(int index)
}
}
void btTriangleMesh::addTriangleIndices(int index1, int index2, int index3 )
{
m_indexedMeshes[0].m_numTriangles++;
addIndex( index1 );
addIndex( index2 );
addIndex( index3 );
}
int btTriangleMesh::findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices)
{

View File

@@ -52,7 +52,10 @@ class btTriangleMesh : public btTriangleIndexVertexArray
///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.
void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2, bool removeDuplicateVertices=false);
///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)
void addTriangleIndices(int index1, int index2, int index3 );
int getNumTriangles() const;
virtual void preallocateVertices(int numverts);