1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies.
* Erwin Coumans makes no representations about the suitability
* of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*/
#ifndef TRIANGLE_MESH_H
#define TRIANGLE_MESH_H
#include "CollisionShapes/StridingMeshInterface.h"
#include <vector>
#include <SimdVector3.h>
struct MyTriangle
{
SimdVector3 m_vert0;
SimdVector3 m_vert1;
SimdVector3 m_vert2;
};
///TriangleMesh provides storage for a concave triangle mesh. It can be used as data for the TriangleMeshShape.
class TriangleMesh : public StridingMeshInterface
{
std::vector<MyTriangle> m_triangles;
public:
TriangleMesh ();
void AddTriangle(const SimdVector3& vertex0,const SimdVector3& vertex1,const SimdVector3& vertex2)
{
MyTriangle tri;
tri.m_vert0 = vertex0;
tri.m_vert1 = vertex1;
tri.m_vert2 = vertex2;
m_triangles.push_back(tri);
}
//StridingMeshInterface interface implementation
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);
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;
/// 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 unLockVertexBase(int subpart) {}
virtual void unLockReadOnlyVertexBase(int subpart) const {}
/// getNumSubParts returns the number of seperate subparts
/// each subpart has a continuous array of vertices and indices
virtual int getNumSubParts() const;
virtual void preallocateVertices(int numverts){}
virtual void preallocateIndices(int numindices){}
};
#endif //TRIANGLE_MESH_H
|