Bullet Collision Detection & Physics Library
btMultimaterialTriangleMeshShape.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
17 
18 #ifndef BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
19 #define BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
20 
21 #include "btBvhTriangleMeshShape.h"
22 #include "btMaterial.h"
23 
26 {
28 
29 public:
30 
32 
33  btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
34  btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
35  {
37 
38  const unsigned char *vertexbase;
39  int numverts;
40  PHY_ScalarType type;
41  int stride;
42  const unsigned char *indexbase;
43  int indexstride;
44  int numfaces;
45  PHY_ScalarType indicestype;
46 
47  //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
48 
49  for(int i = 0; i < meshInterface->getNumSubParts(); i++)
50  {
51  m_meshInterface->getLockedReadOnlyVertexIndexBase(
52  &vertexbase,
53  numverts,
54  type,
55  stride,
56  &indexbase,
57  indexstride,
58  numfaces,
59  indicestype,
60  i);
61  //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
62  }
63  }
64 
66  btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
67  btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
68  {
70 
71  const unsigned char *vertexbase;
72  int numverts;
73  PHY_ScalarType type;
74  int stride;
75  const unsigned char *indexbase;
76  int indexstride;
77  int numfaces;
78  PHY_ScalarType indicestype;
79 
80  //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
81 
82  for(int i = 0; i < meshInterface->getNumSubParts(); i++)
83  {
84  m_meshInterface->getLockedReadOnlyVertexIndexBase(
85  &vertexbase,
86  numverts,
87  type,
88  stride,
89  &indexbase,
90  indexstride,
91  numfaces,
92  indicestype,
93  i);
94  //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
95  }
96  }
97 
99  {
100 /*
101  for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
102  {
103  btAlignedFree(m_materialValues[i]);
104  m_materialLookup[i] = NULL;
105  }
106  btAlignedFree(m_materialValues);
107  m_materialLookup = NULL;
108 */
109  }
110  //debugging
111  virtual const char* getName()const {return "MULTIMATERIALTRIANGLEMESH";}
112 
114  const btMaterial * getMaterialProperties(int partID, int triIndex);
115 
116 }
117 ;
118 
119 #endif //BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
btMultimaterialTriangleMeshShape(btStridingMeshInterface *meshInterface, bool useQuantizedAabbCompression, bool buildBvh=true)
This file was created by Alex Silverman.
btAlignedObjectArray< btMaterial * > m_materialList
The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving ...
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
virtual int getNumSubParts() const =0
getNumSubParts returns the number of seperate subparts each subpart has a continuous array of vertice...
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
This file was created by Alex Silverman.
Definition: btMaterial.h:22
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:403
btMultimaterialTriangleMeshShape(btStridingMeshInterface *meshInterface, bool useQuantizedAabbCompression, const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax, bool buildBvh=true)
optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this...
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.