| 1 |  | 
|---|
| 2 | /* | 
|---|
| 3 | Bullet Continuous Collision Detection and Physics Library | 
|---|
| 4 | Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/ | 
|---|
| 5 |  | 
|---|
| 6 | This software is provided 'as-is', without any express or implied warranty. | 
|---|
| 7 | In no event will the authors be held liable for any damages arising from the use of this software. | 
|---|
| 8 | Permission is granted to anyone to use this software for any purpose, | 
|---|
| 9 | including commercial applications, and to alter it and redistribute it freely, | 
|---|
| 10 | subject to the following restrictions: | 
|---|
| 11 |  | 
|---|
| 12 | 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. | 
|---|
| 13 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. | 
|---|
| 14 | 3. This notice may not be removed or altered from any source distribution. | 
|---|
| 15 | */ | 
|---|
| 16 |  | 
|---|
| 17 | ///This file was created by Alex Silverman | 
|---|
| 18 |  | 
|---|
| 19 | #include "btTriangleIndexVertexMaterialArray.h" | 
|---|
| 20 |  | 
|---|
| 21 | btTriangleIndexVertexMaterialArray::btTriangleIndexVertexMaterialArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride, | 
|---|
| 22 |                                    int numVertices,btScalar* vertexBase,int vertexStride, | 
|---|
| 23 |                                    int numMaterials, unsigned char* materialBase, int materialStride, | 
|---|
| 24 |                                    int* triangleMaterialsBase, int materialIndexStride) : | 
|---|
| 25 | btTriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride) | 
|---|
| 26 | { | 
|---|
| 27 |     btMaterialProperties mat; | 
|---|
| 28 |  | 
|---|
| 29 |     mat.m_numMaterials = numMaterials; | 
|---|
| 30 |     mat.m_materialBase = materialBase; | 
|---|
| 31 |     mat.m_materialStride = materialStride; | 
|---|
| 32 | #ifdef BT_USE_DOUBLE_PRECISION | 
|---|
| 33 |     mat.m_materialType = PHY_DOUBLE; | 
|---|
| 34 | #else | 
|---|
| 35 |     mat.m_materialType = PHY_FLOAT; | 
|---|
| 36 | #endif | 
|---|
| 37 |  | 
|---|
| 38 |     mat.m_numTriangles = numTriangles; | 
|---|
| 39 |     mat.m_triangleMaterialsBase = (unsigned char *)triangleMaterialsBase; | 
|---|
| 40 |     mat.m_triangleMaterialStride = materialIndexStride; | 
|---|
| 41 |     mat.m_triangleType = PHY_INTEGER; | 
|---|
| 42 |  | 
|---|
| 43 |     addMaterialProperties(mat); | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 | void btTriangleIndexVertexMaterialArray::getLockedMaterialBase(unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, | 
|---|
| 48 |                                    unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart) | 
|---|
| 49 | { | 
|---|
| 50 |     btAssert(subpart< getNumSubParts() ); | 
|---|
| 51 |  | 
|---|
| 52 |     btMaterialProperties& mats = m_materials[subpart]; | 
|---|
| 53 |  | 
|---|
| 54 |     numMaterials = mats.m_numMaterials; | 
|---|
| 55 |     (*materialBase) = (unsigned char *) mats.m_materialBase; | 
|---|
| 56 | #ifdef BT_USE_DOUBLE_PRECISION | 
|---|
| 57 |     materialType = PHY_DOUBLE; | 
|---|
| 58 | #else | 
|---|
| 59 |     materialType = PHY_FLOAT; | 
|---|
| 60 | #endif | 
|---|
| 61 |     materialStride = mats.m_materialStride; | 
|---|
| 62 |  | 
|---|
| 63 |     numTriangles = mats.m_numTriangles; | 
|---|
| 64 |     (*triangleMaterialBase) = (unsigned char *)mats.m_triangleMaterialsBase; | 
|---|
| 65 |     triangleMaterialStride = mats.m_triangleMaterialStride; | 
|---|
| 66 |     triangleType = mats.m_triangleType; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | void btTriangleIndexVertexMaterialArray::getLockedReadOnlyMaterialBase(const unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, | 
|---|
| 70 |                                            const unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart) | 
|---|
| 71 | { | 
|---|
| 72 |     btMaterialProperties& mats = m_materials[subpart]; | 
|---|
| 73 |  | 
|---|
| 74 |     numMaterials = mats.m_numMaterials; | 
|---|
| 75 |     (*materialBase) = (const unsigned char *) mats.m_materialBase; | 
|---|
| 76 | #ifdef BT_USE_DOUBLE_PRECISION | 
|---|
| 77 |     materialType = PHY_DOUBLE; | 
|---|
| 78 | #else | 
|---|
| 79 |     materialType = PHY_FLOAT; | 
|---|
| 80 | #endif | 
|---|
| 81 |     materialStride = mats.m_materialStride; | 
|---|
| 82 |  | 
|---|
| 83 |     numTriangles = mats.m_numTriangles; | 
|---|
| 84 |     (*triangleMaterialBase) = (const unsigned char *)mats.m_triangleMaterialsBase; | 
|---|
| 85 |     triangleMaterialStride = mats.m_triangleMaterialStride; | 
|---|
| 86 |     triangleType = mats.m_triangleType; | 
|---|
| 87 | } | 
|---|