diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-24 15:28:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-24 15:28:26 +0400 |
commit | 66bf63d7af52762a81876adc2907c4fc414716f9 (patch) | |
tree | 65e0639779af2bcf41518d142d32befd980a7c80 | |
parent | 9592cade86b8ca15b72584f038508278434f8d89 (diff) |
use inline functions for subsurf MVert,MEdge mesh array functions, also some include cleanup for scons/cmake.
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 110 | ||||
-rw-r--r-- | source/blender/modifiers/SConscript | 40 | ||||
-rw-r--r-- | source/blender/rigidbody/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/rigidbody/SConscript | 12 | ||||
-rw-r--r-- | source/blender/rigidbody/rb_bullet_api.cpp | 2 |
5 files changed, 79 insertions, 86 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 8a4471eec29..2e10407bee8 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -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); } } } diff --git a/source/blender/modifiers/SConscript b/source/blender/modifiers/SConscript index cbd0ad12e05..679109079c2 100644 --- a/source/blender/modifiers/SConscript +++ b/source/blender/modifiers/SConscript @@ -25,30 +25,30 @@ # # ***** 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 = [] diff --git a/source/blender/rigidbody/CMakeLists.txt b/source/blender/rigidbody/CMakeLists.txt index cf91cd6638c..903fbe66f01 100644 --- a/source/blender/rigidbody/CMakeLists.txt +++ b/source/blender/rigidbody/CMakeLists.txt @@ -23,7 +23,6 @@ SET(INC . - ../blenlib ../../../extern/bullet2/src ) diff --git a/source/blender/rigidbody/SConscript b/source/blender/rigidbody/SConscript index bddc9f2bab2..14c80304983 100644 --- a/source/blender/rigidbody/SConscript +++ b/source/blender/rigidbody/SConscript @@ -25,14 +25,18 @@ # # ***** 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]) diff --git a/source/blender/rigidbody/rb_bullet_api.cpp b/source/blender/rigidbody/rb_bullet_api.cpp index c7955cae4f3..c4a4532bad1 100644 --- a/source/blender/rigidbody/rb_bullet_api.cpp +++ b/source/blender/rigidbody/rb_bullet_api.cpp @@ -60,8 +60,6 @@ subject to the following restrictions: #include "RBI_api.h" -#include "BLI_math.h" - #include "btBulletDynamicsCommon.h" #include "LinearMath/btVector3.h" |