Blender V2.61 - r43446

btMultimaterialTriangleMeshShape.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 
00017 
00018 #ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
00019 #define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
00020 
00021 #include "btBvhTriangleMeshShape.h"
00022 #include "btMaterial.h"
00023 
00025 ATTRIBUTE_ALIGNED16(class) btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
00026 {
00027     btAlignedObjectArray <btMaterial*> m_materialList;
00028     int ** m_triangleMaterials;
00029 
00030 public:
00031 
00032     BT_DECLARE_ALIGNED_ALLOCATOR();
00033 
00034     btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
00035         btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
00036         {
00037             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
00038 
00039             const unsigned char *vertexbase;
00040             int numverts;
00041             PHY_ScalarType type;
00042             int stride;
00043             const unsigned char *indexbase;
00044             int indexstride;
00045             int numfaces;
00046             PHY_ScalarType indicestype;
00047 
00048             //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
00049 
00050             for(int i = 0; i < meshInterface->getNumSubParts(); i++)
00051             {
00052                 m_meshInterface->getLockedReadOnlyVertexIndexBase(
00053                     &vertexbase,
00054                     numverts,
00055                     type,
00056                     stride,
00057                     &indexbase,
00058                     indexstride,
00059                     numfaces,
00060                     indicestype,
00061                     i);
00062                 //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
00063             }
00064         }
00065 
00067     btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
00068         btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
00069         {
00070             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
00071 
00072             const unsigned char *vertexbase;
00073             int numverts;
00074             PHY_ScalarType type;
00075             int stride;
00076             const unsigned char *indexbase;
00077             int indexstride;
00078             int numfaces;
00079             PHY_ScalarType indicestype;
00080 
00081             //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
00082 
00083             for(int i = 0; i < meshInterface->getNumSubParts(); i++)
00084             {
00085                 m_meshInterface->getLockedReadOnlyVertexIndexBase(
00086                     &vertexbase,
00087                     numverts,
00088                     type,
00089                     stride,
00090                     &indexbase,
00091                     indexstride,
00092                     numfaces,
00093                     indicestype,
00094                     i);
00095                 //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
00096             }
00097         }
00098     
00099     virtual ~btMultimaterialTriangleMeshShape()
00100     {
00101 /*
00102         for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
00103         {
00104             btAlignedFree(m_materialValues[i]);
00105             m_materialLookup[i] = NULL;
00106         }
00107         btAlignedFree(m_materialValues);
00108         m_materialLookup = NULL;
00109 */
00110     }
00111     //debugging
00112     virtual const char* getName()const {return "MULTIMATERIALTRIANGLEMESH";}
00113 
00115     const btMaterial * getMaterialProperties(int partID, int triIndex);
00116 
00117 }
00118 ;
00119 
00120 #endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H