Bullet Collision Detection & Physics Library
btTriangleIndexVertexMaterialArray.cpp
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
17
19
20btTriangleIndexVertexMaterialArray::btTriangleIndexVertexMaterialArray(int numTriangles, int* triangleIndexBase, int triangleIndexStride,
21 int numVertices, btScalar* vertexBase, int vertexStride,
22 int numMaterials, unsigned char* materialBase, int materialStride,
23 int* triangleMaterialsBase, int materialIndexStride) : btTriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride)
24{
26
27 mat.m_numMaterials = numMaterials;
28 mat.m_materialBase = materialBase;
29 mat.m_materialStride = materialStride;
30#ifdef BT_USE_DOUBLE_PRECISION
32#else
34#endif
35
36 mat.m_numTriangles = numTriangles;
37 mat.m_triangleMaterialsBase = (unsigned char*)triangleMaterialsBase;
38 mat.m_triangleMaterialStride = materialIndexStride;
40
42}
43
44void btTriangleIndexVertexMaterialArray::getLockedMaterialBase(unsigned char** materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride,
45 unsigned char** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart)
46{
47 btAssert(subpart < getNumSubParts());
48
49 btMaterialProperties& mats = m_materials[subpart];
50
51 numMaterials = mats.m_numMaterials;
52 (*materialBase) = (unsigned char*)mats.m_materialBase;
53#ifdef BT_USE_DOUBLE_PRECISION
54 materialType = PHY_DOUBLE;
55#else
56 materialType = PHY_FLOAT;
57#endif
58 materialStride = mats.m_materialStride;
59
60 numTriangles = mats.m_numTriangles;
61 (*triangleMaterialBase) = (unsigned char*)mats.m_triangleMaterialsBase;
62 triangleMaterialStride = mats.m_triangleMaterialStride;
63 triangleType = mats.m_triangleType;
64}
65
66void btTriangleIndexVertexMaterialArray::getLockedReadOnlyMaterialBase(const unsigned char** materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride,
67 const unsigned char** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart)
68{
69 btMaterialProperties& mats = m_materials[subpart];
70
71 numMaterials = mats.m_numMaterials;
72 (*materialBase) = (const unsigned char*)mats.m_materialBase;
73#ifdef BT_USE_DOUBLE_PRECISION
74 materialType = PHY_DOUBLE;
75#else
76 materialType = PHY_FLOAT;
77#endif
78 materialStride = mats.m_materialStride;
79
80 numTriangles = mats.m_numTriangles;
81 (*triangleMaterialBase) = (const unsigned char*)mats.m_triangleMaterialsBase;
82 triangleMaterialStride = mats.m_triangleMaterialStride;
83 triangleType = mats.m_triangleType;
84}
PHY_ScalarType
PHY_ScalarType enumerates possible scalar types.
@ PHY_FLOAT
@ PHY_DOUBLE
@ PHY_INTEGER
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define btAssert(x)
Definition: btScalar.h:153
The btTriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing t...
virtual int getNumSubParts() const
getNumSubParts returns the number of separate subparts each subpart has a continuous array of vertice...
virtual void getLockedReadOnlyMaterialBase(const unsigned char **materialBase, int &numMaterials, PHY_ScalarType &materialType, int &materialStride, const unsigned char **triangleMaterialBase, int &numTriangles, int &triangleMaterialStride, PHY_ScalarType &triangleType, int subpart=0)
virtual void getLockedMaterialBase(unsigned char **materialBase, int &numMaterials, PHY_ScalarType &materialType, int &materialStride, unsigned char **triangleMaterialBase, int &numTriangles, int &triangleMaterialStride, PHY_ScalarType &triangleType, int subpart=0)
void addMaterialProperties(const btMaterialProperties &mat, PHY_ScalarType triangleType=PHY_INTEGER)
This file was created by Alex Silverman.
int m_numTriangles
m_numTriangles <=========== This exists in the btIndexedMesh object for the same subpart,...
const unsigned char * m_triangleMaterialsBase
PHY_ScalarType m_triangleType
m_triangleType <========== Automatically set in addMaterialProperties
int m_numMaterials
m_materialBase ==========> 2 btScalar values make up one material, friction then restitution