00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
00017 #define BT_TRIANGLE_INDEX_VERTEX_ARRAY_H
00018
00019 #include "btStridingMeshInterface.h"
00020 #include "LinearMath/btAlignedObjectArray.h"
00021 #include "LinearMath/btScalar.h"
00022
00023
00026 ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
00027 {
00028 BT_DECLARE_ALIGNED_ALLOCATOR();
00029
00030 int m_numTriangles;
00031 const unsigned char * m_triangleIndexBase;
00032 int m_triangleIndexStride;
00033 int m_numVertices;
00034 const unsigned char * m_vertexBase;
00035 int m_vertexStride;
00036
00037
00038
00039 PHY_ScalarType m_indexType;
00040
00041
00042
00043
00044 PHY_ScalarType m_vertexType;
00045
00046
00047 btIndexedMesh()
00048 :m_indexType(PHY_INTEGER),
00049 #ifdef BT_USE_DOUBLE_PRECISION
00050 m_vertexType(PHY_DOUBLE)
00051 #else // BT_USE_DOUBLE_PRECISION
00052 m_vertexType(PHY_FLOAT)
00053 #endif // BT_USE_DOUBLE_PRECISION
00054 {
00055 }
00056 }
00057 ;
00058
00059
00060 typedef btAlignedObjectArray<btIndexedMesh> IndexedMeshArray;
00061
00066 ATTRIBUTE_ALIGNED16( class) btTriangleIndexVertexArray : public btStridingMeshInterface
00067 {
00068 protected:
00069 IndexedMeshArray m_indexedMeshes;
00070 int m_pad[2];
00071 mutable int m_hasAabb;
00072 mutable btVector3 m_aabbMin;
00073 mutable btVector3 m_aabbMax;
00074
00075 public:
00076
00077 BT_DECLARE_ALIGNED_ALLOCATOR();
00078
00079 btTriangleIndexVertexArray() : m_hasAabb(0)
00080 {
00081 }
00082
00083 virtual ~btTriangleIndexVertexArray();
00084
00085
00086 btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride);
00087
00088 void addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
00089 {
00090 m_indexedMeshes.push_back(mesh);
00091 m_indexedMeshes[m_indexedMeshes.size()-1].m_indexType = indexType;
00092 }
00093
00094
00095 virtual void getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0);
00096
00097 virtual void getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0) const;
00098
00101 virtual void unLockVertexBase(int subpart) {(void)subpart;}
00102
00103 virtual void unLockReadOnlyVertexBase(int subpart) const {(void)subpart;}
00104
00107 virtual int getNumSubParts() const {
00108 return (int)m_indexedMeshes.size();
00109 }
00110
00111 IndexedMeshArray& getIndexedMeshArray()
00112 {
00113 return m_indexedMeshes;
00114 }
00115
00116 const IndexedMeshArray& getIndexedMeshArray() const
00117 {
00118 return m_indexedMeshes;
00119 }
00120
00121 virtual void preallocateVertices(int numverts){(void) numverts;}
00122 virtual void preallocateIndices(int numindices){(void) numindices;}
00123
00124 virtual bool hasPremadeAabb() const;
00125 virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const;
00126 virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const;
00127
00128 }
00129 ;
00130
00131 #endif //BT_TRIANGLE_INDEX_VERTEX_ARRAY_H