1
#ifndef CONVEX_TRIANGLEMESH_SHAPE_H
2
#define CONVEX_TRIANGLEMESH_SHAPE_H
5
#include "btPolyhedralConvexShape.h"
6
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
9
/// The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good as btConvexHullShape.
10
/// A small benefit of this class is that it uses the btStridingMeshInterface, so you can avoid the duplication of the triangle mesh data. Nevertheless, most users should use the much better performing btConvexHullShape instead.
11
class btConvexTriangleMeshShape : public btPolyhedralConvexShape
14
class btStridingMeshInterface* m_stridingMesh;
17
btConvexTriangleMeshShape(btStridingMeshInterface* meshInterface, bool calcAabb = true);
19
class btStridingMeshInterface* getMeshInterface()
21
return m_stridingMesh;
23
const class btStridingMeshInterface* getMeshInterface() const
25
return m_stridingMesh;
28
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
29
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
30
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
32
virtual int getShapeType()const { return CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; }
35
virtual const char* getName()const {return "ConvexTrimesh";}
37
virtual int getNumVertices() const;
38
virtual int getNumEdges() const;
39
virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
40
virtual void getVertex(int i,btPoint3& vtx) const;
41
virtual int getNumPlanes() const;
42
virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
43
virtual bool isInside(const btPoint3& pt,btScalar tolerance) const;
46
virtual void setLocalScaling(const btVector3& scaling);
47
virtual const btVector3& getLocalScaling() const;
49
///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia
50
///and the center of mass to the current coordinate system. A mass of 1 is assumed, for other masses just multiply the computed "inertia"
51
///by the mass. The resulting transform "principal" has to be applied inversely to the mesh in order for the local coordinate system of the
52
///shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform
53
///of the collision object by the principal transform. This method also computes the volume of the convex mesh.
54
void calculatePrincipalAxisTransform(btTransform& principal, btVector3& inertia, btScalar& volume) const;
60
#endif //CONVEX_TRIANGLEMESH_SHAPE_H