Back to index

supertuxkart  0.5+dfsg1
btTriangleIndexVertexArray.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
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 
00027 ATTRIBUTE_ALIGNED16( struct)       btIndexedMesh
00028 {
00029        BT_DECLARE_ALIGNED_ALLOCATOR();
00030 
00031        int                  m_numTriangles;
00032        const unsigned char *              m_triangleIndexBase;
00033        int                  m_triangleIndexStride;
00034        int                  m_numVertices;
00035        const unsigned char *              m_vertexBase;
00036        int                  m_vertexStride;
00037        // The index type is set when adding an indexed mesh to the
00038        // btTriangleIndexVertexArray, do not set it manually
00039        PHY_ScalarType              m_indexType;
00040        int                  pad;
00041 }
00042 ;
00043 
00044 
00045 typedef btAlignedObjectArray<btIndexedMesh>      IndexedMeshArray;
00046 
00051 ATTRIBUTE_ALIGNED16( class) btTriangleIndexVertexArray : public btStridingMeshInterface
00052 {
00053 protected:
00054        IndexedMeshArray     m_indexedMeshes;
00055        int m_pad[3];
00056 
00057               
00058 public:
00059 
00060        BT_DECLARE_ALIGNED_ALLOCATOR();
00061 
00062        btTriangleIndexVertexArray()
00063        {
00064        }
00065 
00066        virtual ~btTriangleIndexVertexArray();
00067 
00068        //just to be backwards compatible
00069        btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride);
00070        
00071        void   addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
00072        {
00073               m_indexedMeshes.push_back(mesh);
00074               m_indexedMeshes[m_indexedMeshes.size()-1].m_indexType = indexType;
00075        }
00076        
00077        
00078        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);
00079 
00080        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;
00081 
00084        virtual void  unLockVertexBase(int subpart) {(void)subpart;}
00085 
00086        virtual void  unLockReadOnlyVertexBase(int subpart) const {(void)subpart;}
00087 
00090        virtual int          getNumSubParts() const { 
00091               return (int)m_indexedMeshes.size();
00092        }
00093 
00094        IndexedMeshArray&    getIndexedMeshArray()
00095        {
00096               return m_indexedMeshes;
00097        }
00098 
00099        const IndexedMeshArray&     getIndexedMeshArray() const
00100        {
00101               return m_indexedMeshes;
00102        }
00103 
00104        virtual void  preallocateVertices(int numverts){(void) numverts;}
00105        virtual void  preallocateIndices(int numindices){(void) numindices;}
00106 
00107 }
00108 ;
00109 
00110 #endif //BT_TRIANGLE_INDEX_VERTEX_ARRAY_H