~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

Viewing changes to extern/bullet/Bullet/CollisionShapes/StridingMeshInterface.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Bullet Continuous Collision Detection and Physics Library
3
 
Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
 
 
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:
10
 
 
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.
14
 
*/
15
 
 
16
 
#include "StridingMeshInterface.h"
17
 
 
18
 
StridingMeshInterface::~StridingMeshInterface()
19
 
{
20
 
 
21
 
}
22
 
 
23
 
 
24
 
void    StridingMeshInterface::InternalProcessAllTriangles(InternalTriangleIndexCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
25
 
{
26
 
 
27
 
        SimdVector3 meshScaling = getScaling();
28
 
 
29
 
        int numtotalphysicsverts = 0;
30
 
        int part,graphicssubparts = getNumSubParts();
31
 
        for (part=0;part<graphicssubparts ;part++)
32
 
        {
33
 
                const unsigned char * vertexbase;
34
 
                const unsigned char * indexbase;
35
 
                int indexstride;
36
 
                PHY_ScalarType type;
37
 
                PHY_ScalarType gfxindextype;
38
 
                int stride,numverts,numtriangles;
39
 
                getLockedReadOnlyVertexIndexBase(&vertexbase,numverts,type,stride,&indexbase,indexstride,numtriangles,gfxindextype,part);
40
 
 
41
 
                numtotalphysicsverts+=numtriangles*3; //upper bound
42
 
 
43
 
        
44
 
                int gfxindex;
45
 
                SimdVector3 triangle[3];
46
 
 
47
 
                for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
48
 
                {
49
 
                
50
 
                        int     graphicsindex=0;
51
 
 
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);
57
 
 
58
 
                        for (int j=2;j>=0;j--)
59
 
                        {
60
 
                                
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);
66
 
 
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
74
 
                        }
75
 
 
76
 
                        
77
 
                        //check aabb in triangle-space, before doing this
78
 
                        callback->InternalProcessTriangleIndex(triangle,part,gfxindex);
79
 
                        
80
 
                }
81
 
                
82
 
                unLockReadOnlyVertexBase(part);
83
 
        }
84
 
}
85