allow to use compression on btTriangleMesh
This commit is contained in:
@@ -16,7 +16,6 @@ subject to the following restrictions:
|
||||
#include "btTriangleMesh.h"
|
||||
#include <assert.h>
|
||||
|
||||
static int myindices[3] = {0,1,2};
|
||||
|
||||
btTriangleMesh::btTriangleMesh ()
|
||||
{
|
||||
@@ -25,31 +24,29 @@ btTriangleMesh::btTriangleMesh ()
|
||||
|
||||
void btTriangleMesh::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
|
||||
{
|
||||
numverts = 3;
|
||||
*vertexbase = (unsigned char*)&m_triangles[subpart];
|
||||
numverts = m_vertices.size();
|
||||
*vertexbase = (unsigned char*)&m_vertices[0];
|
||||
type = PHY_FLOAT;
|
||||
stride = sizeof(btVector3);
|
||||
|
||||
|
||||
numfaces = 1;
|
||||
*indexbase = (unsigned char*) &myindices[0];
|
||||
numfaces = m_indices.size()/3;
|
||||
*indexbase = (unsigned char*) &m_indices[0];
|
||||
indicestype = PHY_INTEGER;
|
||||
indexstride = sizeof(int);
|
||||
indexstride = 3*sizeof(int);
|
||||
|
||||
}
|
||||
|
||||
void btTriangleMesh::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) const
|
||||
{
|
||||
numverts = 3;
|
||||
*vertexbase = (unsigned char*)&m_triangles[subpart];
|
||||
numverts = m_vertices.size();
|
||||
*vertexbase = (unsigned char*)&m_vertices[0];
|
||||
type = PHY_FLOAT;
|
||||
stride = sizeof(btVector3);
|
||||
|
||||
|
||||
numfaces = 1;
|
||||
*indexbase = (unsigned char*) &myindices[0];
|
||||
numfaces = m_indices.size()/3;
|
||||
*indexbase = (unsigned char*) &m_indices[0];
|
||||
indicestype = PHY_INTEGER;
|
||||
indexstride = sizeof(int);
|
||||
indexstride = 3*sizeof(int);
|
||||
|
||||
}
|
||||
|
||||
@@ -57,5 +54,5 @@ void btTriangleMesh::getLockedReadOnlyVertexIndexBase(const unsigned char **vert
|
||||
|
||||
int btTriangleMesh::getNumSubParts() const
|
||||
{
|
||||
return m_triangles.size();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -20,39 +20,34 @@ subject to the following restrictions:
|
||||
#include "btStridingMeshInterface.h"
|
||||
#include "../../LinearMath/btVector3.h"
|
||||
#include "../../LinearMath/btAlignedObjectArray.h"
|
||||
struct btMyTriangle
|
||||
{
|
||||
btVector3 m_vert0;
|
||||
btVector3 m_vert1;
|
||||
btVector3 m_vert2;
|
||||
};
|
||||
|
||||
///TriangleMesh provides storage for a concave triangle mesh. It can be used as data for the btTriangleMeshShape.
|
||||
class btTriangleMesh : public btStridingMeshInterface
|
||||
{
|
||||
btAlignedObjectArray<btMyTriangle> m_triangles;
|
||||
btAlignedObjectArray<btVector3> m_vertices;
|
||||
btAlignedObjectArray<int> m_indices;
|
||||
|
||||
public:
|
||||
btTriangleMesh ();
|
||||
|
||||
void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2)
|
||||
{
|
||||
btMyTriangle tri;
|
||||
tri.m_vert0 = vertex0;
|
||||
tri.m_vert1 = vertex1;
|
||||
tri.m_vert2 = vertex2;
|
||||
m_triangles.push_back(tri);
|
||||
int curIndex = m_indices.size();
|
||||
m_vertices.push_back(vertex0);
|
||||
m_vertices.push_back(vertex1);
|
||||
m_vertices.push_back(vertex2);
|
||||
|
||||
m_indices.push_back(curIndex++);
|
||||
m_indices.push_back(curIndex++);
|
||||
m_indices.push_back(curIndex++);
|
||||
}
|
||||
|
||||
int getNumTriangles() const
|
||||
{
|
||||
return m_triangles.size();
|
||||
return m_indices.size() / 3;
|
||||
}
|
||||
|
||||
const btMyTriangle& getTriangle(int index) const
|
||||
{
|
||||
return m_triangles[index];
|
||||
}
|
||||
|
||||
|
||||
//StridingMeshInterface interface implementation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user