btStridingMeshInterface.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_STRIDING_MESHINTERFACE_H
00017 #define BT_STRIDING_MESHINTERFACE_H
00018 
00019 #include "LinearMath/btVector3.h"
00020 #include "btTriangleCallback.h"
00021 #include "btConcaveShape.h"
00022 
00023 
00024 
00025 
00026 
00030 ATTRIBUTE_ALIGNED16(class ) btStridingMeshInterface
00031 {
00032         protected:
00033         
00034                 btVector3 m_scaling;
00035 
00036         public:
00037                 BT_DECLARE_ALIGNED_ALLOCATOR();
00038                 
00039                 btStridingMeshInterface() :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.))
00040                 {
00041 
00042                 }
00043 
00044                 virtual ~btStridingMeshInterface();
00045 
00046 
00047 
00048                 virtual void    InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
00049 
00051                 void    calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax);
00052 
00058                 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)=0;
00059                 
00060                 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=0;
00061         
00064                 virtual void    unLockVertexBase(int subpart)=0;
00065 
00066                 virtual void    unLockReadOnlyVertexBase(int subpart) const=0;
00067 
00068 
00071                 virtual int             getNumSubParts() const=0;
00072 
00073                 virtual void    preallocateVertices(int numverts)=0;
00074                 virtual void    preallocateIndices(int numindices)=0;
00075 
00076                 virtual bool    hasPremadeAabb() const { return false; }
00077                 virtual void    setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
00078                 {
00079                         (void) aabbMin;
00080                         (void) aabbMax;
00081                 }
00082                 virtual void    getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const
00083         {
00084             (void) aabbMin;
00085             (void) aabbMax;
00086         }
00087 
00088                 const btVector3&        getScaling() const {
00089                         return m_scaling;
00090                 }
00091                 void    setScaling(const btVector3& scaling)
00092                 {
00093                         m_scaling = scaling;
00094                 }
00095 
00096                 virtual int     calculateSerializeBufferSize() const;
00097 
00099                 virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
00100 
00101 
00102 };
00103 
00104 struct  btIntIndexData
00105 {
00106         int     m_value;
00107 };
00108 
00109 struct  btShortIntIndexData
00110 {
00111         short m_value;
00112         char m_pad[2];
00113 };
00114 
00115 struct  btShortIntIndexTripletData
00116 {
00117         short   m_values[3];
00118         char    m_pad[2];
00119 };
00120 
00121 struct  btCharIndexTripletData
00122 {
00123         unsigned char m_values[3];
00124         char    m_pad;
00125 };
00126 
00127 
00129 struct  btMeshPartData
00130 {
00131         btVector3FloatData                      *m_vertices3f;
00132         btVector3DoubleData                     *m_vertices3d;
00133 
00134         btIntIndexData                          *m_indices32;
00135         btShortIntIndexTripletData      *m_3indices16;
00136         btCharIndexTripletData          *m_3indices8;
00137 
00138         btShortIntIndexData                     *m_indices16;//backwards compatibility
00139 
00140         int                     m_numTriangles;//length of m_indices = m_numTriangles
00141         int                     m_numVertices;
00142 };
00143 
00144 
00146 struct  btStridingMeshInterfaceData
00147 {
00148         btMeshPartData  *m_meshPartsPtr;
00149         btVector3FloatData      m_scaling;
00150         int     m_numMeshParts;
00151         char m_padding[4];
00152 };
00153 
00154 
00155 
00156 
00157 SIMD_FORCE_INLINE       int     btStridingMeshInterface::calculateSerializeBufferSize() const
00158 {
00159         return sizeof(btStridingMeshInterfaceData);
00160 }
00161 
00162 
00163 
00164 #endif //BT_STRIDING_MESHINTERFACE_H