2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
5
This software is provided 'as-is', without any express or implied warranty.
6
In no event will the authors be held liable for any damages arising from the use of this software.
7
Permission is granted to anyone to use this software for any purpose,
8
including commercial applications, and to alter it and redistribute it freely,
9
subject to the following restrictions:
11
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.
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13
3. This notice may not be removed or altered from any source distribution.
16
#include "StridingMeshInterface.h"
18
StridingMeshInterface::~StridingMeshInterface()
24
void StridingMeshInterface::InternalProcessAllTriangles(InternalTriangleIndexCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
27
SimdVector3 meshScaling = getScaling();
29
int numtotalphysicsverts = 0;
30
int part,graphicssubparts = getNumSubParts();
31
for (part=0;part<graphicssubparts ;part++)
33
const unsigned char * vertexbase;
34
const unsigned char * indexbase;
37
PHY_ScalarType gfxindextype;
38
int stride,numverts,numtriangles;
39
getLockedReadOnlyVertexIndexBase(&vertexbase,numverts,type,stride,&indexbase,indexstride,numtriangles,gfxindextype,part);
41
numtotalphysicsverts+=numtriangles*3; //upper bound
45
SimdVector3 triangle[3];
47
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
52
#ifdef DEBUG_TRIANGLE_MESH
53
printf("triangle indices:\n");
54
#endif //DEBUG_TRIANGLE_MESH
55
ASSERT(gfxindextype == PHY_INTEGER);
56
int* gfxbase = (int*)(indexbase+gfxindex*indexstride);
58
for (int j=2;j>=0;j--)
61
graphicsindex = gfxbase[j];
62
#ifdef DEBUG_TRIANGLE_MESH
63
printf("%d ,",graphicsindex);
64
#endif //DEBUG_TRIANGLE_MESH
65
float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
67
triangle[j] = SimdVector3(
68
graphicsbase[0]*meshScaling.getX(),
69
graphicsbase[1]*meshScaling.getY(),
70
graphicsbase[2]*meshScaling.getZ());
71
#ifdef DEBUG_TRIANGLE_MESH
72
printf("triangle vertices:%f,%f,%f\n",triangle[j].x(),triangle[j].y(),triangle[j].z());
73
#endif //DEBUG_TRIANGLE_MESH
77
//check aabb in triangle-space, before doing this
78
callback->InternalProcessTriangleIndex(triangle,part,gfxindex);
82
unLockReadOnlyVertexBase(part);