Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gameimmersion/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp @ 8474

Last change on this file since 8474 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1
2/*
3Bullet Continuous Collision Detection and Physics Library
4Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
5
6This software is provided 'as-is', without any express or implied warranty.
7In no event will the authors be held liable for any damages arising from the use of this software.
8Permission is granted to anyone to use this software for any purpose,
9including commercial applications, and to alter it and redistribute it freely,
10subject to the following restrictions:
11
121. 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.
132. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
143. 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
21btTriangleIndexVertexMaterialArray::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) :
25btTriangleIndexVertexArray(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
47void 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
69void 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}
Note: See TracBrowser for help on using the repository browser.