use inline functions for subsurf MVert,MEdge mesh array functions, also some include...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 24 Jan 2013 11:28:26 +0000 (11:28 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 24 Jan 2013 11:28:26 +0000 (11:28 +0000)
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/modifiers/SConscript
source/blender/rigidbody/CMakeLists.txt
source/blender/rigidbody/SConscript
source/blender/rigidbody/rb_bullet_api.cpp

index 8a4471eec29aee65335bd4ddc85a72a1a3c97213..2e10407bee8dd11f719ec0fb2663cfdaf944373a 100644 (file)
@@ -1097,6 +1097,14 @@ void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly,
        }
 }
 
+/* utility functon */
+BLI_INLINE void ccgDM_to_MVert(MVert *mv, const CCGKey *key, CCGElem *elem)
+{
+       copy_v3_v3(mv->co, CCG_elem_co(key, elem));
+       normal_float_to_short_v3(mv->no, CCG_elem_no(key, elem));
+       mv->flag = mv->bweight = 0;
+}
+
 static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
 {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
@@ -1107,7 +1115,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
        int totvert, totedge, totface;
        int gridSize = ccgSubSurf_getGridSize(ss);
        int edgeSize = ccgSubSurf_getEdgeSize(ss);
-       int i = 0;
+       unsigned int i = 0;
 
        CCG_key_top_level(&key, ss);
 
@@ -1117,27 +1125,20 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
                int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
 
                vd = ccgSubSurf_getFaceCenterData(f);
-               copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd));
-               normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd));
-               mvert[i].flag = mvert[i].bweight = 0;
-               i++;
+               ccgDM_to_MVert(&mvert[i++], &key, vd);
                
                for (S = 0; S < numVerts; S++) {
-                       for (x = 1; x < gridSize - 1; x++, i++) {
+                       for (x = 1; x < gridSize - 1; x++) {
                                vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x);
-                               copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd));
-                               normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd));
-                               mvert[i].flag = mvert[i].bweight = 0;
+                               ccgDM_to_MVert(&mvert[i++], &key, vd);
                        }
                }
 
                for (S = 0; S < numVerts; S++) {
                        for (y = 1; y < gridSize - 1; y++) {
-                               for (x = 1; x < gridSize - 1; x++, i++) {
+                               for (x = 1; x < gridSize - 1; x++) {
                                        vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y);
-                                       copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd));
-                                       normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd));
-                                       mvert[i].flag = mvert[i].bweight = 0;
+                                       ccgDM_to_MVert(&mvert[i++], &key, vd);
                                }
                        }
                }
@@ -1148,16 +1149,14 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
                CCGEdge *e = ccgdm->edgeMap[index].edge;
                int x;
 
-               for (x = 1; x < edgeSize - 1; x++, i++) {
-                       vd = ccgSubSurf_getEdgeData(ss, e, x);
-                       copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd));
+               for (x = 1; x < edgeSize - 1; x++) {
                        /* This gives errors with -debug-fpe
                         * the normals don't seem to be unit length.
                         * this is most likely caused by edges with no
                         * faces which are now zerod out, see comment in:
                         * ccgSubSurf__calcVertNormals(), - campbell */
-                       normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd));
-                       mvert[i].flag = mvert[i].bweight = 0;
+                       vd = ccgSubSurf_getEdgeData(ss, e, x);
+                       ccgDM_to_MVert(&mvert[i++], &key, vd);
                }
        }
 
@@ -1166,13 +1165,20 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
                CCGVert *v = ccgdm->vertMap[index].vert;
 
                vd = ccgSubSurf_getVertData(ss, v);
-               copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd));
-               normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd));
-               mvert[i].flag = mvert[i].bweight = 0;
-               i++;
+               ccgDM_to_MVert(&mvert[i++], &key, vd);
        }
 }
 
