Bullet Collision Detection & Physics Library: btTriangleIndexVertexMaterialArray.cpp Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
18#include "btTriangleIndexVertexMaterialArray.h"
19
20 btTriangleIndexVertexMaterialArray::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{
25 btMaterialProperties mat;
26
27 mat.m_numMaterials = numMaterials;
28 mat.m_materialBase = materialBase;
29 mat.m_materialStride = materialStride;
30#ifdef BT_USE_DOUBLE_PRECISION
31 mat.m_materialType = PHY_DOUBLE;
32#else
33 mat.m_materialType = PHY_FLOAT;
34#endif
35
36 mat.m_numTriangles = numTriangles;
37 mat.m_triangleMaterialsBase = (unsigned char*)triangleMaterialsBase;
38 mat.m_triangleMaterialStride = materialIndexStride;
39 mat.m_triangleType = PHY_INTEGER;
40
41 addMaterialProperties(mat);
42}
43
44 void 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
66 void 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
PHY_ScalarType enumerates possible scalar types.
Definition btConcaveShape.h:26
PHY_FLOAT
@ PHY_FLOAT
Definition btConcaveShape.h:27
PHY_DOUBLE
@ PHY_DOUBLE
Definition btConcaveShape.h:28
PHY_INTEGER
@ PHY_INTEGER
Definition btConcaveShape.h:29
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
btAssert
#define btAssert(x)
Definition btScalar.h:153
btTriangleIndexVertexMaterialArray.h
btTriangleIndexVertexArray
The btTriangleIndexVertexArray allows to access multiple triangle meshes, by indexing into existing t...
Definition btTriangleIndexVertexArray.h:67
btTriangleIndexVertexArray::getNumSubParts
virtual int getNumSubParts() const
getNumSubParts returns the number of separate subparts each subpart has a continuous array of vertice...
Definition btTriangleIndexVertexArray.h:105
btTriangleIndexVertexMaterialArray::getLockedReadOnlyMaterialBase
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)
Definition btTriangleIndexVertexMaterialArray.cpp:66
btTriangleIndexVertexMaterialArray::btTriangleIndexVertexMaterialArray
btTriangleIndexVertexMaterialArray()
Definition btTriangleIndexVertexMaterialArray.h:59
btTriangleIndexVertexMaterialArray::m_materials
MaterialArray m_materials
Definition btTriangleIndexVertexMaterialArray.h:54
btTriangleIndexVertexMaterialArray::getLockedMaterialBase
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)
Definition btTriangleIndexVertexMaterialArray.cpp:44
btTriangleIndexVertexMaterialArray::addMaterialProperties
void addMaterialProperties(const btMaterialProperties &mat, PHY_ScalarType triangleType=PHY_INTEGER)
Definition btTriangleIndexVertexMaterialArray.h:70
btMaterialProperties
This file was created by Alex Silverman.
Definition btTriangleIndexVertexMaterialArray.h:25
btMaterialProperties::m_numTriangles
int m_numTriangles
m_numTriangles <=========== This exists in the btIndexedMesh object for the same subpart,...
Definition btTriangleIndexVertexMaterialArray.h:35
btMaterialProperties::m_triangleMaterialsBase
const unsigned char * m_triangleMaterialsBase
Definition btTriangleIndexVertexMaterialArray.h:36
btMaterialProperties::m_materialType
PHY_ScalarType m_materialType
Definition btTriangleIndexVertexMaterialArray.h:30
btMaterialProperties::m_materialStride
int m_materialStride
Definition btTriangleIndexVertexMaterialArray.h:29
btMaterialProperties::m_materialBase
const unsigned char * m_materialBase
Definition btTriangleIndexVertexMaterialArray.h:28
btMaterialProperties::m_triangleMaterialStride
int m_triangleMaterialStride
Definition btTriangleIndexVertexMaterialArray.h:37
btMaterialProperties::m_triangleType
PHY_ScalarType m_triangleType
m_triangleType <========== Automatically set in addMaterialProperties
Definition btTriangleIndexVertexMaterialArray.h:39
btMaterialProperties::m_numMaterials
int m_numMaterials
m_materialBase ==========> 2 btScalar values make up one material, friction then restitution
Definition btTriangleIndexVertexMaterialArray.h:27