btTriangleIndexVertexArray.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
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 
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    // 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 
00041    // The vertex type has a default type similar to Bullet's precision mode (float or double)
00042    // but can be set manually if you for example run Bullet with double precision but have
00043    // mesh data in single precision..
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; // using int instead of bool to maintain alignment
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         //just to be backwards compatible
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


bullet
Author(s): Erwin Coumans, ROS package maintained by Tully Foote
autogenerated on Wed Oct 31 2012 07:54:31