+
+/* utility functon */
+BLI_INLINE void ccgDM_to_MEdge(MEdge *med, const int v1, const int v2, const short flag)
+{
+       med->v1 = v1;
+       med->v2 = v2;
+       med->crease = med->bweight = 0;
+       med->flag = flag;
+}
+
 static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
 {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
@@ -1181,7 +1187,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
        int totedge, totface;
        int gridSize = ccgSubSurf_getGridSize(ss);
        int edgeSize = ccgSubSurf_getEdgeSize(ss);
-       int i = 0;
+       unsigned int i = 0;
        short *edgeFlags = ccgdm->edgeFlags;
        const short ed_interior_flag = ccgdm->drawInteriorEdges ? (ME_EDGEDRAW | ME_EDGERENDER) : 0;
 
@@ -1192,36 +1198,22 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
 
                for (S = 0; S < numVerts; S++) {
                        for (x = 0; x < gridSize - 1; x++) {
-                               MEdge *med = &medge[i];
-
-                               med->v1 = getFaceIndex(ss, f, S, x, 0, edgeSize, gridSize);
-                               med->v2 = getFaceIndex(ss, f, S, x + 1, 0, edgeSize, gridSize);
-                               med->crease = med->bweight = 0;
-                               med->flag = ed_interior_flag;
-                               i++;
+                               ccgDM_to_MEdge(&medge[i++],
+                                              getFaceIndex(ss, f, S, x,     0, edgeSize, gridSize),
+                                              getFaceIndex(ss, f, S, x + 1, 0, edgeSize, gridSize),
+                                              ed_interior_flag);
                        }
 
                        for (x = 1; x < gridSize - 1; x++) {
                                for (y = 0; y < gridSize - 1; y++) {
-                                       MEdge *med;
-
-                                       med = &medge[i];
-                                       med->v1 = getFaceIndex(ss, f, S, x, y,
-                                                              edgeSize, gridSize);
-                                       med->v2 = getFaceIndex(ss, f, S, x, y + 1,
-                                                              edgeSize, gridSize);
-                                       med->crease = med->bweight = 0;
-                                       med->flag = ed_interior_flag;
-                                       i++;
-
-                                       med = &medge[i];
-                                       med->v1 = getFaceIndex(ss, f, S, y, x,
-                                                              edgeSize, gridSize);
-                                       med->v2 = getFaceIndex(ss, f, S, y + 1, x,
-                                                              edgeSize, gridSize);
-                                       med->crease = med->bweight = 0;
-                                       med->flag = ed_interior_flag;
-                                       i++;
+                                       ccgDM_to_MEdge(&medge[i++],
+                                                      getFaceIndex(ss, f, S, x, y,    edgeSize, gridSize),
+                                                      getFaceIndex(ss, f, S, x, y + 1, edgeSize, gridSize),
+                                                      ed_interior_flag);
+                                       ccgDM_to_MEdge(&medge[i++],
+                                                      getFaceIndex(ss, f, S, y, x,     edgeSize, gridSize),
+                                                      getFaceIndex(ss, f, S, y + 1, x, edgeSize, gridSize),
+                                                      ed_interior_flag);
                                }
                        }
                }
@@ -1230,28 +1222,28 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge)
        totedge = ccgSubSurf_getNumEdges(ss);
        for (index = 0; index < totedge; index++) {
                CCGEdge *e = ccgdm->edgeMap[index].edge;
-               unsigned int flags = 0;
+               short ed_flag = 0;
                int x;
                int edgeIdx = GET_INT_FROM_POINTER(ccgSubSurf_getEdgeEdgeHandle(e));
 
-               if (!ccgSubSurf_getEdgeNumFaces(e)) flags |= ME_LOOSEEDGE;
+               if (!ccgSubSurf_getEdgeNumFaces(e)) {
+                       ed_flag |= ME_LOOSEEDGE;
+               }
 
                if (edgeFlags) {
                        if (edgeIdx != -1) {
-                               flags |= ((edgeFlags[index] & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER);
+                               ed_flag |= ((edgeFlags[index] & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER);
                        }
                }
                else {
-                       flags |= ME_EDGEDRAW | ME_EDGERENDER;
+                       ed_flag |= ME_EDGEDRAW | ME_EDGERENDER;
                }
 
                for (x = 0; x < edgeSize - 1; x++) {
-                       MEdge *med = &medge[i];
-                       med->v1 = getEdgeIndex(ss, e, x, edgeSize);
-                       med->v2 = getEdgeIndex(ss, e, x + 1, edgeSize);
-                       med->crease = med->bweight = 0;
-                       med->flag = flags;
-                       i++;
+                       ccgDM_to_MEdge(&medge[i++],
+                                      getEdgeIndex(ss, e, x, edgeSize),
+                                      getEdgeIndex(ss, e, x + 1, edgeSize),
+                                      ed_flag);
                }
        }
 }
index cbd0ad12e05738f1bdcade470d0236aec8c54244..679109079c2644d7e73e322bf07024d340e30a4a 100644 (file)
 #
 # ***** END GPL LICENSE BLOCK *****
 
-Import ('env')
+Import('env')
 
 sources = env.Glob('intern/*.c')
 
 incs = [
-       '.',
-       './intern', 
-       '#/intern/guardedalloc',
-       '#/intern/bsp/extern',
-       '#/intern/elbeem/extern',
-       '#/extern/glew/include',
-       '#/intern/opennl/extern',
-       '../render/extern/include',
-       '../blenloader',
-       '../bmesh',
-       '../include',
-       '../blenlib',
-       '../blenfont',
-       '../makesdna',
-       '../makesrna',
-       '../blenkernel',
-       '../gpu',
-       env['BF_ZLIB_INC'],
-       ]
+    '.',
+    './intern', 
+    '#/intern/guardedalloc',
+    '#/intern/bsp/extern',
+    '#/intern/elbeem/extern',
+    '#/extern/glew/include',
+    '#/intern/opennl/extern',
+    '../render/extern/include',
+    '../blenloader',
+    '../bmesh',
+    '../include',
+    '../blenlib',
+    '../blenfont',
+    '../makesdna',
+    '../makesrna',
+    '../blenkernel',
+    '../gpu',
+    env['BF_ZLIB_INC'],
+    ]
 
 defs = []
 
