Bullet Collision Detection & Physics Library: btMultimaterialTriangleMeshShape.h Source File

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
25 ATTRIBUTE_ALIGNED16(class)
26 btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
27 {
28 btAlignedObjectArray<btMaterial *> m_materialList;
29
30 public:
31 BT_DECLARE_ALIGNED_ALLOCATOR();
32
33 btMultimaterialTriangleMeshShape(btStridingMeshInterface * meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true) : btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
34 {
35 m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
36
37 const unsigned char *vertexbase;
38 int numverts;
39 PHY_ScalarType type;
40 int stride;
41 const unsigned char *indexbase;
42 int indexstride;
43 int numfaces;
44 PHY_ScalarType indicestype;
45
46 //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
47
48 for (int i = 0; i < meshInterface->getNumSubParts(); i++)
49 {
50 m_meshInterface->getLockedReadOnlyVertexIndexBase(
51 &vertexbase,
52 numverts,
53 type,
54 stride,
55 &indexbase,
56 indexstride,
57 numfaces,
58 indicestype,
59 i);
60 //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
61 }
62 }
63
65 btMultimaterialTriangleMeshShape(btStridingMeshInterface * meshInterface, bool useQuantizedAabbCompression, const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax, bool buildBvh = true) : btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
66 {
67 m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
68
69 const unsigned char *vertexbase;
70 int numverts;
71 PHY_ScalarType type;
72 int stride;
73 const unsigned char *indexbase;
74 int indexstride;
75 int numfaces;
76 PHY_ScalarType indicestype;
77
78 //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
79
80 for (int i = 0; i < meshInterface->getNumSubParts(); i++)
81 {
82 m_meshInterface->getLockedReadOnlyVertexIndexBase(
83 &vertexbase,
84 numverts,
85 type,
86 stride,
87 &indexbase,
88 indexstride,
89 numfaces,
90 indicestype,
91 i);
92 //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
93 }
94 }
95
96 virtual ~btMultimaterialTriangleMeshShape()
97 {
98 /*
99 for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
100 {
101 btAlignedFree(m_materialValues[i]);
102 m_materialLookup[i] = NULL;
103 }
104 btAlignedFree(m_materialValues);
105 m_materialLookup = NULL;
106 */
107 }
108 //debugging
109 virtual const char *getName() const { return "MULTIMATERIALTRIANGLEMESH"; }
110
112 const btMaterial *getMaterialProperties(int partID, int triIndex);
113 };
114
115 #endif //BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
btMultimaterialTriangleMeshShape::btMultimaterialTriangleMeshShape
btMultimaterialTriangleMeshShape(btStridingMeshInterface *meshInterface, bool useQuantizedAabbCompression, bool buildBvh=true)
Definition: btMultimaterialTriangleMeshShape.h:33
btMultimaterialTriangleMeshShape
This file was created by Alex Silverman.
Definition: btMultimaterialTriangleMeshShape.h:25
btAlignedObjectArray
The btAlignedObjectArray template class uses a subset of the stl::vector interface for its methods It...
Definition: btAlignedObjectArray.h:52
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE
Multimaterial mesh.
Definition: btBroadphaseProxy.h:63
btMaterial.h
btBvhTriangleMeshShape.h
btMultimaterialTriangleMeshShape::m_materialList
btAlignedObjectArray< btMaterial * > m_materialList
Definition: btMultimaterialTriangleMeshShape.h:28
btBvhTriangleMeshShape
The btBvhTriangleMeshShape is a static-triangle mesh shape, it can only be used for fixed/non-moving ...
Definition: btBvhTriangleMeshShape.h:34
btMultimaterialTriangleMeshShape::~btMultimaterialTriangleMeshShape
virtual ~btMultimaterialTriangleMeshShape()
Definition: btMultimaterialTriangleMeshShape.h:96
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:80
btStridingMeshInterface::getNumSubParts
virtual int getNumSubParts() const =0
getNumSubParts returns the number of seperate subparts each subpart has a continuous array of vertice...
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:84
btMaterial
This file was created by Alex Silverman.
Definition: btMaterial.h:22
btStridingMeshInterface
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
Definition: btStridingMeshInterface.h:26
btMultimaterialTriangleMeshShape::getName
virtual const char * getName() const
Definition: btMultimaterialTriangleMeshShape.h:109
BT_DECLARE_ALIGNED_ALLOCATOR
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:405
btMultimaterialTriangleMeshShape::btMultimaterialTriangleMeshShape
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...
Definition: btMultimaterialTriangleMeshShape.h:65
PHY_ScalarType
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
Definition: btConcaveShape.h:25