Blender V2.61 - r43446
|
00001 /* 00002 Bullet Continuous Collision Detection and Physics Library 00003 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 00004 00005 This software is provided 'as-is', without any express or implied warranty. 00006 In no event will the authors be held liable for any damages arising from the use of this software. 00007 Permission is granted to anyone to use this software for any purpose, 00008 including commercial applications, and to alter it and redistribute it freely, 00009 subject to the following restrictions: 00010 00011 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. 00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 00013 3. This notice may not be removed or altered from any source distribution. 00014 */ 00015 00017 00018 #include "btTriangleIndexVertexMaterialArray.h" 00019 00020 btTriangleIndexVertexMaterialArray::btTriangleIndexVertexMaterialArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride, 00021 int numVertices,btScalar* vertexBase,int vertexStride, 00022 int numMaterials, unsigned char* materialBase, int materialStride, 00023 int* triangleMaterialsBase, int materialIndexStride) : 00024 btTriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride) 00025 { 00026 btMaterialProperties mat; 00027 00028 mat.m_numMaterials = numMaterials; 00029 mat.m_materialBase = materialBase; 00030 mat.m_materialStride = materialStride; 00031 #ifdef BT_USE_DOUBLE_PRECISION 00032 mat.m_materialType = PHY_DOUBLE; 00033 #else 00034 mat.m_materialType = PHY_FLOAT; 00035 #endif 00036 00037 mat.m_numTriangles = numTriangles; 00038 mat.m_triangleMaterialsBase = (unsigned char *)triangleMaterialsBase; 00039 mat.m_triangleMaterialStride = materialIndexStride; 00040 mat.m_triangleType = PHY_INTEGER; 00041 00042 addMaterialProperties(mat); 00043 } 00044 00045 00046 void btTriangleIndexVertexMaterialArray::getLockedMaterialBase(unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, 00047 unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart) 00048 { 00049 btAssert(subpart< getNumSubParts() ); 00050 00051 btMaterialProperties& mats = m_materials[subpart]; 00052 00053 numMaterials = mats.m_numMaterials; 00054 (*materialBase) = (unsigned char *) mats.m_materialBase; 00055 #ifdef BT_USE_DOUBLE_PRECISION 00056 materialType = PHY_DOUBLE; 00057 #else 00058 materialType = PHY_FLOAT; 00059 #endif 00060 materialStride = mats.m_materialStride; 00061 00062 numTriangles = mats.m_numTriangles; 00063 (*triangleMaterialBase) = (unsigned char *)mats.m_triangleMaterialsBase; 00064 triangleMaterialStride = mats.m_triangleMaterialStride; 00065 triangleType = mats.m_triangleType; 00066 } 00067 00068 void btTriangleIndexVertexMaterialArray::getLockedReadOnlyMaterialBase(const unsigned char **materialBase, int& numMaterials, PHY_ScalarType& materialType, int& materialStride, 00069 const unsigned char ** triangleMaterialBase, int& numTriangles, int& triangleMaterialStride, PHY_ScalarType& triangleType, int subpart) 00070 { 00071 btMaterialProperties& mats = m_materials[subpart]; 00072 00073 numMaterials = mats.m_numMaterials; 00074 (*materialBase) = (const unsigned char *) mats.m_materialBase; 00075 #ifdef BT_USE_DOUBLE_PRECISION 00076 materialType = PHY_DOUBLE; 00077 #else 00078 materialType = PHY_FLOAT; 00079 #endif 00080 materialStride = mats.m_materialStride; 00081 00082 numTriangles = mats.m_numTriangles; 00083 (*triangleMaterialBase) = (const unsigned char *)mats.m_triangleMaterialsBase; 00084 triangleMaterialStride = mats.m_triangleMaterialStride; 00085 triangleType = mats.m_triangleType; 00086 }