2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2008 Erwin Coumans http://continuousphysics.com/Bullet/
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:
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.
16
/// This file was created by Alex Silverman
18
#ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
19
#define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
21
#include "btBvhTriangleMeshShape.h"
22
#include "btMaterial.h"
24
///The BvhTriangleMaterialMeshShape extends the btBvhTriangleMeshShape. Its main contribution is the interface into a material array, which allows per-triangle friction and restitution.
25
ATTRIBUTE_ALIGNED16(class) btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
27
btAlignedObjectArray <btMaterial*> m_materialList;
28
int ** m_triangleMaterials;
32
BT_DECLARE_ALIGNED_ALLOCATOR();
34
btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
35
btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
36
btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
38
m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
40
btVector3 m_triangle[3];
41
const unsigned char *vertexbase;
45
const unsigned char *indexbase;
48
PHY_ScalarType indicestype;
50
//m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
52
for(int i = 0; i < meshInterface->getNumSubParts(); i++)
54
m_meshInterface->getLockedReadOnlyVertexIndexBase(
64
//m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
68
///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
69
btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
70
btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
72
m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
74
btVector3 m_triangle[3];
75
const unsigned char *vertexbase;
79
const unsigned char *indexbase;
82
PHY_ScalarType indicestype;
84
//m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
86
for(int i = 0; i < meshInterface->getNumSubParts(); i++)
88
m_meshInterface->getLockedReadOnlyVertexIndexBase(
98
//m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
102
virtual ~btMultimaterialTriangleMeshShape()
105
for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
107
btAlignedFree(m_materialValues[i]);
108
m_materialLookup[i] = NULL;
110
btAlignedFree(m_materialValues);
111
m_materialLookup = NULL;
115
virtual const char* getName()const {return "MULTIMATERIALTRIANGLEMESH";}
117
///Obtains the material for a specific triangle
118
const btMaterial * getMaterialProperties(int partID, int triIndex);
123
#endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2008 Erwin Coumans http://continuousphysics.com/Bullet/
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:
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.
16
/// This file was created by Alex Silverman
18
#ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
19
#define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
21
#include "btBvhTriangleMeshShape.h"
22
#include "btMaterial.h"
24
///The BvhTriangleMaterialMeshShape extends the btBvhTriangleMeshShape. Its main contribution is the interface into a material array, which allows per-triangle friction and restitution.
25
ATTRIBUTE_ALIGNED16(class) btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
27
btAlignedObjectArray <btMaterial*> m_materialList;
28
int ** m_triangleMaterials;
32
BT_DECLARE_ALIGNED_ALLOCATOR();
34
btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
35
btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
36
btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
38
m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
40
btVector3 m_triangle[3];
41
const unsigned char *vertexbase;
45
const unsigned char *indexbase;
48
PHY_ScalarType indicestype;
50
//m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
52
for(int i = 0; i < meshInterface->getNumSubParts(); i++)
54
m_meshInterface->getLockedReadOnlyVertexIndexBase(
64
//m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
68
///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
69
btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
70
btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
72
m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
74
btVector3 m_triangle[3];
75
const unsigned char *vertexbase;
79
const unsigned char *indexbase;
82
PHY_ScalarType indicestype;
84
//m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
86
for(int i = 0; i < meshInterface->getNumSubParts(); i++)
88
m_meshInterface->getLockedReadOnlyVertexIndexBase(
98
//m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
102
virtual ~btMultimaterialTriangleMeshShape()
105
for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
107
btAlignedFree(m_materialValues[i]);
108
m_materialLookup[i] = NULL;
110
btAlignedFree(m_materialValues);
111
m_materialLookup = NULL;
115
virtual const char* getName()const {return "MULTIMATERIALTRIANGLEMESH";}
117
///Obtains the material for a specific triangle
118
const btMaterial * getMaterialProperties(int partID, int triIndex);
123
#endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H