Changeset View
Changeset View
Standalone View
Standalone View
extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleMesh.h
| Show All 20 Lines | |||||
| #include "LinearMath/btAlignedObjectArray.h" | #include "LinearMath/btAlignedObjectArray.h" | ||||
| ///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. | ///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. | ///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. | ///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. | ///Performance of btTriangleMesh and btTriangleIndexVertexArray used in a btBvhTriangleMeshShape is the same. | ||||
| class btTriangleMesh : public btTriangleIndexVertexArray | class btTriangleMesh : public btTriangleIndexVertexArray | ||||
| { | { | ||||
| btAlignedObjectArray<btVector3> m_4componentVertices; | btAlignedObjectArray<btVector3> m_4componentVertices; | ||||
| btAlignedObjectArray<btScalar> m_3componentVertices; | btAlignedObjectArray<btScalar> m_3componentVertices; | ||||
| btAlignedObjectArray<unsigned int> m_32bitIndices; | btAlignedObjectArray<unsigned int> m_32bitIndices; | ||||
| btAlignedObjectArray<unsigned short int> m_16bitIndices; | btAlignedObjectArray<unsigned short int> m_16bitIndices; | ||||
| bool m_use32bitIndices; | bool m_use32bitIndices; | ||||
| bool m_use4componentVertices; | bool m_use4componentVertices; | ||||
| public: | public: | ||||
| btScalar m_weldingThreshold; | btScalar m_weldingThreshold; | ||||
| btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true); | btTriangleMesh(bool use32bitIndices = true, bool use4componentVertices = true); | ||||
| bool getUse32bitIndices() const | bool getUse32bitIndices() const | ||||
| { | { | ||||
| return m_use32bitIndices; | return m_use32bitIndices; | ||||
| } | } | ||||
| bool getUse4componentVertices() const | bool getUse4componentVertices() const | ||||
| { | { | ||||
| return m_use4componentVertices; | return m_use4componentVertices; | ||||
| } | } | ||||
| ///By default addTriangle won't search for duplicate vertices, because the search is very slow for large triangle meshes. | ///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. | ///In general it is better to directly use btTriangleIndexVertexArray instead. | ||||
| void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2, bool removeDuplicateVertices=false); | 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) | ///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 ); | void addTriangleIndices(int index1, int index2, int index3); | ||||
| int getNumTriangles() const; | int getNumTriangles() const; | ||||
| virtual void preallocateVertices(int numverts); | virtual void preallocateVertices(int numverts); | ||||
| virtual void preallocateIndices(int numindices); | virtual void preallocateIndices(int numindices); | ||||
| ///findOrAddVertex is an internal method, use addTriangle instead | ///findOrAddVertex is an internal method, use addTriangle instead | ||||
| int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices); | int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices); | ||||
| ///addIndex is an internal method, use addTriangle instead | ///addIndex is an internal method, use addTriangle instead | ||||
| void addIndex(int index); | void addIndex(int index); | ||||
| }; | }; | ||||
| #endif //BT_TRIANGLE_MESH_H | #endif //BT_TRIANGLE_MESH_H | ||||