index cf91cd6638cc5adf17f636e123b9b1849d5ce58f..903fbe66f01e65a49c4d05bd02164e05391908ed 100644 (file)
@@ -23,7 +23,6 @@
 
 SET(INC
        .
-       ../blenlib
        ../../../extern/bullet2/src
 )
 
index bddc9f2bab26a0eeea69edca192482e32eeb1987..14c8030498322d780a6ae469f3c50e32a324a8f4 100644 (file)
 #
 # ***** END GPL LICENSE BLOCK *****
 
-Import ('env')
+Import('env')
 
 # XXX: we need a contingency plan for when not compiling with Bullet,
 # since this module will always get included... 
 # This problem will also apply to other engines at a later date too...
 sources = env.Glob('*.cpp')
 
-incs = '../blenlib ../../../intern/guardedalloc ../../../extern/bullet2/src'
-
-env.BlenderLib ('bf_rigidbody', sources, Split(incs), [], libtype=['core', 'player'], priority=[180, 30] )
+incs = [
+    '.',
+    '../../../extern/bullet2/src',
+    ]
 
+env.BlenderLib('bf_rigidbody', sources=sources,
+               includes=incs, defines=[],
+               libtype=['core', 'player'], priority=[180, 30])
index c7955cae4f3cb80bb0a9de1aeebda390536b2277..c4a4532bad1a38d39cfb386d49e26fc5ffebfdb6 100644 (file)
@@ -60,8 +60,6 @@ subject to the following restrictions:
  
 #include "RBI_api.h"
 
-#include "BLI_math.h"
-
 #include "btBulletDynamicsCommon.h"
 
 #include "LinearMath/btVector3.h"