From a37bcf93ef395817a881918053ffff9c2ab73a03 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Wed, 14 Jul 2010 22:06:10 +0000 Subject: [PATCH] wip commit; DO NOT USE. almost done with phase 1 of this restructuring, basically just some things that needed to be done before trunk (and some things that needed to be started, but can be finished much later). --- intern/guardedalloc/MEM_guardedalloc.h | 2 +- intern/guardedalloc/intern/mallocn.c | 5 +- source/blender/CMakeLists.txt | 2 +- source/blender/blenkernel/BKE_DerivedMesh.h | 14 - source/blender/blenkernel/BKE_utildefines.h | 10 - source/blender/blenkernel/CMakeLists.txt | 5 +- .../blenkernel/intern/BME_Customdata.c | 2 + .../blenkernel/intern/BME_conversions.c | 2 + source/blender/blenkernel/intern/BME_eulers.c | 106 ++-- source/blender/blenkernel/intern/BME_mesh.c | 40 +- .../blender/blenkernel/intern/BME_structure.c | 67 +- source/blender/blenkernel/intern/BME_tools.c | 112 ++-- .../blender/blenkernel/intern/DerivedMesh.c | 5 +- .../blender/blenkernel/intern/cdderivedmesh.c | 3 - source/blender/blenkernel/intern/customdata.c | 34 +- .../blenkernel/intern/editderivedbmesh.c | 50 +- source/blender/blenkernel/intern/modifier.c | 15 +- .../blenkernel/intern/modifiers_bmesh.c | 3 - source/blender/blenlib/BLI_array.h | 26 +- source/blender/blenlib/BLI_ghash.h | 31 +- source/blender/blenlib/BLI_math_vector.h | 2 + source/blender/blenlib/BLI_mempool.h | 26 +- source/blender/blenlib/CMakeLists.txt | 6 +- source/blender/blenlib/intern/BLI_cellalloc.c | 2 +- source/blender/blenlib/intern/BLI_ghash.c | 2 +- source/blender/blenlib/intern/BLI_mempool.c | 106 +++- source/blender/blenlib/intern/DLRB_tree.c | 6 - source/blender/blenlib/intern/edgehash.c | 2 +- source/blender/blenloader/CMakeLists.txt | 2 +- source/blender/bmesh/bmesh.h | 356 ++++++----- source/blender/bmesh/bmesh_iterators.h | 12 +- source/blender/bmesh/bmesh_operator_api.h | 28 +- source/blender/bmesh/intern/bmesh_construct.c | 242 ++++---- source/blender/bmesh/intern/bmesh_eulers.c | 306 +++++----- source/blender/bmesh/intern/bmesh_interp.c | 40 +- source/blender/bmesh/intern/bmesh_iterators.c | 111 ++-- source/blender/bmesh/intern/bmesh_marking.c | 18 +- source/blender/bmesh/intern/bmesh_mesh.c | 71 +-- source/blender/bmesh/intern/bmesh_mods.c | 145 +++-- source/blender/bmesh/intern/bmesh_operators.c | 62 +- source/blender/bmesh/intern/bmesh_polygon.c | 69 +-- source/blender/bmesh/intern/bmesh_private.h | 29 +- source/blender/bmesh/intern/bmesh_queries.c | 150 ++--- source/blender/bmesh/intern/bmesh_structure.c | 573 +++++++++++------- source/blender/bmesh/intern/bmesh_structure.h | 24 +- .../blender/bmesh/intern/bmesh_to_editmesh.c | 28 +- source/blender/bmesh/intern/bmesh_walkers.c | 48 +- .../blender/bmesh/intern/editmesh_to_bmesh.c | 6 +- .../blender/bmesh/operators/bmesh_dupeops.c | 2 +- source/blender/bmesh/operators/connectops.c | 4 +- source/blender/bmesh/operators/createops.c | 4 +- source/blender/bmesh/operators/dissolveops.c | 14 +- source/blender/bmesh/operators/edgesplitop.c | 20 +- source/blender/bmesh/operators/extrudeops.c | 39 +- .../blender/bmesh/operators/join_triangles.c | 44 +- source/blender/bmesh/operators/mesh_conv.c | 24 +- .../blender/bmesh/operators/removedoubles.c | 6 +- source/blender/bmesh/operators/subdivideop.c | 41 +- source/blender/bmesh/operators/utils.c | 13 +- source/blender/bmesh/tools/BME_bevel.c | 46 +- source/blender/bmesh/tools/BME_dupe_ops.c | 14 +- source/blender/bmesh/tools/BME_duplicate.c | 14 +- source/blender/bmesh/tools/BME_extrude.c | 28 +- source/blender/editors/CMakeLists.txt | 44 +- source/blender/editors/include/ED_mesh.h | 3 + source/blender/editors/mesh/bmesh_select.c | 12 +- source/blender/editors/mesh/bmesh_tools.c | 30 +- source/blender/editors/mesh/editbmesh_bvh.c | 55 +- source/blender/editors/mesh/editface.c | 51 +- source/blender/editors/mesh/loopcut.c | 6 +- source/blender/editors/mesh/mesh_intern.h | 2 +- .../blender/editors/object/object_modifier.c | 11 + source/blender/editors/sculpt_paint/sculpt.c | 1 - .../blender/editors/space_view3d/drawobject.c | 33 +- .../editors/space_view3d/view3d_buttons.c | 15 +- source/blender/editors/transform/transform.c | 22 +- .../editors/transform/transform_conversions.c | 24 +- .../transform/transform_orientations.c | 4 +- source/blender/editors/uvedit/uvedit_draw.c | 8 +- source/blender/editors/uvedit/uvedit_ops.c | 18 +- source/blender/gpu/CMakeLists.txt | 8 +- .../blender/makesdna/DNA_customdata_types.h | 7 +- source/blender/makesrna/intern/CMakeLists.txt | 2 +- source/blender/quicktime/CMakeLists.txt | 1 + source/blender/render/CMakeLists.txt | 2 +- source/blender/windowmanager/CMakeLists.txt | 2 +- source/creator/CMakeLists.txt | 229 +------ .../Converter/BL_ArmatureObject.cpp | 3 +- source/gameengine/Converter/SConscript | 1 + source/gameengine/Ketsji/SConscript | 1 + source/gameengine/Physics/Bullet/SConscript | 1 + .../RAS_OpenGLRasterizer/SConscript | 2 +- source/gameengine/Rasterizer/SConscript | 2 +- 93 files changed, 2083 insertions(+), 1836 deletions(-) diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 69bb9347df7..1d001ea6074 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -176,7 +176,7 @@ typedef struct MemHead { } MemHead; typedef struct MemTail { - int tag3, pad; + int tag3, tag4; } MemTail; /*memory bias to hopefully account diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index 33ca1ba9a97..42f5443aef2 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -71,6 +71,7 @@ static const char *check_memlist(MemHead *memh); #define MEMTAG1 MAKE_ID('M', 'E', 'M', 'O') #define MEMTAG2 MAKE_ID('R', 'Y', 'B', 'L') #define MEMTAG3 MAKE_ID('O', 'C', 'K', '!') +#define MEMTAG4 MAKE_ID('C', 'R', 'A', 'P') #define MEMFREE MAKE_ID('F', 'R', 'E', 'E') #define MEMNEXT(x) ((MemHead *)(((char *) x) - ((char *) & (((MemHead *)0)->next)))) @@ -230,6 +231,7 @@ static void make_memhead_header(MemHead *memh, unsigned int len, const char *str memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + len); memt->tag3 = MEMTAG3; + memt->tag4 = MEMTAG4; addtail(membase,&memh->next); if (memh->next) memh->nextname = MEMNEXT(memh->next)->name; @@ -555,11 +557,12 @@ short _MEM_freeN(void *vmemh, char *file, int line) /* anders compileertie niet mem_lock_thread(); if ((memh->tag1 == MEMTAG1) && (memh->tag2 == MEMTAG2) && ((memh->len & 0x3) == 0)) { memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + memh->len); - if (memt->tag3 == MEMTAG3){ + if (memt->tag3 == MEMTAG3 && memt->tag4 == MEMTAG4){ memh->tag1 = MEMFREE; memh->tag2 = MEMFREE; memt->tag3 = MEMFREE; + memt->tag4 = MEMFREE; /* after tags !!! */ rem_memblock(memh); diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index b0c88a48536..b7686752882 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -30,6 +30,7 @@ ADD_SUBDIRECTORY(avi) ADD_SUBDIRECTORY(nodes) ADD_SUBDIRECTORY(blenkernel) ADD_SUBDIRECTORY(blenlib) +ADD_SUBDIRECTORY(bmesh) ADD_SUBDIRECTORY(blenloader) ADD_SUBDIRECTORY(blenpluginapi) ADD_SUBDIRECTORY(imbuf) @@ -40,7 +41,6 @@ ADD_SUBDIRECTORY(makesrna) ADD_SUBDIRECTORY(readblenfile) ADD_SUBDIRECTORY(render) ADD_SUBDIRECTORY(blenfont) -ADD_SUBDIRECTORY(bmesh) ADD_SUBDIRECTORY(ikplugin) IF(WITH_OPENEXR) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 4a099613887..1440176f1d9 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -86,7 +86,6 @@ #include "BKE_customdata.h" #include "BKE_bvhutils.h" -#include "BKE_tessmesh.h" struct MVert; struct MEdge; @@ -130,19 +129,6 @@ typedef struct DMLoopIter { loop refers to per-face-vertex data.*/ void *(*getLoopCDData)(void *self, int type, int layer); void *(*getVertCDData)(void *self, int type, int layer); - -/* derivedmesh 2.0 interface ideas (will likely never be implemented ;): - void (*interpLoopData)(void *self, void **src_blocks, - float *weights, float *sub_weights, int count); - - //a generic handle for a loop - intptr_t lhandle; - - inside DerivedMesh itself: - // - //void (*interpLoopData)(DerivedMesh *dm, DMLoopIter *destloop, - // intptr_t *loop_handles, int totloop); -*/ } DMLoopIter; typedef struct DMFaceIter { diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 1ad411b4c89..f9252eac875 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -229,14 +229,4 @@ extern "C" { #ifdef __cplusplus } #endif - -/*little macro so inline keyword works*/ -#if defined(_MSC_VER) -#define BM_INLINE static __forceinline -#else -#define BM_INLINE static inline __attribute((always_inline)) -#endif - -#define BMEMSET(mem, val, size) {unsigned int _i; char *_c = (char*) mem; for (_i=0; _iset_default((char*)*block + offset, 1); } } +#endif diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index 160a073be80..4181825acb5 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -1,3 +1,4 @@ +#if 0 /** * BME_mesh.c jan 2007 * @@ -641,3 +642,4 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) BLI_edgehash_free(edge_hash, NULL); return result; } +#endif diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index 647671d0ed8..9c83f6aaf65 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -1,3 +1,4 @@ +#if 0 /** * BME_eulers.c jan 2007 * @@ -135,13 +136,13 @@ BME_Edge *BME_ME(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2){ #ifndef BME_FASTEULER /*count valance of v1*/ - if(v1->edge){ - d1 = BME_disk_getpointer(v1->edge,v1); + if(v1->e){ + d1 = BME_disk_getpointer(v1->e,v1); if(d1) valance1 = BME_cycle_length(d1); else BME_error(); } - if(v2->edge){ - d2 = BME_disk_getpointer(v2->edge,v2); + if(v2->e){ + d2 = BME_disk_getpointer(v2->e,v2); if(d2) valance2 = BME_cycle_length(d2); else BME_error(); } @@ -209,7 +210,7 @@ BME_Poly *BME_MF(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge **elist, int elist[i]->eflag1 |= MF_CANDIDATE; /*if elist[i] has a loop, count its radial length*/ - if(elist[i]->loop) elist[i]->eflag2 = BME_cycle_length(&(elist[i]->loop->radial)); + if(elist[i]->loop) elist[i]->eflag2 = BME_cycle_length(&(elist[i]->l->radial)); else elist[i]->eflag2 = 0; } @@ -279,8 +280,8 @@ BME_Poly *BME_MF(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge **elist, int for(i=0;iloopbase)) f->loopbase = l; - BME_cycle_append(f->loopbase, l); + if(!(f->loopbase)) f->lbase = l; + BME_cycle_append(f->lbase, l); } /*take care of edge pointers and radial cycle*/ @@ -304,7 +305,7 @@ BME_Poly *BME_MF(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge **elist, int f->len = len; /*Validation Loop cycle*/ - edok = BME_cycle_validate(len, f->loopbase); + edok = BME_cycle_validate(len, f->lbase); if(!edok) BME_error(); for(i=0, l = f->loopbase; inext){ /*validate loop vert pointers*/ @@ -332,7 +333,7 @@ BME_Poly *BME_MF(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge **elist, int */ int BME_KV(BME_Mesh *bm, BME_Vert *v){ - if(v->edge == NULL){ + if(v->e == NULL){ BLI_remlink(&(bm->verts), v); BME_free_vert(bm,v); return 1; @@ -355,7 +356,7 @@ int BME_KE(BME_Mesh *bm, BME_Edge *e){ int edok; /*Make sure that no faces!*/ - if(e->loop == NULL){ + if(e->l == NULL){ BME_disk_remove_edge(e, e->v1); BME_disk_remove_edge(e, e->v2); @@ -391,14 +392,14 @@ int BME_KF(BME_Mesh *bm, BME_Poly *bply){ /*add validation to make sure that radial cycle is cleaned up ok*/ /*deal with radial cycle first*/ - len = BME_cycle_length(bply->loopbase); + len = BME_cycle_length(bply->lbase); for(i=0, curloop=bply->loopbase; i < len; i++, curloop = curloop->next) BME_radial_remove_loop(curloop, curloop->e); /*now deallocate the editloops*/ for(i=0; i < len; i++){ - newbase = bply->loopbase->next; - oldbase = bply->loopbase; + newbase = bply->lbase->next; + oldbase = bply->lbase; BME_cycle_remove(oldbase, oldbase); BME_free_loop(bm, oldbase); bply->loopbase = newbase; @@ -458,24 +459,24 @@ BME_Vert *BME_SEMV(BME_Mesh *bm, BME_Vert *tv, BME_Edge *e, BME_Edge **re){ /*add ne to tv's disk cycle*/ BME_disk_append_edge(ne, tv); /*verify disk cycles*/ - diskbase = BME_disk_getpointer(ov->edge,ov); + diskbase = BME_disk_getpointer(ov->e,ov); edok = BME_cycle_validate(valance1, diskbase); if(!edok) BME_error(); - diskbase = BME_disk_getpointer(tv->edge,tv); + diskbase = BME_disk_getpointer(tv->e,tv); edok = BME_cycle_validate(valance2, diskbase); if(!edok) BME_error(); - diskbase = BME_disk_getpointer(nv->edge,nv); + diskbase = BME_disk_getpointer(nv->e,nv); edok = BME_cycle_validate(2, diskbase); if(!edok) BME_error(); /*Split the radial cycle if present*/ - if(e->loop){ + if(e->l){ BME_Loop *nl,*l; BME_CycleNode *radEBase=NULL, *radNEBase=NULL; - int radlen = BME_cycle_length(&(e->loop->radial)); + int radlen = BME_cycle_length(&(e->l->radial)); /*Take the next loop. Remove it from radial. Split it. Append to appropriate radials.*/ - while(e->loop){ - l=e->loop; + while(e->l){ + l=e->l; l->f->len++; BME_radial_remove_loop(l,e); @@ -528,17 +529,17 @@ BME_Vert *BME_SEMV(BME_Mesh *bm, BME_Vert *tv, BME_Edge *e, BME_Edge **re){ } - e->loop = radEBase->data; - ne->loop = radNEBase->data; + e->l = radEBase->data; + ne->l = radNEBase->data; /*verify length of radial cycle*/ - edok = BME_cycle_validate(radlen,&(e->loop->radial)); + edok = BME_cycle_validate(radlen,&(e->l->radial)); if(!edok) BME_error(); - edok = BME_cycle_validate(radlen,&(ne->loop->radial)); + edok = BME_cycle_validate(radlen,&(ne->l->radial)); if(!edok) BME_error(); /*verify loop->v and loop->next->v pointers for e*/ - for(i=0,l=e->loop; i < radlen; i++, l = l->radial.next->data){ + for(i=0,l=e->l; i < radlen; i++, l = l->radial_next){ if(!(l->e == e)) BME_error(); if(!(l->radial.data == l)) BME_error(); if(l->prev->e != ne && l->next->e != ne) BME_error(); @@ -547,11 +548,11 @@ BME_Vert *BME_SEMV(BME_Mesh *bm, BME_Vert *tv, BME_Edge *e, BME_Edge **re){ if(l->v == l->next->v) BME_error(); if(l->e == l->next->e) BME_error(); /*verify loop cycle for kloop->f*/ - edok = BME_cycle_validate(l->f->len, l->f->loopbase); + edok = BME_cycle_validate(l->f->len, l->f->lbase); if(!edok) BME_error(); } /*verify loop->v and loop->next->v pointers for ne*/ - for(i=0,l=ne->loop; i < radlen; i++, l = l->radial.next->data){ + for(i=0,l=ne->l; i < radlen; i++, l = l->radial_next){ if(!(l->e == ne)) BME_error(); if(!(l->radial.data == l)) BME_error(); if(l->prev->e != e && l->next->e != e) BME_error(); @@ -560,7 +561,7 @@ BME_Vert *BME_SEMV(BME_Mesh *bm, BME_Vert *tv, BME_Edge *e, BME_Edge **re){ if(l->v == l->next->v) BME_error(); if(l->e == l->next->e) BME_error(); /*verify loop cycle for kloop->f. Redundant*/ - edok = BME_cycle_validate(l->f->len, l->f->loopbase); + edok = BME_cycle_validate(l->f->len, l->f->lbase); if(!edok) BME_error(); } } @@ -605,7 +606,7 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo /*verify that v1 and v2 are in face.*/ - len = BME_cycle_length(f->loopbase); + len = BME_cycle_length(f->lbase); for(i = 0, curloop = f->loopbase; i < len; i++, curloop = curloop->next){ if(curloop->v == v1) v1loop = curloop; else if(curloop->v == v2) v2loop = curloop; @@ -639,7 +640,7 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo /*I dont know how many loops are supposed to be in each face at this point! FIXME!*/ /*go through all of f2's loops and make sure they point to it properly.*/ - f2len = BME_cycle_length(f2->loopbase); + f2len = BME_cycle_length(f2->lbase); for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = curloop->next) curloop->f = f2; /*link up the new loops into the new edges radial*/ @@ -649,7 +650,7 @@ BME_Poly *BME_SFME(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Vert *v2, BME_Lo f2->len = f2len; - f1len = BME_cycle_length(f->loopbase); + f1len = BME_cycle_length(f->lbase); f->len = f1len; if(rl) *rl = f2loop; @@ -697,7 +698,7 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv) int len,radlen=0, halt = 0, i, valance1, valance2,edok; if(BME_vert_in_edge(ke,kv) == 0) return 0; - diskbase = BME_disk_getpointer(kv->edge, kv); + diskbase = BME_disk_getpointer(kv->e, kv); len = BME_cycle_length(diskbase); if(len == 2){ @@ -710,9 +711,9 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv) else{ /*For verification later, count valance of ov and tv*/ - diskbase = BME_disk_getpointer(ov->edge, ov); + diskbase = BME_disk_getpointer(ov->e, ov); valance1 = BME_cycle_length(diskbase); - diskbase = BME_disk_getpointer(tv->edge, tv); + diskbase = BME_disk_getpointer(tv->e, tv); valance2 = BME_cycle_length(diskbase); /*remove oe from kv's disk cycle*/ @@ -727,10 +728,10 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv) /*deal with radial cycle of ke*/ - if(ke->loop){ + if(ke->l){ /*first step, fix the neighboring loops of all loops in ke's radial cycle*/ - radlen = BME_cycle_length(&(ke->loop->radial)); - for(i=0,killoop = ke->loop; il->radial)); + for(i=0,killoop = ke->l; inext->prev = killoop->prev; killoop->prev->next = killoop->next; @@ -738,11 +739,11 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv) /*fix len attribute of face*/ killoop->f->len--; - if(killoop->f->loopbase == killoop) killoop->f->loopbase = killoop->next; + if(killoop->f->loopbase == killoop) killoop->f->lbase = killoop->next; } /*second step, remove all the hanging loops attached to ke*/ - killoop = ke->loop; - radlen = BME_cycle_length(&(ke->loop->radial)); + killoop = ke->l; + radlen = BME_cycle_length(&(ke->l->radial)); /*make sure we have enough room in bm->lpar*/ if(bm->lparlen < radlen){ MEM_freeN(bm->lpar); @@ -753,7 +754,7 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv) i=0; while(ilpar[i] = killoop; - killoop = killoop->radial.next->data; + killoop = killoop->radial_next; i++; } i=0; @@ -762,22 +763,22 @@ int BME_JEKV(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv) i++; } /*Validate radial cycle of oe*/ - edok = BME_cycle_validate(radlen,&(oe->loop->radial)); + edok = BME_cycle_validate(radlen,&(oe->l->radial)); } /*Validate disk cycles*/ - diskbase = BME_disk_getpointer(ov->edge,ov); + diskbase = BME_disk_getpointer(ov->e,ov); edok = BME_cycle_validate(valance1, diskbase); if(!edok) BME_error(); - diskbase = BME_disk_getpointer(tv->edge,tv); + diskbase = BME_disk_getpointer(tv->e,tv); edok = BME_cycle_validate(valance2, diskbase); if(!edok) BME_error(); /*Validate loop cycle of all faces attached to oe*/ - for(i=0,nextl = oe->loop; if->len,nextl->f->loopbase); + for(i=0,nextl = oe->l; if->len,nextl->f->lbase); if(!edok) BME_error(); } /*deallocate edge*/ @@ -907,8 +908,8 @@ BME_Poly *BME_JFKE(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e) if(f1 == f2) return NULL; //can't join a face to itself /*verify that e is in both f1 and f2*/ - f1len = BME_cycle_length(f1->loopbase); - f2len = BME_cycle_length(f2->loopbase); + f1len = BME_cycle_length(f1->lbase); + f2len = BME_cycle_length(f2->lbase); for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = curloop->next){ if(curloop->e == e){ f1loop = curloop; @@ -947,19 +948,19 @@ BME_Poly *BME_JFKE(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e) f2loop->prev->next = f1loop->next; /*if f1loop was baseloop, give f1loop->next the base.*/ - if(f1->loopbase == f1loop) f1->loopbase = f1loop->next; + if(f1->loopbase == f1loop) f1->lbase = f1loop->next; /*validate the new loop*/ - loopok = BME_cycle_validate((f1len+f2len)-2, f1->loopbase); + loopok = BME_cycle_validate((f1len+f2len)-2, f1->lbase); if(!loopok) BME_error(); /*make sure each loop points to the proper face*/ - newlen = BME_cycle_length(f1->loopbase); + newlen = BME_cycle_length(f1->lbase); for(i = 0, curloop = f1->loopbase; i < newlen; i++, curloop = curloop->next) curloop->f = f1; f1->len = newlen; - edok = BME_cycle_validate(f1->len, f1->loopbase); + edok = BME_cycle_validate(f1->len, f1->lbase); if(!edok) BME_error(); /*remove edge from the disk cycle of its two vertices.*/ @@ -975,3 +976,4 @@ BME_Poly *BME_JFKE(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e) BME_free_poly(bm, f2); return f1; } +#endif diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index f1f9f27031b..e9a1284809a 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -1,3 +1,4 @@ +#if 0 /** * BME_mesh.c jan 2007 * @@ -55,10 +56,10 @@ BME_Mesh *BME_make_mesh(int allocsize[4]) /*allocate the structure*/ BME_Mesh *bm = MEM_callocN(sizeof(BME_Mesh),"BMesh"); /*allocate the memory pools for the mesh elements*/ - bm->vpool = BLI_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0], 1); - bm->epool = BLI_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1], 1); - bm->lpool = BLI_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2], 1); - bm->ppool = BLI_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3], 1); + bm->vpool = BLI_mempool_create(sizeof(BME_Vert), allocsize[0], allocsize[0], 1, 0); + bm->epool = BLI_mempool_create(sizeof(BME_Edge), allocsize[1], allocsize[1], 1, 0); + bm->lpool = BLI_mempool_create(sizeof(BME_Loop), allocsize[2], allocsize[2], 1, 0); + bm->ppool = BLI_mempool_create(sizeof(BME_Poly), allocsize[3], allocsize[3], 1, 0); return bm; } /* @@ -82,7 +83,7 @@ void BME_free_mesh(BME_Mesh *bm) do{ CustomData_bmesh_free_block(&bm->ldata, &l->data); l = l->next; - }while(l!=f->loopbase); + }while(l!=f->lbase); } /*Free custom data pools, This should probably go in CustomData_free?*/ @@ -196,9 +197,9 @@ int BME_validate_mesh(struct BME_Mesh *bm, int halt) if(e->v1 == e->v2) VHALT(halt); /*validate e->d1.data and e->d2.data*/ if(e->d1.data != e || e->d2.data != e) VHALT(halt); - /*validate e->loop->e*/ - if(e->loop){ - if(e->loop->e != e) VHALT(halt); + /*validate e->l->e*/ + if(e->l){ + if(e->l->e != e) VHALT(halt); } } @@ -210,17 +211,17 @@ int BME_validate_mesh(struct BME_Mesh *bm, int halt) } /*Validate vertices and disk cycle*/ for(v=bm->verts.first; v; v=v->next){ - /*validate v->edge pointer*/ + /*validate v->e pointer*/ if(v->tflag1){ - if(v->edge){ - ok = BME_vert_in_edge(v->edge,v); + if(v->e){ + ok = BME_vert_in_edge(v->e,v); if(!ok) VHALT(halt); /*validate length of disk cycle*/ - diskbase = BME_disk_getpointer(v->edge, v); + diskbase = BME_disk_getpointer(v->e, v); ok = BME_cycle_validate(v->tflag1, diskbase); if(!ok) VHALT(halt); /*validate that each edge in disk cycle contains V*/ - for(i=0, e=v->edge; i < v->tflag1; i++, e = BME_disk_nextedge(e,v)){ + for(i=0, e=v->e; i < v->tflag1; i++, e = BME_disk_nextedge(e,v)){ ok = BME_vert_in_edge(e, v); if(!ok) VHALT(halt); } @@ -242,7 +243,7 @@ int BME_validate_mesh(struct BME_Mesh *bm, int halt) for(e=bm->edges.first; e; e=e->next) e->tflag2 = 0; //store incident faces /*Validate the loop cycle integrity.*/ for(f=bm->polys.first; f; f=f->next){ - ok = BME_cycle_length(f->loopbase); + ok = BME_cycle_length(f->lbase); if(ok > 1){ f->tflag1 = ok; } @@ -253,11 +254,11 @@ int BME_validate_mesh(struct BME_Mesh *bm, int halt) if(!ok) VHALT(halt); /*verify radial node data pointer*/ if(l->radial.data != l) VHALT(halt); - /*validate l->e->loop poitner*/ - if(l->e->loop == NULL) VHALT(halt); + /*validate l->e->l poitner*/ + if(l->e->l == NULL) VHALT(halt); /*validate l->f pointer*/ if(l->f != f) VHALT(halt); - /*see if l->e->loop is actually in radial cycle*/ + /*see if l->e->l is actually in radial cycle*/ l->e->tflag2++; } @@ -265,8 +266,8 @@ int BME_validate_mesh(struct BME_Mesh *bm, int halt) /*validate length of radial cycle*/ for(e=bm->edges.first; e; e=e->next){ - if(e->loop){ - ok = BME_cycle_validate(e->tflag2,&(e->loop->radial)); + if(e->l){ + ok = BME_cycle_validate(e->tflag2,&(e->l->radial)); if(!ok) VHALT(halt); } } @@ -283,3 +284,4 @@ int BME_validate_mesh(struct BME_Mesh *bm, int halt) void BME_error(void){ printf("BME modelling error!"); } +#endif diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index da0ce4da43b..bc14e5d37d6 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -1,3 +1,4 @@ +#if 0 /** * BME_structure.c jan 2007 * @@ -31,7 +32,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ - +#if 0 #include #include "MEM_guardedalloc.h" @@ -89,7 +90,7 @@ BME_Vert *BME_addvertlist(BME_Mesh *bm, BME_Vert *example){ v->EID = bm->nextv; v->co[0] = v->co[1] = v->co[2] = 0.0f; v->no[0] = v->no[1] = v->no[2] = 0.0f; - v->edge = NULL; + v->e = NULL; v->data = NULL; v->eflag1 = v->eflag2 = v->tflag1 = v->tflag2 = 0; v->flag = v->h = 0; @@ -117,7 +118,7 @@ BME_Edge *BME_addedgelist(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge *ex e->d1.next = e->d1.prev = e->d2.next = e->d2.prev = NULL; e->d1.data = e; e->d2.data = e; - e->loop = NULL; + e->l = NULL; e->data = NULL; e->eflag1 = e->eflag2 = e->tflag1 = e->tflag2 = 0; e->flag = e->h = 0; @@ -242,7 +243,7 @@ void BME_free_loop(BME_Mesh *bm, BME_Loop *l){ * BME_disk_getpointer * * 2: The Radial Cycle - A circle of face edges (BME_Loop) around an edge - * Base: edge->loop->radial structure. + * Base: edge->l->radial structure. * * The radial cycle is similar to the radial cycle in the radial edge data structure.* * Unlike the radial edge however, the radial cycle does not require a large amount of memory @@ -258,7 +259,7 @@ void BME_free_loop(BME_Mesh *bm, BME_Loop *l){ * * * 3: The Loop Cycle - A circle of face edges around a polygon. - * Base: polygon->loopbase. + * Base: polygon->lbase. * * The loop cycle keeps track of a faces vertices and edges. It should be noted that the * direction of a loop cycle is either CW or CCW depending on the face normal, and is @@ -446,15 +447,15 @@ int BME_disk_append_edge(BME_Edge *e, BME_Vert *v) if(BME_vert_in_edge(e, v) == 0) return 0; /*check to make sure v is in e*/ /*check for loose vert first*/ - if(v->edge == NULL){ - v->edge = e; + if(v->e == NULL){ + v->e = e; base = tail = BME_disk_getpointer(e, v); BME_cycle_append(base, tail); /*circular reference is ok!*/ return 1; } - /*insert e at the end of disk cycle and make it the new v->edge*/ - base = BME_disk_getpointer(v->edge, v); + /*insert e at the end of disk cycle and make it the new v->e*/ + base = BME_disk_getpointer(v->e, v); tail = BME_disk_getpointer(e, v); BME_cycle_append(base, tail); return 1; @@ -477,18 +478,18 @@ void BME_disk_remove_edge(BME_Edge *e, BME_Vert *v) BME_Edge *newbase; int len; - base = BME_disk_getpointer(v->edge, v); + base = BME_disk_getpointer(v->e, v); remnode = BME_disk_getpointer(e, v); - /*first deal with v->edge pointer...*/ + /*first deal with v->e pointer...*/ len = BME_cycle_length(base); if(len == 1) newbase = NULL; - else if(v->edge == e) newbase = base->next-> data; - else newbase = v->edge; + else if(v->e == e) newbase = base->next-> data; + else newbase = v->e; /*remove and rebase*/ BME_cycle_remove(base, remnode); - v->edge = newbase; + v->e = newbase; } /** @@ -541,12 +542,12 @@ int BME_disk_count_edgeflag(BME_Vert *v, int eflag, int tflag){ BME_Edge *curedge; int i, len=0, count=0; - if(v->edge){ + if(v->e){ if(eflag && tflag) return 0; /*tflag and eflag are reserved for different functions!*/ - diskbase = BME_disk_getpointer(v->edge, v); + diskbase = BME_disk_getpointer(v->e, v); len = BME_cycle_length(diskbase); - for(i = 0, curedge=v->edge; ie; itflag1 == tflag) count++; } @@ -564,11 +565,11 @@ int BME_disk_hasedge(BME_Vert *v, BME_Edge *e){ BME_Edge *curedge; int i, len=0; - if(v->edge){ - diskbase = BME_disk_getpointer(v->edge,v); + if(v->e){ + diskbase = BME_disk_getpointer(v->e,v); len = BME_cycle_length(diskbase); - for(i = 0, curedge=v->edge; ie; iradial.next->data); + return (BME_Loop*)(l->radial_next); } void BME_radial_append(BME_Edge *e, BME_Loop *l){ - if(e->loop == NULL) e->loop = l; - BME_cycle_append(&(e->loop->radial), &(l->radial)); + if(e->l == NULL) e->l = l; + BME_cycle_append(&(e->l->radial), &(l->radial)); } void BME_radial_remove_loop(BME_Loop *l, BME_Edge *e) @@ -591,15 +592,15 @@ void BME_radial_remove_loop(BME_Loop *l, BME_Edge *e) BME_Loop *newbase; int len; - /*deal with edge->loop pointer*/ - len = BME_cycle_length(&(e->loop->radial)); + /*deal with edge->l pointer*/ + len = BME_cycle_length(&(e->l->radial)); if(len == 1) newbase = NULL; - else if(e->loop == l) newbase = e->loop->radial.next->data; - else newbase = e->loop; + else if(e->l == l) newbase = e->l->radial_next; + else newbase = e->l; /*remove and rebase*/ - BME_cycle_remove(&(e->loop->radial), &(l->radial)); - e->loop = newbase; + BME_cycle_remove(&(e->l->radial), &(l->radial)); + e->l = newbase; } int BME_radial_find_face(BME_Edge *e,BME_Poly *f) @@ -608,8 +609,8 @@ int BME_radial_find_face(BME_Edge *e,BME_Poly *f) BME_Loop *curloop; int i, len; - len = BME_cycle_length(&(e->loop->radial)); - for(i = 0, curloop = e->loop; i < len; i++, curloop = curloop->radial.next->data){ + len = BME_cycle_length(&(e->l->radial)); + for(i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next){ if(curloop->f == f) return 1; } return 0; @@ -619,9 +620,11 @@ struct BME_Loop *BME_loop_find_loop(struct BME_Poly *f, struct BME_Vert *v) { BME_Loop *l; int i, len; - len = BME_cycle_length(f->loopbase); + len = BME_cycle_length(f->lbase); for (i = 0, l=f->loopbase; i < len; i++, l=l->next) { if (l->v == v) return l; } return NULL; } +#endif +#endif diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index fe82d2dab95..483e7ad150e 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -1,3 +1,4 @@ +#if 0 /** * BME_tools.c jan 2007 * @@ -117,20 +118,20 @@ static int BME_is_nonmanifold_vert(BME_Mesh *bm, BME_Vert *v) { BME_Loop *l; int len, count, flag; - if (v->edge == NULL) { + if (v->e == NULL) { /* loose vert */ return 1; } /* count edges while looking for non-manifold edges */ - oe = v->edge; - for (len=0,e=v->edge; e != oe || (e == oe && len == 0); len++,e=BME_disk_nextedge(e,v)) { - if (e->loop == NULL) { + oe = v->e; + for (len=0,e=v->e; e != oe || (e == oe && len == 0); len++,e=BME_disk_nextedge(e,v)) { + if (e->l == NULL) { /* loose edge */ return 1; } - if (BME_cycle_length(&(e->loop->radial)) > 2) { + if (BME_cycle_length(&(e->l->radial)) > 2) { /* edge shared by more than two faces */ return 1; } @@ -139,28 +140,28 @@ static int BME_is_nonmanifold_vert(BME_Mesh *bm, BME_Vert *v) { count = 1; flag = 1; e = NULL; - oe = v->edge; - l = oe->loop; + oe = v->e; + l = oe->l; while(e != oe) { if (l->v == v) l = l->prev; else l = l->next; e = l->e; count++; /* count the edges */ - if (flag && l->radial.next->data == l) { + if (flag && l->radial_next == l) { /* we've hit the edge of an open mesh, reset once */ flag = 0; count = 1; oe = e; e = NULL; - l = oe->loop; + l = oe->l; } - else if (l->radial.next->data == l) { + else if (l->radial_next == l) { /* break the loop */ e = oe; } else { - l = l->radial.next->data; + l = l->radial_next; } } @@ -177,8 +178,8 @@ static int BME_is_nonmanifold_vert(BME_Mesh *bm, BME_Vert *v) { static BME_Poly *BME_JFKE_safe(BME_Mesh *bm, BME_Poly *f1, BME_Poly *f2, BME_Edge *e) { BME_Loop *l1, *l2; - l1 = e->loop; - l2 = l1->radial.next->data; + l1 = e->l; + l2 = l1->radial_next; if (l1->v == l2->v) { BME_loop_reverse(bm, f2); } @@ -230,8 +231,8 @@ static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2 w[0] = 1.0f - fac; w[1] = fac; - if(!e1->loop) return; - l = e1->loop; + if(!e1->l) return; + l = e1->l; do{ if(l->v == v1){ v1loop = l; @@ -248,8 +249,8 @@ static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2 src[1] = v2loop->data; CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, vloop->data); - l = l->radial.next->data; - }while(l!=e1->loop); + l = l->radial_next; + }while(l!=e1->l); } @@ -286,8 +287,8 @@ static void BME_collapse_vert(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv, float fa w[0] = 1.0f - fac; w[1] = fac; - if(ke->loop){ - l = ke->loop; + if(ke->l){ + l = ke->l; do{ if(l->v == tv && l->next->v == kv){ tvloop = l; @@ -297,8 +298,8 @@ static void BME_collapse_vert(BME_Mesh *bm, BME_Edge *ke, BME_Vert *kv, float fa src[1] = tvloop->data; CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, kvloop->data); } - l=l->radial.next->data; - }while(l!=ke->loop); + l=l->radial_next; + }while(l!=ke->l); } BME_JEKV(bm,ke,kv); } @@ -404,12 +405,12 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B * so... here we walk around edges to find the needed verts */ forward = 1; is_split_vert = 0; - if (v->edge == NULL) { + if (v->e == NULL) { //printf("We can't split a loose vert's edge!\n"); return NULL; } - e1 = v->edge; /* we just use the first two edges */ - e2 = BME_disk_nextedge(v->edge, v); + e1 = v->e; /* we just use the first two edges */ + e2 = BME_disk_nextedge(v->e, v); if (e1 == e2) { //printf("You need at least two edges to use BME_bevel_split_edge()\n"); return NULL; @@ -590,8 +591,8 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran static BME_Vert *BME_bevel_wire(BME_Mesh *bm, BME_Vert *v, float value, int res, int options, BME_TransData_Head *td) { BME_Vert *ov1, *ov2, *v1, *v2; - ov1 = BME_edge_getothervert(v->edge, v); - ov2 = BME_edge_getothervert(BME_disk_nextedge(v->edge, v), v); + ov1 = BME_edge_getothervert(v->e, v); + ov2 = BME_edge_getothervert(BME_disk_nextedge(v->e, v), v); /* split the edges */ v1 = BME_bevel_split_edge(bm,v,ov1,NULL,NULL,value,td); @@ -606,7 +607,7 @@ static BME_Vert *BME_bevel_wire(BME_Mesh *bm, BME_Vert *v, float value, int res, /* remove the original vert */ if (res) { - BME_JEKV(bm,v->edge,v); + BME_JEKV(bm,v->e,v); } return v1; @@ -631,7 +632,7 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti /* first, check to see if this edge was inset previously */ if ((l->prev->e->tflag1 & BME_BEVEL_ORIG) == 0 && (l->v->tflag1 & BME_BEVEL_NONMAN) == 0) { - kl = l->prev->radial.next->data; + kl = l->prev->radial_next; if (kl->v == l->v) kl = kl->prev; else kl = kl->next; kv = l->v; @@ -651,14 +652,14 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti l = l->next; if (kl->v == kv) { BME_split_face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e); - BME_JFKE(bm,((BME_Loop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e); + BME_JFKE(bm,((BME_Loop*)kl->prev->radial_next)->f,kl->f,kl->prev->e); BME_collapse_vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } else { BME_split_face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e); - BME_JFKE(bm,((BME_Loop*)kl->next->radial.next->data)->f,kl->f,kl->next->e); + BME_JFKE(bm,((BME_Loop*)kl->next->radial_next)->f,kl->f,kl->next->e); BME_collapse_vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } @@ -669,7 +670,7 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti /* first, check to see if this edge was inset previously */ if ((l->next->e->tflag1 & BME_BEVEL_ORIG) == 0 && (l->next->v->tflag1 & BME_BEVEL_NONMAN) == 0) { - kl = l->next->radial.next->data; + kl = l->next->radial_next; if (kl->v == l->next->v) kl = kl->prev; else kl = kl->next; kv = l->next->v; @@ -688,13 +689,13 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti if (kv) { if (kl->v == kv) { BME_split_face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e); - BME_JFKE(bm,((BME_Loop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e); + BME_JFKE(bm,((BME_Loop*)kl->prev->radial_next)->f,kl->f,kl->prev->e); BME_collapse_vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } else { BME_split_face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e); - BME_JFKE(bm,((BME_Loop*)kl->next->radial.next->data)->f,kl->f,kl->next->e); + BME_JFKE(bm,((BME_Loop*)kl->next->radial_next)->f,kl->f,kl->next->e); BME_collapse_vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } @@ -703,7 +704,7 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti if ((v1->tflag1 & BME_BEVEL_NONMAN)==0 || (v2->tflag1 & BME_BEVEL_NONMAN)==0) { BME_split_face(bm,f,v2,v1,&l,e); l->e->tflag1 = BME_BEVEL_BEVEL; - l = l->radial.next->data; + l = l->radial_next; } if (l->f != f){ @@ -869,8 +870,8 @@ static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) { BME_Loop *l1, *l2; float vec1[3], vec2[3], vec3[3], vec4[3]; - l1 = e->loop; - l2 = e->loop->radial.next->data; + l1 = e->l; + l2 = e->l->radial_next; if (l1->v == v) { v1 = l1->prev->v; v2 = l1->next->v; @@ -909,7 +910,7 @@ static int BME_face_sharededges(BME_Poly *f1, BME_Poly *f2){ do{ if(BME_radial_find_face(l->e,f2)) count++; l = l->next; - }while(l != f1->loopbase); + }while(l != f1->lbase); return count; } @@ -954,11 +955,11 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int defgrp_inde */ /* get disk cycle length */ - if (v->edge == NULL) { + if (v->e == NULL) { len = 0; } else { - len = BME_cycle_length(BME_disk_getpointer(v->edge,v)); + len = BME_cycle_length(BME_disk_getpointer(v->e,v)); /* we'll assign a default transform data to every vert (except the loose ones) */ vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1, NULL); } @@ -1025,13 +1026,13 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int defgrp_inde * i.e. the vert's weight is the average of the weights of its weighted edges */ - if (e->loop == NULL) { + if (e->l == NULL) { len = 0; e->v1->tflag1 |= BME_BEVEL_NONMAN; e->v2->tflag1 |= BME_BEVEL_NONMAN; } else { - len = BME_cycle_length(&(e->loop->radial)); + len = BME_cycle_length(&(e->l->radial)); } if (len > 2) { @@ -1095,7 +1096,7 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int defgrp_inde for (e=bm->edges.first; e; e=e->next){ if(e->tflag1 & BME_BEVEL_BEVEL){ int count = 0; - count = BME_face_sharededges(e->loop->f, ((BME_Loop*)e->loop->radial.next->data)->f); + count = BME_face_sharededges(e->l->f, ((BME_Loop*)e->l->radial_next)->f); if(count > 1){ e->tflag1 &= ~BME_BEVEL_BEVEL; } @@ -1145,26 +1146,26 @@ static void bmesh_dissolve_disk(BME_Mesh *bm, BME_Vert *v){ BME_Edge *e; int done, len; - if(v->edge){ + if(v->e){ done = 0; while(!done){ done = 1; - e = v->edge; /*loop the edge looking for a edge to dissolve*/ + e = v->e; /*loop the edge looking for a edge to dissolve*/ do{ f = NULL; - len = BME_cycle_length(&(e->loop->radial)); + len = BME_cycle_length(&(e->l->radial)); if(len == 2){ - f = BME_JFKE_safe(bm,e->loop->f, ((BME_Loop*)(e->loop->radial.next->data))->f, e); + f = BME_JFKE_safe(bm,e->l->f, ((BME_Loop*)(e->l->radial_next))->f, e); } if(f){ done = 0; break; } e = BME_disk_nextedge(e,v); - }while(e != v->edge); + }while(e != v->e); } - BME_collapse_vert(bm, v->edge, v, 1.0); - //BME_JEKV(bm,v->edge,v); + BME_collapse_vert(bm, v->e, v, 1.0); + //BME_JEKV(bm,v->e,v); } } static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, int defgrp_index, BME_TransData_Head *td) { @@ -1190,7 +1191,7 @@ static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, else if (res && ((v->tflag1 & BME_BEVEL_BEVEL) && (v->tflag1 & BME_BEVEL_ORIG))) { int count = 0; /* first, make sure we're not sitting on an edge to be removed */ - oe = v->edge; + oe = v->e; e = BME_disk_nextedge(oe,v); while ((e->tflag1 & BME_BEVEL_BEVEL) && (e->tflag1 & BME_BEVEL_ORIG)) { e = BME_disk_nextedge(e,v); @@ -1204,7 +1205,7 @@ static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, while ( (e = BME_disk_next_edgeflag(oe, v, 0, BME_BEVEL_ORIG | BME_BEVEL_BEVEL)) ) { count++; /* join the faces (we'll split them later) */ - f = BME_JFKE_safe(bm,e->loop->f,((BME_Loop*)e->loop->radial.next->data)->f,e); + f = BME_JFKE_safe(bm,e->l->f,((BME_Loop*)e->l->radial_next)->f,e); if (!f){ //printf("Non-manifold geometry not getting tagged right?\n"); } @@ -1215,10 +1216,10 @@ static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, /* all original edges marked to be beveled have been removed; * now we need to link up the edges for this "corner" */ - len = BME_cycle_length(BME_disk_getpointer(v->edge, v)); - for (i=0,e=v->edge; i < len; i++,e=BME_disk_nextedge(e,v)) { - l = e->loop; - l2 = l->radial.next->data; + len = BME_cycle_length(BME_disk_getpointer(v->e, v)); + for (i=0,e=v->e; i < len; i++,e=BME_disk_nextedge(e,v)) { + l = e->l; + l2 = l->radial_next; if (l->v != v) l = l->next; if (l2->v != v) l2 = l2->next; /* look for faces that have had the original edges removed via JFKE */ @@ -1324,3 +1325,4 @@ BME_Mesh *BME_bevel(BME_Mesh *bm, float value, int res, int options, int defgrp_ BME_free_transdata(td); return bm; } +#endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index fce6b5ae9fc..3235ccbbaa5 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -429,8 +429,11 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me) CustomData_free(&me->ldata, me->totloop); CustomData_free(&me->pdata, me->totpoly); - /* if the number of verts has changed, remove invalid data */ + /* BMESH_TODO/XXX: ok, this should use new CD shapekey data, + which shouuld be fed through the modifier + stack*/ if(tmp.totvert != me->totvert) { + printf("YEEK! this should be recoded! Shape key loss!!!\n"); if(me->key) me->key->id.us--; me->key = NULL; } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 89fb01dc5c7..9ee4b66b194 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1771,7 +1771,6 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *me) mv->no[0] = eve->no[0] * 32767.0; mv->no[1] = eve->no[1] * 32767.0; mv->no[2] = eve->no[2] * 32767.0; - mv->bweight = (unsigned char) (eve->bweight * 255.0f); mv->mat_nr = 0; mv->flag = BMFlags_To_MEFlags(eve); @@ -1790,8 +1789,6 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *me) med->v1 = BMINDEX_GET(eed->v1); med->v2 = BMINDEX_GET(eed->v2); - med->crease = (unsigned char) (eed->crease * 255.0f); - med->bweight = (unsigned char) (eed->bweight * 255.0f); med->flag = ME_EDGEDRAW|ME_EDGERENDER; med->flag = BMFlags_To_MEFlags(eed); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 6f133f85b7f..1cf8be330e6 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -900,6 +900,25 @@ static void layerDefault_mcol(void *data, int count) mcol[i] = default_mcol; } +static void layerInterp_bweight(void **sources, float *weights, + float *sub_weights, int count, void *dest) +{ + float *f = dest, *src; + float **in = sources; + int i; + + if(count <= 0) return; + + *f = 0.0f; + + for(i = 0; i < count; ++i) { + float weight = weights ? weights[i] : 1.0f; + + src = in[i]; + *f += *src * weight; + } +} + static void layerInterp_shapekey(void **sources, float *weights, float *sub_weights, int count, void *dest) { @@ -969,6 +988,8 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerSwap_mcol, layerDefault_mcol}, {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, {sizeof(float)*3, "", 0, "ShapeKey", NULL, NULL, layerInterp_shapekey}, + {sizeof(float), "", 0, "BevelWeight", NULL, NULL, layerInterp_bweight}, + {sizeof(float), "", 0, "SubSurfCrease", NULL, NULL, layerInterp_bweight}, }; const char *LAYERTYPENAMES[CD_NUMTYPES] = { @@ -976,10 +997,10 @@ const char *LAYERTYPENAMES[CD_NUMTYPES] = { "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags","CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps", "CDWeightMCol", "CDMPoly", - "CDMLoop", "CDMLoopCol", "CDIDCol", "CDTextureCol", "CDShapeKeyIndex", "CDShapeKey"}; + "CDMLoop", "CDMLoopCol", "CDIDCol", "CDTextureCol", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight", "CDSubSurfCrease"}; const CustomDataMask CD_MASK_BAREMESH = - CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE | CD_MASK_MLOOP | CD_MASK_MPOLY; + CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE | CD_MASK_MLOOP | CD_MASK_MPOLY | CD_MASK_BWEIGHT; const CustomDataMask CD_MASK_MESH = CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE | CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL | @@ -2159,7 +2180,7 @@ void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData void CustomData_bmesh_init_pool(CustomData *data, int allocsize){ - if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, 1); + if(data->totlayer)data->pool = BLI_mempool_create(data->totsize, allocsize, allocsize, 1, 0); } void CustomData_bmesh_merge(CustomData *source, CustomData *dest, @@ -2227,7 +2248,9 @@ void CustomData_bmesh_free_block(CustomData *data, void **block) } } - BLI_mempool_free(data->pool, *block); + if (data->totsize) + BLI_mempool_free(data->pool, *block); + *block = NULL; } @@ -2238,7 +2261,7 @@ static void CustomData_bmesh_alloc_block(CustomData *data, void **block) CustomData_bmesh_free_block(data, block); if (data->totsize > 0) - *block = BLI_mempool_calloc(data->pool); + *block = BLI_mempool_alloc(data->pool); else *block = NULL; } @@ -2471,6 +2494,7 @@ void CustomData_bmesh_set_default(CustomData *data, void **block) if(typeInfo->set_default) typeInfo->set_default((char*)*block + offset, 1); + else memset((char*)*block + offset, 0, typeInfo->size); } } diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index d1a503b36dd..3063d42cbe5 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -185,7 +185,7 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); for (j=0; l; l=BMIter_Step(&liter), j++) { /*mark order*/ - l->head.eflag2 = j; + l->_index = j; v = BLI_addfillvert(l->v->co); v->tmp.p = l; @@ -214,13 +214,13 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm) looptris[i*3+1] = l2 = efa->v2->tmp.p; looptris[i*3+2] = l3 = efa->v3->tmp.p; - if (l1->head.eflag2 > l2->head.eflag2) { + if (l1->_index > l2->_index) { SWAP(BMLoop*, l1, l2); } - if (l2->head.eflag2 > l3->head.eflag2) { + if (l2->_index > l3->_index) { SWAP(BMLoop*, l2, l3); } - if (l1->head.eflag2 > l2->head.eflag2) { + if (l1->_index > l2->_index) { SWAP(BMLoop*, l1, l2); } @@ -1110,7 +1110,7 @@ static void bmDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) BMIter iter; int i; - if (bmdm->tc->bm->verts.first) { + if (bmdm->tc->bm->totvert) { eve = BMIter_New(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); for (i=0; eve; eve=BMIter_Step(&iter), i++) { if (bmdm->vertexCos) { @@ -1151,7 +1151,7 @@ static int bmDM_getNumFaces(DerivedMesh *dm) return bmdm->tc->bm->totface; } -static int bmvert_to_mvert(BMVert *ev, MVert *vert_r) +static int bmvert_to_mvert(BMesh *bm, BMVert *ev, MVert *vert_r) { VECCOPY(vert_r->co, ev->co); @@ -1162,7 +1162,10 @@ static int bmvert_to_mvert(BMVert *ev, MVert *vert_r) /* TODO what to do with vert_r->flag and vert_r->mat_nr? */ vert_r->flag = BMFlags_To_MEFlags(ev); vert_r->mat_nr = 0; - vert_r->bweight = (unsigned char) (ev->bweight*255.0f); + + if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) { + vert_r->bweight = (unsigned char) (BM_GetCDf(&bm->vdata, ev, CD_BWEIGHT)*255.0f); + } } static void bmDM_getVert(DerivedMesh *dm, int index, MVert *vert_r) @@ -1177,7 +1180,7 @@ static void bmDM_getVert(DerivedMesh *dm, int index, MVert *vert_r) } ev = ((EditDerivedBMesh *)dm)->vtable[index]; - bmvert_to_mvert(ev, vert_r); + bmvert_to_mvert(((EditDerivedBMesh *)dm)->tc->bm, ev, vert_r); } static void bmDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r) @@ -1196,9 +1199,14 @@ static void bmDM_getEdge(DerivedMesh *dm, int index, MEdge *edge_r) e = bmdm->etable[index]; - edge_r->crease = (unsigned char) (e->crease*255.0f); - edge_r->bweight = (unsigned char) (e->bweight*255.0f); - /* TODO what to do with edge_r->flag? */ + if (CustomData_has_layer(&bm->edata, CD_BWEIGHT)) { + edge_r->bweight = (unsigned char) (BM_GetCDf(&bm->edata, e, CD_BWEIGHT)*255.0f); + } + + if (CustomData_has_layer(&bm->edata, CD_CREASE)) { + edge_r->crease = (unsigned char) (BM_GetCDf(&bm->edata, e, CD_CREASE)*255.0f); + } + edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER; edge_r->flag |= BMFlags_To_MEFlags(e); #if 0 @@ -1256,7 +1264,10 @@ static void bmDM_copyVertArray(DerivedMesh *dm, MVert *vert_r) /* TODO what to do with vert_r->flag and vert_r->mat_nr? */ vert_r->mat_nr = 0; vert_r->flag = BMFlags_To_MEFlags(ev); - vert_r->bweight = (unsigned char) (ev->bweight*255.0f); + + if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) { + vert_r->bweight = (unsigned char) (BM_GetCDf(&bm->vdata, ev, CD_BWEIGHT)*255.0f); + } } } @@ -1275,9 +1286,14 @@ static void bmDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r) ee = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); for( ; ee; ee=BMIter_Step(&iter)) { - edge_r->crease = (unsigned char) (ee->crease*255.0f); - edge_r->bweight = (unsigned char) (ee->bweight*255.0f); - /* TODO what to do with edge_r->flag? */ + if (CustomData_has_layer(&bm->edata, CD_BWEIGHT)) { + edge_r->bweight = (unsigned char) (BM_GetCDf(&bm->edata, ee, CD_BWEIGHT)*255.0f); + } + + if (CustomData_has_layer(&bm->edata, CD_CREASE)) { + edge_r->crease = (unsigned char) (BM_GetCDf(&bm->edata, ee, CD_CREASE)*255.0f); + } + edge_r->flag = ME_EDGEDRAW|ME_EDGERENDER; if (ee->head.flag & BM_SEAM) edge_r->flag |= ME_SEAM; if (ee->head.flag & BM_SHARP) edge_r->flag |= ME_SHARP; @@ -1424,7 +1440,7 @@ void bmDM_loopIterStep(void *self) return; } - bmvert_to_mvert(iter->l->v, &iter->head.v); + bmvert_to_mvert(iter->bm, iter->l->v, &iter->head.v); iter->head.index++; iter->head.vindex = BMINDEX_GET(iter->l->v); iter->head.eindex = BMINDEX_GET(iter->l->e); @@ -1472,7 +1488,7 @@ DMLoopIter *bmDM_newLoopsIter(void *faceiter) iter->head.getLoopCDData = bmDM_getLoopCDData; iter->head.getVertCDData = bmDM_getVertCDData; - bmvert_to_mvert(iter->l->v, &iter->head.v); + bmvert_to_mvert(iter->bm, iter->l->v, &iter->head.v); iter->head.vindex = BMINDEX_GET(iter->l->v); iter->head.eindex = BMINDEX_GET(iter->l->e); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index d5696dd03d4..20e8542fb56 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -150,13 +150,13 @@ static int is_last_displist(Object *ob) } /* returns a derived mesh if dm == NULL, for deforming modifiers that need it */ -static DerivedMesh *get_dm(Scene *scene, Object *ob, EditMesh *em, DerivedMesh *dm, float (*vertexCos)[3], int orco) +static DerivedMesh *get_dm(Scene *scene, Object *ob, BMEditMesh *em, DerivedMesh *dm, float (*vertexCos)[3], int orco) { if(dm) return dm; if(ob->type==OB_MESH) { - if(em) dm= CDDM_from_editmesh(em, ob->data); + if(em) dm= CDDM_from_BMEditMesh(em, ob->data); else dm = CDDM_from_mesh((Mesh*)(ob->data), ob); if(vertexCos) { @@ -194,7 +194,7 @@ static DerivedMesh *get_dm(Scene *scene, Object *ob, EditMesh *em, DerivedMesh * } /* returns a cdderivedmesh if dm == NULL or is another type of derivedmesh */ -static DerivedMesh *get_cddm(Scene *scene, Object *ob, EditMesh *em, DerivedMesh *dm, float (*vertexCos)[3]) +static DerivedMesh *get_cddm(Scene *scene, Object *ob, BMEditMesh *em, DerivedMesh *dm, float (*vertexCos)[3]) { if(dm && dm->type == DM_TYPE_CDDM) return dm; @@ -2128,7 +2128,7 @@ BM_INLINE VertUser *new_vuser(MemBase *base) BM_INLINE MemBase *new_membase(void) { MemBase *b = MEM_callocN(sizeof(MemBase), "MemBase for edgesplit in modifier.c"); - b->vertuserpool = BLI_mempool_create(sizeof(VertUser), 1, 2048, 1); + b->vertuserpool = BLI_mempool_create(sizeof(VertUser), 1, 2048, 1, 0); return b; } @@ -2481,7 +2481,7 @@ static DerivedMesh *bevelModifier_applyModifier( int useRenderParams, int isFinalCalc) { DerivedMesh *result; - BME_Mesh *bm; + //BME_Mesh *bm; /*bDeformGroup *def;*/ int /*i,*/ options, defgrp_index = -1; @@ -2495,14 +2495,15 @@ static DerivedMesh *bevelModifier_applyModifier( options &= ~BME_BEVEL_VWEIGHT; } }*/ - +/* bm = BME_derivedmesh_to_bmesh(derivedData); BME_bevel(bm,bmd->value,bmd->res,options,defgrp_index,bmd->bevel_angle,NULL); result = BME_bmesh_to_derivedmesh(bm,derivedData); BME_free_mesh(bm); CDDM_calc_normals(result); - +*/ + result = derivedData; return result; } diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 4fde1d45dcb..250a272015e 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -152,7 +152,6 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing) for (i=0; ico, NULL); - v->bweight = mv->bweight; VECCOPY(v->no, mv->no); v->head.flag = MEFlags_To_BMFlags(mv->flag, BM_VERT); @@ -166,8 +165,6 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing) for (i=0; iv1], vtable[me->v2], NULL, 0); - e->bweight = me->bweight; - e->crease = me->crease; e->head.flag = MEFlags_To_BMFlags(me->flag, BM_EDGE); CustomData_to_bmesh_block(&dm->edgeData, &bm->edata, i, &e->head.data); diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index c01d821cb8b..7c1dfb1d3a4 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -57,35 +57,43 @@ the array size is doubled). supposedly this should give good Big Oh behaviour, though it may not be the best in practice. */ -#define BLI_array_declare(arr) int _##arr##_count=0; void *_##arr##_tmp +#define BLI_array_declare(arr) int _##arr##_count=0; void *_##arr##_tmp; void *_##arr##_static = NULL + +/*this will use stack space, up to maxstatic array elements, befoe + switching to dynamic heap allocation*/ +#define BLI_array_staticdeclare(arr, maxstatic) int _##arr##_count=0; void *_##arr##_tmp; char _##arr##_static[maxstatic*sizeof(arr)] /*this returns the entire size of the array, including any buffering.*/ -#define BLI_array_totalsize(arr) ((signed int)((arr)==NULL ? 0 : MEM_allocN_len(arr) / sizeof(*arr))) +#define BLI_array_totalsize_dyn(arr) ((arr)==NULL ? 0 : MEM_allocN_len(arr) / sizeof(*arr)) +#define BLI_array_totalsize(arr) ((signed int)((arr == _##arr##_static && arr != NULL) ? (sizeof(_##arr##_static) / sizeof(*arr)) : BLI_array_totalsize_dyn(arr))) /*this returns the logical size of the array, not including buffering.*/ #define BLI_array_count(arr) _##arr##_count /*grow the array by one. zeroes the new elements.*/ -#define BLI_array_growone(arr) \ - BLI_array_totalsize(arr) > _##arr##_count ? _##arr##_count++ : \ +#define _BLI_array_growone(arr) \ + BLI_array_totalsize(arr) > _##arr##_count ? ++_##arr##_count : \ ((_##arr##_tmp = MEM_callocN(sizeof(*arr)*(_##arr##_count*2+2), #arr " " __FILE__ " ")),\ (arr && memcpy(_##arr##_tmp, arr, sizeof(*arr) * _##arr##_count)),\ - (arr && (MEM_freeN(arr),1)),\ + (arr && (arr != (void*)_##arr##_static ? (MEM_freeN(arr), arr) : arr)),\ (arr = _##arr##_tmp),\ _##arr##_count++) -/*appends an item to the array and returns a pointer to the item in the array. +/*returns length of array*/ +#define BLI_array_growone(arr) (arr==NULL && _##arr##_static != NULL ? ((arr=(void*)_##arr##_static), ++_##arr##_count) : _BLI_array_growone(arr)) + + /*appends an item to the array and returns a pointer to the item in the array. item is not a pointer, but actual data value.*/ -#define BLI_array_append(arr, item) (BLI_array_growone(arr), arr[_##arr##_count] = item, (arr+_##arr##_count)) +#define BLI_array_append(arr, item) (BLI_array_growone(arr), (arr[_##arr##_count-1] = item), (arr+(_##arr##_count-1))) /*grow an array by a specified number of items.*/ #define BLI_array_growitems(arr, num) {int _i; for (_i=0; _i<(num); _i++) {BLI_array_growone(arr);}} -#define BLI_array_free(arr) if (arr) MEM_freeN(arr) +#define BLI_array_free(arr) if (arr && arr != _##arr##_static) MEM_freeN(arr) /*resets the logical size of an array to zero, but doesn't free the memory.*/ #define BLI_array_empty(arr) _##arr##_count=0 /*set the count of the array, doesn't actually increase the allocated array - size. don't use this unless you know what your doing.*/ + size. don't use this unless you know what you're doing.*/ #define BLI_array_set_length(arr, count) _##arr##_count = (count) diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 2d37438a944..56f1f40be33 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -36,6 +36,10 @@ #include "stdlib.h" #include "string.h" +#ifdef __cplusplus +extern "C" { +#endif + #include "BKE_utildefines.h" #include "MEM_guardedalloc.h" @@ -145,32 +149,6 @@ int BLI_ghashutil_intcmp(void *a, void *b); /*begin of macro-inlined functions*/ extern unsigned int hashsizes[]; -#if 0 -#define BLI_ghash_insert(gh, _k, _v){\ - unsigned int _hash= (gh)->hashfp(_k)%gh->nbuckets;\ - Entry *_e= BLI_mempool_alloc((gh)->entrypool);\ - _e->key= _k;\ - _e->val= _v;\ - _e->next= (gh)->buckets[_hash];\ - (gh)->buckets[_hash]= _e;\ - if (++(gh)->nentries>(gh)->nbuckets*3) {\ - Entry *_e, **_old= (gh)->buckets;\ - int _i, _nold= (gh)->nbuckets;\ - (gh)->nbuckets= hashsizes[++(gh)->cursize];\ - (gh)->buckets= malloc((gh)->nbuckets*sizeof(*(gh)->buckets));\ - memset((gh)->buckets, 0, (gh)->nbuckets*sizeof(*(gh)->buckets));\ - for (_i=0; _i<_nold; _i++) {\ - for (_e= _old[_i]; _e;) {\ - Entry *_n= _e->next;\ - _hash= (gh)->hashfp(_e->key)%(gh)->nbuckets;\ - _e->next= (gh)->buckets[_hash];\ - (gh)->buckets[_hash]= _e;\ - _e= _n;\ - }\ - }\ - free(_old); } } -#endif - /*---------inlined functions---------*/ BM_INLINE void BLI_ghash_insert(GHash *gh, void *key, void *val) { unsigned int hash= gh->hashfp(key)%gh->nbuckets; @@ -262,5 +240,4 @@ BM_INLINE int BLI_ghash_haskey(GHash *gh, void *key) { #ifdef __cplusplus } #endif - #endif diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index fc2d257707a..ee7deb19544 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -34,6 +34,8 @@ extern "C" { #ifdef BLI_MATH_INLINE #include "intern/math_vector_inline.c" +#else +#define MINLINE #endif /************************************* Init ***********************************/ diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h index a9f5d9c6200..c7be8f50cf3 100644 --- a/source/blender/blenlib/BLI_mempool.h +++ b/source/blender/blenlib/BLI_mempool.h @@ -36,14 +36,38 @@ extern "C" { #endif +#ifndef BLI_MEMPOOL_INTERN struct BLI_mempool; +struct BLI_mempool_chunk; typedef struct BLI_mempool BLI_mempool; +#endif -BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc); +/*allow_iter allows iteration on this mempool. note: this requires that the + first four bytes of the elements never contain the character string + 'free'. use with care.*/ + +BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, + int use_sysmalloc, int allow_iter); void *BLI_mempool_alloc(BLI_mempool *pool); void *BLI_mempool_calloc(BLI_mempool *pool); void BLI_mempool_free(BLI_mempool *pool, void *addr); void BLI_mempool_destroy(BLI_mempool *pool); +int BLI_mempool_count(BLI_mempool *pool); + +/** iteration stuff. note: this may easy to produce bugs with **/ +/*private structure*/ +typedef struct BLI_mempool_iter { + BLI_mempool *pool; + struct BLI_mempool_chunk *curchunk; + int curindex; +} BLI_mempool_iter; + +/*allow iteration on this mempool. note: this requires that the + first four bytes of the elements never contain the character string + 'free'. use with care.*/ +void BLI_mempool_allow_iter(BLI_mempool *pool); +void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter); +void *BLI_mempool_iterstep(BLI_mempool_iter *iter); #ifdef __cplusplus } diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index fec5f1803eb..75e36895abe 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -28,7 +28,7 @@ FILE(GLOB SRC intern/*.c) SET(INC . ../makesdna ../blenkernel ../../../intern/guardedalloc ../include - ../gpu ../../../intern/ghost + ../gpu ../../../intern/ghost ../bmesh ${FREETYPE_INCLUDE_DIRS} ${ZLIB_INC} ) @@ -44,6 +44,10 @@ IF(WIN32) SET(INC ${INC} ${PTHREADS_INC}) ENDIF(WIN32) +IF(WITH_OPENMP) + ADD_DEFINITIONS(-DPARALLEL=1) +ENDIF(WITH_OPENMP) + BLENDERLIB(bf_blenlib "${SRC}" "${INC}") #if env['OURPLATFORM'] == 'linux2': # cflags='-pthread' diff --git a/source/blender/blenlib/intern/BLI_cellalloc.c b/source/blender/blenlib/intern/BLI_cellalloc.c index 1244fa32d48..715c66fae7b 100644 --- a/source/blender/blenlib/intern/BLI_cellalloc.c +++ b/source/blender/blenlib/intern/BLI_cellalloc.c @@ -94,7 +94,7 @@ void *BLI_cellalloc_malloc(long size, char *tag) } if (!pools[slot]) { - pools[slot] = BLI_mempool_create(slot, 1, 128, 1); + pools[slot] = BLI_mempool_create(slot, 1, 128, 1, 0); } memh = BLI_mempool_alloc(pools[slot]); diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index d5617cecc27..6ef8d9e5f19 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -60,7 +60,7 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp) { GHash *gh= MEM_mallocN(sizeof(*gh), "GHash"); gh->hashfp= hashfp; gh->cmpfp= cmpfp; - gh->entrypool = BLI_mempool_create(sizeof(Entry), 64, 64, 1); + gh->entrypool = BLI_mempool_create(sizeof(Entry), 64, 64, 1, 0); gh->cursize= 0; gh->nentries= 0; diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 1ad685b34f2..7eec62c7494 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -38,11 +38,15 @@ #include "BLI_linklist.h" #include "DNA_listBase.h" +#include "DNA_ID.h" #include +#define FREEWORD MAKE_ID('f', 'r', 'e', 'e') + typedef struct BLI_freenode{ struct BLI_freenode *next; + intptr_t freeword; /*used to identify this as a freed node*/ }BLI_freenode; typedef struct BLI_mempool_chunk{ @@ -55,29 +59,34 @@ typedef struct BLI_mempool{ int esize, csize, pchunk; /*size of elements and chunks in bytes and number of elements per chunk*/ struct BLI_freenode *free; /*free element list. Interleaved into chunk datas.*/ int totalloc, totused; /*total number of elements allocated in total, and currently in use*/ - int use_sysmalloc; + int use_sysmalloc, allow_iter; }BLI_mempool; -BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc) +#define BLI_MEMPOOL_INTERN +#include "BLI_mempool.h" + +BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, + int use_sysmalloc, int allow_iter) { BLI_mempool *pool = NULL; BLI_freenode *lasttail = NULL, *curnode = NULL; int i,j, maxchunks; char *addr; - if (esize < sizeof(void*)) - esize = sizeof(void*); + if (esize < sizeof(void*)*2) + esize = sizeof(void*)*2; - if (esize < sizeof(void*)) - esize = sizeof(void*); + if (esize < sizeof(void*)*2) + esize = sizeof(void*)*2; /*allocate the pool structure*/ pool = use_sysmalloc ? malloc(sizeof(BLI_mempool)) : MEM_mallocN(sizeof(BLI_mempool), "memory pool"); - pool->esize = esize; + pool->esize = allow_iter ? MAX2(esize, sizeof(BLI_freenode)) : esize; pool->use_sysmalloc = use_sysmalloc; pool->pchunk = pchunk; pool->csize = esize * pchunk; pool->chunks.first = pool->chunks.last = NULL; pool->totused= 0; + pool->allow_iter= allow_iter; maxchunks = tote / pchunk + 1; if (maxchunks==0) maxchunks = 1; @@ -89,15 +98,30 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmall mpchunk->data = use_sysmalloc ? malloc(pool->csize) : MEM_mallocN(pool->csize, "BLI Mempool Chunk Data"); BLI_addtail(&(pool->chunks), mpchunk); - if(i==0) pool->free = mpchunk->data; /*start of the list*/ + if(i==0) { + pool->free = mpchunk->data; /*start of the list*/ + if (pool->allow_iter) + pool->free->freeword = FREEWORD; + } + /*loop through the allocated data, building the pointer structures*/ for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){ curnode = ((BLI_freenode*)addr); addr += pool->esize; curnode->next = (BLI_freenode*)addr; + if (pool->allow_iter) { + if (j != pool->pchunk-1) + curnode->next->freeword = FREEWORD; + curnode->freeword = FREEWORD; + } } /*final pointer in the previously allocated chunk is wrong.*/ - if(lasttail) lasttail->next = mpchunk->data; + if(lasttail) { + lasttail->next = mpchunk->data; + if (pool->allow_iter) + lasttail->freeword = FREEWORD; + } + /*set the end of this chunks memoryy to the new tail for next iteration*/ lasttail = curnode; @@ -108,12 +132,15 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmall curnode->next = NULL; return pool; } + void *BLI_mempool_alloc(BLI_mempool *pool){ void *retval=NULL; BLI_freenode *curnode=NULL; char *addr=NULL; int j; - + + if (!pool) return NULL; + pool->totused++; if(!(pool->free)){ @@ -124,10 +151,18 @@ void *BLI_mempool_alloc(BLI_mempool *pool){ BLI_addtail(&(pool->chunks), mpchunk); pool->free = mpchunk->data; /*start of the list*/ + if (pool->allow_iter) + pool->free->freeword = FREEWORD; for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){ curnode = ((BLI_freenode*)addr); addr += pool->esize; curnode->next = (BLI_freenode*)addr; + + if (pool->allow_iter) { + curnode->freeword = FREEWORD; + if (j != pool->pchunk-1) + curnode->next->freeword = FREEWORD; + } } curnode->next = NULL; /*terminate the list*/ @@ -135,6 +170,9 @@ void *BLI_mempool_alloc(BLI_mempool *pool){ } retval = pool->free; + if (pool->allow_iter) + pool->free->freeword = 0x7FFFFFFF; + pool->free = pool->free->next; //memset(retval, 0, pool->esize); return retval; @@ -153,7 +191,9 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against d BLI_freenode *curnode=NULL; char *tmpaddr=NULL; int i; - + + if (pool->allow_iter) + newhead->freeword = FREEWORD; newhead->next = pool->free; pool->free = newhead; @@ -184,6 +224,50 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against d } } +void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) +{ + if (!pool->allow_iter) { + fprintf(stderr, "evil! you can't iterate over this mempool!\n"); + iter->curchunk = NULL; + iter->curindex = 0; + + return; + } + + iter->pool = pool; + iter->curchunk = pool->chunks.first; + iter->curindex = 0; +} + +static void *bli_mempool_iternext(BLI_mempool_iter *iter) +{ + void *ret = NULL; + + if (!iter->curchunk) return NULL; + + ret = ((char*)iter->curchunk->data) + iter->pool->esize*iter->curindex; + + iter->curindex++; + + if (iter->curindex >= iter->pool->pchunk) { + iter->curchunk = iter->curchunk->next; + iter->curindex = 0; + } + + return ret; +} + +void *BLI_mempool_iterstep(BLI_mempool_iter *iter) +{ + BLI_freenode *ret; + + do { + ret = bli_mempool_iternext(iter); + } while (ret && ret->freeword == FREEWORD); + + return ret; +} + void BLI_mempool_destroy(BLI_mempool *pool) { BLI_mempool_chunk *mpchunk=NULL; diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 9b38289f15b..69c9cc7e522 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -25,17 +25,11 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include -#include -#include - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" #include "BLI_dlrbTree.h" -#include "DNA_listBase.h" - /* *********************************************** */ /* Tree API */ diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index a32666757a3..1f70a34329f 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -44,7 +44,7 @@ EdgeHash *BLI_edgehash_new(void) { eh->nbuckets= _ehash_hashsizes[eh->cursize]; eh->buckets= MEM_callocN(eh->nbuckets*sizeof(*eh->buckets), "eh buckets 2"); - eh->epool = BLI_mempool_create(sizeof(EdgeEntry), 512, 512, 1); + eh->epool = BLI_mempool_create(sizeof(EdgeEntry), 512, 512, 1, 0); return eh; } diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index cae0fccd12a..29b81a6f11b 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -29,7 +29,7 @@ FILE(GLOB SRC intern/*.c) SET(INC . ../../../intern/guardedalloc ../blenlib ../blenkernel ../makesdna ../readblenfile ../include ../makesrna - ../python ../../kernel/gen_messaging + ../python ../../kernel/gen_messaging ../bmesh ../render/extern/include ${ZLIB_INC} ) diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index 0bdeaa97e4a..53d724d6e8d 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -13,7 +13,7 @@ * of the License, or (at your option) any later version. The Blender * Foundation also sells licenses for use in proprietary software under * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * about this. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -37,26 +37,28 @@ #ifndef BMESH_H #define BMESH_H +#ifdef __cplusplus +extern "C" { +#endif + #include "DNA_listBase.h" #include "DNA_scene_types.h" #include "DNA_customdata_types.h" #include "BKE_customdata.h" -#include "BLI_mempool.h" - /* short introduction: -the bmesh structure is a boundary representation, supporting non-manifold +the bmesh structure is a boundary representation, supporting non-manifold locally modifiable topology. the API is designed to allow clean, maintainable code, that never (or almost never) directly inspects the underlying structure. The API includes iterators, including many useful topological iterators; walkers, which walk over a mesh, without the risk of hitting the recursion limit; operators, which are logical, reusable mesh modules; topological -modification functions (like split face, join faces, etc), which are used for -topological manipulations; and some (not yet finished) geometric utility +modification functions (like split face, join faces, etc), which are used for +topological manipulations; and some (not yet finished) geometric utility functions. some definitions: @@ -81,7 +83,7 @@ struct EditMesh; /* * BMHeader * - * All mesh elements begin with a BMHeader. This structure + * All mesh elements begin with a BMHeader. This structure * hold several types of data * * 1: The type of the element (vert, edge, loop or face) @@ -111,136 +113,35 @@ struct EditMesh; #define BM_NONORMCALC (1<<7) #define BM_PINNED (1<<8) -typedef struct BMHeader { - struct BMHeader *next, *prev; - int EID; /*Consider removing this/making it ifdeffed for debugging*/ - - /*don't confuse this with tool flags. this flag - member is what "header flag" means.*/ - int flag; - int type; /*the element type, can be BM_VERT, BM_EDGE, BM_LOOP, or BM_FACE*/ - int eflag1, eflag2; /*Flags used by eulers. Try and get rid of/minimize some of these*/ - - /*this is only used to store temporary integers. - don't use it for anything else. - use the BMINDEX_GET and BMINDEX_SET macros to access it*/ - int index; - struct BMFlagLayer *flags; /*Dynamically allocated block of flag layers for operators to use*/ - void *data; /*customdata block*/ -} BMHeader; - -typedef struct BMFlagLayer { - int f1; - short mask, pflag; -} BMFlagLayer; - -#define BM_OVERLAP (1<<14) /*used by bmesh_verts_in_face*/ -#define BM_EDGEVERT (1<<15) /*used by bmesh_make_ngon*/ - -/* - * BMNode - * - * Used for circular/linked list functions that form basis of - * adjacency system in BMesh. This should probably be hidden - * somewhere since tool authors never need to know about it. - * -*/ - -typedef struct BMNode { - struct BMNode *next, *prev; - void *data; -} BMNode; - -typedef struct BMesh { - ListBase verts, edges, polys; - struct BLI_mempool *vpool; - struct BLI_mempool *epool; - struct BLI_mempool *lpool; - struct BLI_mempool *ppool; - struct BMVert **vtar; - struct BMEdge **edar; - struct BMLoop **lpar; - struct BMFace **plar; - int vtarlen, edarlen, lparlen, plarlen; - int totvert, totedge, totface, totloop; - int totvertsel, totedgesel, totfacesel; - int nextv, nexte, nextp, nextl; - struct CustomData vdata, edata, pdata, ldata; - int selectmode; /*now uses defines in DNA_scene_types.h*/ - struct BLI_mempool *flagpool; /*memory pool for dynamically allocated flag layers*/ - int stackdepth; /*current depth of operator stack*/ - int totflags, walkers; /*total number of tool flag layers*/ - ListBase errorstack; - - /*selection order list*/ - ListBase selected; - - /*active face pointer*/ - struct BMFace *act_face; - - /*active shape key number, should really be in BMEditMesh, not here*/ - int shapenr; -} BMesh; - -typedef struct BMVert { - struct BMHeader head; - float co[3]; - float no[3]; - struct BMEdge *edge; - float bweight; /*please, someone just get rid of me...*/ -} BMVert; - -typedef struct BMEdge { - struct BMHeader head; - struct BMVert *v1, *v2; - struct BMNode d1, d2; - struct BMLoop *loop; - float crease, bweight; /*make these custom data.... no really, please....*/ -} BMEdge; - -typedef struct BMLoop { - struct BMHeader head; - struct BMNode radial; - struct BMVert *v; - struct BMEdge *e; - struct BMFace *f; -} BMLoop; - -typedef struct BMFace { - struct BMHeader head; - struct BMLoop *loopbase; - int len; - float no[3]; - - /*custom data again*/ - short mat_nr; -} BMFace; +#include "bmesh_class.h" /*stub */ -void bmesh_error(void); +void bmesh_error ( void ); /*Mesh Level Ops */ -struct BMesh *BM_Make_Mesh(int allocsize[4]); -BMesh *BM_Copy_Mesh(BMesh *bmold); -void BM_Free_Mesh(struct BMesh *bm); +struct BMesh *BM_Make_Mesh ( int allocsize[4] ); +BMesh *BM_Copy_Mesh ( BMesh *bmold ); +void BM_Free_Mesh ( struct BMesh *bm ); /*frees mesh, but not actual BMesh struct*/ -void BM_Free_Mesh_Data(BMesh *bm); -void BM_Compute_Normals(struct BMesh *bm); +void BM_Free_Mesh_Data ( BMesh *bm ); +void BM_Compute_Normals ( struct BMesh *bm ); /*Construction*/ -struct BMVert *BM_Make_Vert(struct BMesh *bm, float co[3], struct BMVert *example); -struct BMEdge *BM_Make_Edge(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge *example, int nodouble); -struct BMFace *BM_Make_Quadtriangle(struct BMesh *bm, struct BMVert **verts, BMEdge **edges, int len, struct BMFace *example, int nodouble); +struct BMVert *BM_Make_Vert ( struct BMesh *bm, float co[3], struct BMVert *example ); +struct BMEdge *BM_Make_Edge ( struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge *example, int nodouble ); +struct BMFace *BM_Make_Quadtriangle ( struct BMesh *bm, struct BMVert **verts, BMEdge **edges, int len, struct BMFace *example, int nodouble ); + +BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, int len); /*more easier to use version of BM_Make_Quadtriangle. creates edges if necassary.*/ -BMFace *BM_Make_QuadTri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, - BMVert *v4, BMFace *example, int nodouble); +BMFace *BM_Make_QuadTri ( BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, + BMVert *v4, BMFace *example, int nodouble ); /*makes an ngon from an unordered list of edges. v1 and v2 must be the verts defining edges[0], and define the winding of the new face.*/ -struct BMFace *BM_Make_Ngon(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge **edges, int len, int nodouble); +struct BMFace *BM_Make_Ngon ( struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge **edges, int len, int nodouble ); /*stuff for dealing with header flags*/ #define BM_TestHFlag(ele, f) (((BMHeader*)ele)->flag & (f)) @@ -248,110 +149,122 @@ struct BMFace *BM_Make_Ngon(struct BMesh *bm, struct BMVert *v1, struct BMVert * #define BM_ClearHFlag(ele, f) (((BMHeader*)ele)->flag = ((BMHeader*)ele)->flag & ~(f)) /*stuff for setting indices in elements.*/ -#define BMINDEX_SET(ele, i) (((BMHeader*)(ele))->index = i) -#define BMINDEX_GET(ele) (((BMHeader*)(ele))->index) +#define BMINDEX_SET(ele, i) (((BMHeader*)ele)->index = i) +#define BMINDEX_GET(ele) (((BMHeader*)ele)->index) /*copies loop data from adjacent faces*/ -void BM_Face_CopyShared(BMesh *bm, BMFace *f); +void BM_Face_CopyShared ( BMesh *bm, BMFace *f ); /*copies attributes, e.g. customdata, header flags, etc, from one element to another of the same type.*/ -void BM_Copy_Attributes(struct BMesh *source_mesh, struct BMesh *target_mesh, void *source, void *target); +void BM_Copy_Attributes ( struct BMesh *source_mesh, struct BMesh *target_mesh, void *source, void *target ); /*Modification*/ /*join two adjacent faces together along an edge. note that the faces must only be joined by on edge. e is the edge you wish to dissolve.*/ -struct BMFace *BM_Join_Faces(struct BMesh *bm, struct BMFace *f1, - struct BMFace *f2, struct BMEdge *e); +BMFace *BM_Join_TwoFaces(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e); + +/*generic, flexible join faces function; note that most everything uses + this, including BM_Join_TwoFaces*/ +BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface); /*split a face along two vertices. returns the newly made face, and sets the nl member to a loop in the newly created edge.*/ -struct BMFace *BM_Split_Face(struct BMesh *bm, struct BMFace *f, - struct BMVert *v1, struct BMVert *v2, - struct BMLoop **nl, struct BMEdge *example); +struct BMFace *BM_Split_Face ( struct BMesh *bm, struct BMFace *f, + struct BMVert *v1, struct BMVert *v2, + struct BMLoop **nl, struct BMEdge *example ); /*dissolves a vert shared only by two edges*/ -void BM_Collapse_Vert(struct BMesh *bm, struct BMEdge *ke, struct BMVert *kv, - float fac); +void BM_Collapse_Vert ( struct BMesh *bm, struct BMEdge *ke, struct BMVert *kv, + float fac ); /*splits an edge. ne is set to the new edge created.*/ -struct BMVert *BM_Split_Edge(struct BMesh *bm, struct BMVert *v, - struct BMEdge *e, struct BMEdge **ne, - float percent); +struct BMVert *BM_Split_Edge ( struct BMesh *bm, struct BMVert *v, + struct BMEdge *e, struct BMEdge **ne, + float percent ); /*split an edge multiple times evenly*/ -struct BMVert *BM_Split_Edge_Multi(struct BMesh *bm, struct BMEdge *e, - int numcuts); +struct BMVert *BM_Split_Edge_Multi ( struct BMesh *bm, struct BMEdge *e, + int numcuts ); /*connect two verts together, through a face they share. this function may be removed in the future.*/ -BMEdge *BM_Connect_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **nf); +BMEdge *BM_Connect_Verts ( BMesh *bm, BMVert *v1, BMVert *v2, BMFace **nf ); /*rotates an edge topologically, either clockwise (if ccw=0) or counterclockwise (if ccw is 1).*/ -BMEdge *BM_Rotate_Edge(BMesh *bm, BMEdge *e, int ccw); +BMEdge *BM_Rotate_Edge ( BMesh *bm, BMEdge *e, int ccw ); /*updates a face normal*/ -void BM_Face_UpdateNormal(BMesh *bm, BMFace *f); +void BM_Face_UpdateNormal ( BMesh *bm, BMFace *f ); /*updates face and vertex normals incident on an edge*/ -void BM_Edge_UpdateNormals(BMesh *bm, BMEdge *e); +void BM_Edge_UpdateNormals ( BMesh *bm, BMEdge *e ); /*update a vert normal (but not the faces incident on it)*/ -void BM_Vert_UpdateNormal(BMesh *bm, BMVert *v); +void BM_Vert_UpdateNormal ( BMesh *bm, BMVert *v ); -void BM_flip_normal(BMesh *bm, BMFace *f); +void BM_flip_normal ( BMesh *bm, BMFace *f ); /*dissolves all faces around a vert, and removes it.*/ -int BM_Dissolve_Disk(BMesh *bm, BMVert *v); +int BM_Dissolve_Disk ( BMesh *bm, BMVert *v ); /*dissolves vert, in more situations then BM_Dissolve_Disk (e.g. if the vert is part of a wire edge, etc).*/ -int BM_Dissolve_Vert(BMesh *bm, BMVert *v); +int BM_Dissolve_Vert ( BMesh *bm, BMVert *v ); /*Interpolation*/ -void BM_Data_Interp_From_Verts(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, float fac); -void BM_Data_Facevert_Edgeinterp(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, struct BMEdge *e1, float fac); +void BM_Data_Interp_From_Verts ( struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, float fac ); +void BM_Data_Facevert_Edgeinterp ( struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, struct BMEdge *e1, float fac ); //void bmesh_data_interp_from_face(struct BMesh *bm, struct BMFace *source, struct BMFace *target); -void BM_add_data_layer(BMesh *em, CustomData *data, int type); -void BM_add_data_layer_named(BMesh *bm, CustomData *data, int type, char *name); -void BM_free_data_layer(BMesh *em, CustomData *data, int type); +void BM_add_data_layer ( BMesh *em, CustomData *data, int type ); +void BM_add_data_layer_named ( BMesh *bm, CustomData *data, int type, char *name ); +void BM_free_data_layer ( BMesh *em, CustomData *data, int type ); +float BM_GetCDf(struct CustomData *cd, void *element, int type); +void BM_SetCDf(struct CustomData *cd, void *element, int type, float val); /*computes the centroid of a face, using the center of the bounding box*/ -int BM_Compute_Face_Center(BMesh *bm, BMFace *f, float center[3]); +int BM_Compute_Face_Center ( BMesh *bm, BMFace *f, float center[3] ); -void BM_SelectMode_Flush(BMesh *bm); +void BM_SelectMode_Flush ( BMesh *bm ); /*convert an editmesh to a bmesh*/ -BMesh *editmesh_to_bmesh(struct EditMesh *em); +BMesh *editmesh_to_bmesh ( struct EditMesh *em ); /*initializes editmesh to bmesh operator, but doesn't execute. this is used in situations where you need to get access to the conversion operator's editmesh->bmesh mapping slot (e.g. if you need to find the bmesh edge that corrusponds to a specific editmesh edge).*/ -BMesh *init_editmesh_to_bmesh(struct EditMesh *em, struct BMOperator *op); +BMesh *init_editmesh_to_bmesh ( struct EditMesh *em, struct BMOperator *op ); /*converts a bmesh to an editmesh*/ -struct EditMesh *bmesh_to_editmesh(BMesh *bm); +struct EditMesh *bmesh_to_editmesh ( BMesh *bm ); /*convert between bmesh and Mesh flags*/ -int BMFlags_To_MEFlags(void *element); +int BMFlags_To_MEFlags ( void *element ); /*convert between Mesh and bmesh flags type must be BM_VERT/BM_EDGE/BM_FACE, and represents the type of the element parameter (the three defines map to MVert, MEdge, and MPoly, respectively).*/ -int MEFlags_To_BMFlags(int flag, int type); +int MEFlags_To_BMFlags ( int flag, int type ); /*convert MLoop*** in a bmface to mtface and mcol in an MFace*/ -void BM_loops_to_corners(BMesh *bm, struct Mesh *me, int findex, - BMFace *f, int numTex, int numCol); +void BM_loops_to_corners ( BMesh *bm, struct Mesh *me, int findex, + BMFace *f, int numTex, int numCol ); + +void BM_Kill_Loop(BMesh *bm, BMLoop *l); +void BM_Kill_Face(BMesh *bm, BMFace *f); +void BM_Kill_Edge(BMesh *bm, BMEdge *e); +void BM_Kill_Vert(BMesh *bm, BMVert *v); + +#define bm_firstfaceloop(p) ((BMLoopList*)(p->loops.first))->first /*include the rest of the API*/ #include "bmesh_filters.h" @@ -363,4 +276,125 @@ void BM_loops_to_corners(BMesh *bm, struct Mesh *me, int findex, #include "bmesh_queries.h" #include "bmesh_walkers.h" +#ifdef __cplusplus +} +#endif + #endif /* BMESH_H */ + +/*old structures*/ +#if 0 + +typedef struct BMHeader +{ + struct BMHeader *next, *prev; + int EID; /*Consider removing this/making it ifdeffed for debugging*/ + + /*don't confuse this with tool flags. this flag + member is what "header flag" means.*/ + int flag; + int type; /*the element type, can be BM_VERT, BM_EDGE, BM_LOOP, or BM_FACE*/ + int eflag1, eflag2; /*Flags used by eulers. Try and get rid of/minimize some of these*/ + + /*this is only used to store temporary integers. + don't use it for anything else. + use the BMINDEX_GET and BMINDEX_SET macros to access it*/ + int index; + struct BMFlagLayer *flags; /*Dynamically allocated block of flag layers for operators to use*/ + void *data; /*customdata block*/ +} BMHeader; + +typedef struct BMFlagLayer +{ + int f1; + short mask, pflag; +} BMFlagLayer; + +#define BM_OVERLAP (1<<14) /*used by bmesh_verts_in_face*/ +#define BM_EDGEVERT (1<<15) /*used by bmesh_make_ngon*/ + +/* + * BMNode + * + * Used for circular/linked list functions that form basis of + * adjacency system in BMesh. This should probably be hidden + * somewhere since tool authors never need to know about it. + * +*/ + +typedef struct BMNode +{ + struct BMNode *next, *prev; + void *data; +} BMNode; + +typedef struct BMesh +{ + ListBase verts, edges, polys; + struct BLI_mempool *vpool; + struct BLI_mempool *epool; + struct BLI_mempool *lpool; + struct BLI_mempool *ppool; + struct BMVert **vtar; + struct BMEdge **edar; + struct BMLoop **lpar; + struct BMFace **plar; + int vtarlen, edarlen, lparlen, plarlen; + int totvert, totedge, totface, totloop; + int totvertsel, totedgesel, totfacesel; + int nextv, nexte, nextp, nextl; + struct CustomData vdata, edata, pdata, ldata; + int selectmode; /*now uses defines in DNA_scene_types.h*/ + struct BLI_mempool *flagpool; /*memory pool for dynamically allocated flag layers*/ + int stackdepth; /*current depth of operator stack*/ + int totflags, walkers; /*total number of tool flag layers*/ + ListBase errorstack; + + /*selection order list*/ + ListBase selected; + + /*active face pointer*/ + struct BMFace *act_face; + + /*active shape key number, should really be in BMEditMesh, not here*/ + int shapenr; +} BMesh; + +typedef struct BMVert +{ + struct BMHeader head; + float co[3]; + float no[3]; + struct BMEdge *edge; + float bweight; /*please, someone just get rid of me...*/ +} BMVert; + +typedef struct BMEdge +{ + struct BMHeader head; + struct BMVert *v1, *v2; + struct BMNode d1, d2; + struct BMLoop *loop; + float crease, bweight; /*make these custom data.... no really, please....*/ +} BMEdge; + +typedef struct BMLoop +{ + struct BMHeader head; + struct BMNode radial; + struct BMVert *v; + struct BMEdge *e; + struct BMFace *f; +} BMLoop; + +typedef struct BMFace +{ + struct BMHeader head; + struct BMLoop *loopbase; + int len; + float no[3]; + + /*custom data again*/ + short mat_nr; +} BMFace; +#endif diff --git a/source/blender/bmesh/bmesh_iterators.h b/source/blender/bmesh/bmesh_iterators.h index cae022d66bd..16127f54e9d 100644 --- a/source/blender/bmesh/bmesh_iterators.h +++ b/source/blender/bmesh/bmesh_iterators.h @@ -13,6 +13,8 @@ #ifndef BM_ITERATORS_H #define BM_ITERATORS_H +#include "BLI_mempool.h" + /*Defines for passing to BMIter_New. "OF" can be substituted for "around" @@ -34,11 +36,15 @@ #define BM_VERTS_OF_FACE 8 #define BM_EDGES_OF_FACE 9 #define BM_LOOPS_OF_FACE 10 +/*returns elements from all boundaries, and returns +the first element at the end to flag that we're entering +a different face hole boundary*/ +#define BM_ALL_LOOPS_OF_FACE 11 /*iterate through loops around this loop, which are fetched from the other faces in the radial cycle surrounding the input loop's edge.*/ -#define BM_LOOPS_OF_LOOP 11 +#define BM_LOOPS_OF_LOOP 12 #define BM_ITER(ele, iter, bm, type, data) \ ele = BMIter_New(iter, bm, type, data); \ @@ -54,7 +60,9 @@ for (ele = BMIter_New(iter, bm, type, data); ele; ele=BMIter_Step(iter)) {\ /*Iterator Structure*/ -typedef struct BMIter{ +typedef struct BMIter { + BLI_mempool_iter pooliter; + struct BMVert *firstvert, *nextvert, *vdata; struct BMEdge *firstedge, *nextedge, *edata; struct BMLoop *firstloop, *nextloop, *ldata, *l; diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h index 820f43a3094..2bf091a3cf7 100644 --- a/source/blender/bmesh/bmesh_operator_api.h +++ b/source/blender/bmesh/bmesh_operator_api.h @@ -1,6 +1,10 @@ #ifndef _BMESH_OPERATOR_H #define _BMESH_OPERATOR_H +#ifdef __cplusplus +extern "C" { +#endif + #include "BLI_memarena.h" #include "BLI_ghash.h" @@ -85,6 +89,10 @@ typedef struct BMOpSlot{ #define BMOP_MAX_SLOTS 16 /*way more than probably needed*/ +#ifdef slots +#undef slots +#endif + typedef struct BMOperator { int type; int slottype; @@ -133,9 +141,9 @@ void BMO_Finish_Op(struct BMesh *bm, struct BMOperator *op); if you need to store a value per element, use a ghash or a mapping slot to do it.*/ /*flags 15 and 16 (1<<14 and 1<<15) are reserved for bmesh api use*/ -#define BMO_TestFlag(bm, element, flag) (((BMHeader*)element)->flags[bm->stackdepth-1].mask & (flag)) -#define BMO_SetFlag(bm, element, flag) (((BMHeader*)element)->flags[bm->stackdepth-1].mask |= (flag)) -#define BMO_ClearFlag(bm, element, flag) (((BMHeader*)element)->flags[bm->stackdepth-1].mask &= ~(flag)) +#define BMO_TestFlag(bm, element, flag) (((BMHeader*)element)->flags[bm->stackdepth-1].f & (flag)) +#define BMO_SetFlag(bm, element, flag) (((BMHeader*)element)->flags[bm->stackdepth-1].f |= (flag)) +#define BMO_ClearFlag(bm, element, flag) (((BMHeader*)element)->flags[bm->stackdepth-1].f &= ~(flag)) /*profiling showed a significant amount of time spent in BMO_TestFlag void BMO_SetFlag(struct BMesh *bm, void *element, int flag); @@ -376,9 +384,9 @@ BM_INLINE void BMO_Insert_Mapping(BMesh *bm, BMOperator *op, char *slotname, /*sanity check*/ if (slot->slottype != BMOP_OPSLOT_MAPPING) return; - mapping = BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); + mapping = (element_mapping*) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); - mapping->element = element; + mapping->element = (BMHeader*) element; mapping->len = len; memcpy(mapping+1, data, len); @@ -424,7 +432,7 @@ BM_INLINE void *BMO_Get_MapData(BMesh *bm, BMOperator *op, char *slotname, if (slot->slottype != BMOP_OPSLOT_MAPPING) return NULL; if (!slot->data.ghash) return NULL; - mapping = BLI_ghash_lookup(slot->data.ghash, element); + mapping = (element_mapping*) BLI_ghash_lookup(slot->data.ghash, element); if (!mapping) return NULL; @@ -434,7 +442,7 @@ BM_INLINE void *BMO_Get_MapData(BMesh *bm, BMOperator *op, char *slotname, BM_INLINE float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, char *slotname, void *element) { - float *val = BMO_Get_MapData(bm, op, slotname, element); + float *val = (float*) BMO_Get_MapData(bm, op, slotname, element); if (val) return *val; return 0.0f; @@ -443,10 +451,14 @@ BM_INLINE float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, char *slotname, BM_INLINE void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, char *slotname, void *element) { - void **val = BMO_Get_MapData(bm, op, slotname, element); + void **val = (void**) BMO_Get_MapData(bm, op, slotname, element); if (val) return *val; return NULL; } +#ifdef __cplusplus +} +#endif + #endif /* _BMESH_OPERATOR_H */ \ No newline at end of file diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index c444927824a..2364f6d554b 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -48,10 +48,12 @@ #include "string.h" #define SELECT 1 + #define BM_EDGEVERT (1<<14) /*prototypes*/ static void bm_copy_loop_attributes(BMesh *source_mesh, BMesh *target_mesh, BMLoop *source_loop, BMLoop *target_loop); +#if 0 /* * BM_CONSTRUCT.C @@ -100,7 +102,7 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge *example, int nod BMEdge *e = NULL; if(nodouble) /*test if edge already exists.*/ - e = bmesh_disk_existedge(v1, v2); + e = BM_Edge_Exist(v1, v2); if(!e){ e = bmesh_me(bm, v1, v2); @@ -112,6 +114,7 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge *example, int nod return e; } +#endif /* * BMESH MAKE QUADTRIANGLE @@ -136,10 +139,10 @@ BMFace *BM_Make_QuadTri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMEdge *edar[4]; BMVert *vtar[4]; - edar[0] = bmesh_disk_existedge(v1, v2); - edar[1] = bmesh_disk_existedge(v2, v3); - edar[2] = bmesh_disk_existedge(v3, v4? v4 : v1); - if (v4) edar[3] = bmesh_disk_existedge(v4, v1); + edar[0] = BM_Edge_Exist(v1, v2); + edar[1] = BM_Edge_Exist(v2, v3); + edar[2] = BM_Edge_Exist(v3, v4? v4 : v1); + if (v4) edar[3] = BM_Edge_Exist(v4, v1); else edar[3] = NULL; if (!edar[0]) edar[0] = BM_Make_Edge(bm, v1, v2, NULL, 0); @@ -170,14 +173,14 @@ BMFace *BM_Make_Quadtriangle(BMesh *bm, BMVert **verts, BMEdge **edges, int len, edar[2] = edges[2]; if(len == 4) edar[3] = edges[3]; }else{ - edar[0] = bmesh_disk_existedge(verts[0],verts[1]); - edar[1] = bmesh_disk_existedge(verts[1],verts[2]); + edar[0] = BM_Edge_Exist(verts[0],verts[1]); + edar[1] = BM_Edge_Exist(verts[1],verts[2]); if(len == 4){ - edar[2] = bmesh_disk_existedge(verts[2],verts[3]); - edar[3] = bmesh_disk_existedge(verts[3],verts[0]); + edar[2] = BM_Edge_Exist(verts[2],verts[3]); + edar[3] = BM_Edge_Exist(verts[3],verts[0]); }else{ - edar[2] = bmesh_disk_existedge(verts[2],verts[0]); + edar[2] = BM_Edge_Exist(verts[2],verts[0]); } } @@ -192,17 +195,16 @@ BMFace *BM_Make_Quadtriangle(BMesh *bm, BMVert **verts, BMEdge **edges, int len, /*make new face*/ if((!f) && (!overlap)){ - if(!edar[0]) edar[0] = bmesh_me(bm, verts[0], verts[1]); - if(!edar[1]) edar[1] = bmesh_me(bm, verts[1], verts[2]); + if(!edar[0]) edar[0] = BM_Make_Edge(bm, verts[0], verts[1], NULL, 0); + if(!edar[1]) edar[1] = BM_Make_Edge(bm, verts[1], verts[2], NULL, 0); if(len == 4){ - if(!edar[2]) edar[2] = bmesh_me(bm, verts[2], verts[3]); - if(!edar[3]) edar[3] = bmesh_me(bm, verts[3], verts[0]); + if(!edar[2]) edar[2] = BM_Make_Edge(bm, verts[2], verts[3], NULL, 0); + if(!edar[3]) edar[3] = BM_Make_Edge(bm, verts[3], verts[0], NULL, 0); } else { - if(!edar[2]) edar[2] = bmesh_me(bm, verts[2], verts[0]); + if(!edar[2]) edar[2] = BM_Make_Edge(bm, verts[2], verts[0], NULL, 0); } - if(len == 4) f = bmesh_mf(bm, verts[0], verts[1], edar, 4); - else f = bmesh_mf(bm, verts[0], verts[1], edar, 3); + f = BM_Make_Face(bm, verts, edar, len); if(example) CustomData_bmesh_copy_data(&bm->pdata, &bm->pdata, example->head.data, &f->head.data); @@ -222,13 +224,13 @@ void BM_Face_CopyShared(BMesh *bm, BMFace *f) { l=BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); for (; l; l=BMIter_Step(&iter)) { - l2 = l->radial.next->data; + l2 = l->radial_next; if (l2 && l2 != l) { if (l2->v == l->v) { bm_copy_loop_attributes(bm, bm, l2, l); } else { - l2 = (BMLoop*) l2->head.next; + l2 = (BMLoop*) l2->next; bm_copy_loop_attributes(bm, bm, l2, l); } } @@ -240,82 +242,126 @@ void BM_Face_CopyShared(BMesh *bm, BMFace *f) { * * Attempts to make a new Ngon from a list of edges. * If nodouble equals one, a check for overlaps or existing - * - * * + * The edges are not required to be ordered, simply to to form + * a single closed loop as a whole */ #define VERT_BUF_SIZE 100 BMFace *BM_Make_Ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, int nodouble) { - BMVert *vert_buf[VERT_BUF_SIZE]; - BMVert **verts = vert_buf, *lastv; + BMEdge **edges2 = NULL; + BLI_array_staticdeclare(edges2, VERT_BUF_SIZE); + BMVert **verts = NULL, *v; + BLI_array_staticdeclare(verts, VERT_BUF_SIZE); BMFace *f = NULL; - int overlap = 0, i, j; - - /*note: need to make sure this is correct*/ - if(bmesh_verts_in_edge(v1,v2,edges[0]) == 0) { - if (v1 == edges[0]->v1) - v2 = edges[0]->v2; - else { - v1 = edges[0]->v2; - v2 = edges[0]->v1; + BMEdge *e; + int overlap = 0, i, j, v1found, reverse; + + /*this code is hideous, yeek. I'll have to think about ways of + cleaning it up. basically, it now combines the old BM_Make_Ngon + *and* the old bmesh_mf functions, so its kindof smashed together + - joeedh*/ + + if (!len || !v1 || !v2 || !edges || !bm) + return NULL; + + /*put edges in correct order*/ + for (i=0; iv1); + + v = edges[0]->v2; + e = edges[0]; + do { + BMEdge *e2 = e; + + BLI_array_append(verts, v); + BLI_array_append(edges2, e); + + do { + e2 = bmesh_disk_nextedge(e2, v); + if (e2 != e && bmesh_api_getflag(e2, _FLAG_MF)) { + v = BM_OtherEdgeVert(e2, v); + break; + } + } while (e2 != e); + + if (e2 == e) + goto err; /*the edges do not form a closed loop*/ + + e = e2; + } while (e != edges[0]); + + if (BLI_array_count(edges2) != len) + goto err; /*we didn't use all edges in forming the boundary loop*/ + + /*ok, edges are in correct order, now ensure they are going + in the correct direction*/ + v1found = reverse = 0; + for (i=0; i VERT_BUF_SIZE) - verts = MEM_callocN(sizeof(BMVert *) * len, "bmesh make ngon vertex array"); - - /*if ((edges[i]->v1 == edges[i]->v1) || - (edges[i]->v1 == edges[i]->v2)) - { - lastv = edges[i]->v2; - } else lastv = edges[i]->v1; - verts[0] = lastv; - - for (i=1; iv1, BM_EDGEVERT); - BMO_ClearFlag(bm, edges[i]->v2, BM_EDGEVERT); + if (reverse) { + for (i=0; iv1, BM_EDGEVERT)){ - BMO_SetFlag(bm, edges[i]->v1, BM_EDGEVERT); - verts[j++] = edges[i]->v1; - } - if(!BMO_TestFlag(bm, edges[i]->v2, BM_EDGEVERT)) { - BMO_SetFlag(bm, edges[i]->v2, BM_EDGEVERT); - verts[j++] = edges[i]->v2; - } - } - - if (j != len) { - /*sanity check*/ - return NULL; - } + for (i=0; iv1, BM_EDGEVERT); - BMO_ClearFlag(bm, edges[i]->v2, BM_EDGEVERT); - } - - if(len > VERT_BUF_SIZE) - MEM_freeN(verts); + + /*create the face, if necassary*/ + if (!f && !overlap) + f = BM_Make_Face(bm, verts, edges2, len); + else if (!overlap) + f = NULL; + + /*clean up flags*/ + for (i=0; ipolys.first; - while(current){ - next = current->next; - if(BMO_TestFlag(bm, current, flag)) bmesh_kf(bm, (BMFace*)current); - current = next; + BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { + if(BMO_TestFlag(bm, f, flag)) BM_Kill_Face(bm, f); } } + void BM_remove_tagged_edges(BMesh *bm, int flag) { - BMHeader *current, *next; - - current = bm->edges.first; - - while(current){ - next = current->next; - if(BMO_TestFlag(bm, current, flag)) bmesh_ke(bm, (BMEdge*)current); - current = next; + BMEdge *e; + BMIter iter; + + BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { + if(BMO_TestFlag(bm, e, flag)) BM_Kill_Edge(bm, e); } } void BM_remove_tagged_verts(BMesh *bm, int flag) { - BMHeader *current, *next; + BMVert *v; + BMIter iter; - current = bm->verts.first; - - while(current){ - next = current->next; - if(BMO_TestFlag(bm, current, flag)) bmesh_kv(bm,(BMVert*)current); - current = next; + BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { + if(BMO_TestFlag(bm, v, flag)) BM_Kill_Vert(bm, v); } } static void bm_copy_vert_attributes(BMesh *source_mesh, BMesh *target_mesh, BMVert *source_vertex, BMVert *target_vertex) { CustomData_bmesh_copy_data(&source_mesh->vdata, &target_mesh->vdata, source_vertex->head.data, &target_vertex->head.data); - target_vertex->bweight = source_vertex->bweight; } static void bm_copy_edge_attributes(BMesh *source_mesh, BMesh *target_mesh, BMEdge *source_edge, BMEdge *target_edge) { CustomData_bmesh_copy_data(&source_mesh->edata, &target_mesh->edata, source_edge->head.data, &target_edge->head.data); - target_edge->crease = source_edge->crease; - target_edge->bweight = source_edge->bweight; } static void bm_copy_loop_attributes(BMesh *source_mesh, BMesh *target_mesh, BMLoop *source_loop, BMLoop *target_loop) @@ -598,4 +634,4 @@ int MEFlags_To_BMFlags(int flag, int type) { } return f; -} \ No newline at end of file +} diff --git a/source/blender/bmesh/intern/bmesh_eulers.c b/source/blender/bmesh/intern/bmesh_eulers.c index 746969a00e0..43b1ee76ffd 100644 --- a/source/blender/bmesh/intern/bmesh_eulers.c +++ b/source/blender/bmesh/intern/bmesh_eulers.c @@ -1,3 +1,6 @@ +/*some of this may come back, such as split face or split edge, if necassary for speed*/ + +#if 0 /** * bmesh_eulers.c jan 2007 * @@ -137,13 +140,13 @@ BMEdge *bmesh_me(BMesh *bm, BMVert *v1, BMVert *v2){ #ifndef bmesh_FASTEULER /*count valance of v1*/ - if(v1->edge){ - d1 = bmesh_disk_getpointer(v1->edge,v1); + if(v1->e){ + d1 = bmesh_disk_getpointer(v1->e,v1); if(d1) valance1 = bmesh_cycle_length(d1); else bmesh_error(); } - if(v2->edge){ - d2 = bmesh_disk_getpointer(v2->edge,v2); + if(v2->e){ + d2 = bmesh_disk_getpointer(v2->e,v2); if(d2) valance2 = bmesh_cycle_length(d2); else bmesh_error(); } @@ -203,8 +206,8 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len) if(len < 2) return NULL; /*make sure that v1 and v2 are in elist[0]*/ - if(bmesh_verts_in_edge(v1,v2,elist[0]) == 0) - return NULL; + //if(bmesh_verts_in_edge(v1,v2,elist[0]) == 0) + // return NULL; /*clear euler flags*/ for(i=0;iv2 : elist[i]->v1; - diskbase = bmesh_disk_getpointer(v1->edge, v1); + diskbase = bmesh_disk_getpointer(v1->e, v1); len = bmesh_cycle_length(diskbase); - for(a=0,curedge=v1->edge;ae;ahead.eflag1 = curedge->head.eflag2 = 0; } } @@ -230,7 +233,7 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len) elist[i]->head.eflag1 |= MF_CANDIDATE; /*if elist[i] has a loop, count its radial length*/ - if(elist[i]->loop) elist[i]->head.eflag2 = bmesh_cycle_length(&(elist[i]->loop->radial)); + if(elist[i]->loop) elist[i]->head.eflag2 = bmesh_cycle_length(&(elist[i]->l->radial)); else elist[i]->head.eflag2 = 0; } @@ -238,12 +241,12 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len) Note that this does not gauruntee that face is a single closed loop. At best it gauruntees that elist contains a finite number of seperate closed loops. */ - for(i=0; iv1, MF_CANDIDATE, 0); - if(edok != 2) return NULL; - edok = bmesh_disk_count_edgeflag(elist[i]->v2, MF_CANDIDATE, 0); - if(edok != 2) return NULL; - } +// for(i=0; iv1, MF_CANDIDATE, 0); +// if(edok != 2) return NULL; +// edok = bmesh_disk_count_edgeflag(elist[i]->v2, MF_CANDIDATE, 0); +// if(edok != 2) return NULL; +// } /*set start edge, start vert and target vert for our loop traversal*/ curedge = elist[0]; @@ -288,9 +291,9 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len) from sv, but that several unconnected loops were passed in via elist. */ cont=1; - for(i=0; ihead.eflag1 & MF_VISITED) == 0) cont = 0; - } +// for(i=0; ihead.eflag1 & MF_VISITED) == 0) cont = 0; +// } /*if we get this far, its ok to allocate the face and add the loops*/ if(cont){ @@ -301,18 +304,18 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len) for(i=0;iloopbase)) f->loopbase = l; - bmesh_cycle_append(f->loopbase, l); + if(!(f->loopbase)) f->lbase = l; + bmesh_cycle_append(f->lbase, l); } /*take care of edge pointers and radial cycle*/ - for(i=0, l = f->loopbase; ihead.next))){ + for(i=0, l = f->loopbase; inext))){ e = NULL; if(l == f->loopbase) e = elist[0]; /*first edge*/ else{/*search elist for others*/ for(j=1; jv, ((BMLoop*)(l->head.next))->v, elist[j]); + edok = bmesh_verts_in_edge(l->v, ((BMLoop*)(l->next))->v, elist[j]); if(edok){ e = elist[j]; break; @@ -326,11 +329,11 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len) f->len = len; /*Validation Loop cycle*/ - edok = bmesh_cycle_validate(len, f->loopbase); + edok = bmesh_cycle_validate(len, f->lbase); if(!edok) bmesh_error(); - for(i=0, l = f->loopbase; ihead.next))){ + for(i=0, l = f->loopbase; inext))){ /*validate loop vert pointers*/ - edok = bmesh_verts_in_edge(l->v, ((BMLoop*)(l->head.next))->v, l->e); + edok = bmesh_verts_in_edge(l->v, ((BMLoop*)(l->next))->v, l->e); if(!edok) bmesh_error(); /*validate the radial cycle of each edge*/ edok = bmesh_cycle_length(&(l->radial)); @@ -356,7 +359,7 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len) */ int bmesh_kv(BMesh *bm, BMVert *v){ - if(v->edge == NULL){ + if(v->e == NULL){ if (BM_TestHFlag(v, BM_SELECT)) bm->totvertsel--; BLI_remlink(&(bm->verts), &(v->head)); @@ -381,7 +384,7 @@ int bmesh_ke(BMesh *bm, BMEdge *e){ int edok; /*Make sure that no faces!*/ - if(e->loop == NULL){ + if(e->l == NULL){ bmesh_disk_remove_edge(e, e->v1); bmesh_disk_remove_edge(e, e->v2); @@ -418,14 +421,14 @@ int bmesh_kf(BMesh *bm, BMFace *bply){ /*add validation to make sure that radial cycle is cleaned up ok*/ /*deal with radial cycle first*/ - len = bmesh_cycle_length(bply->loopbase); - for(i=0, curloop=bply->loopbase; i < len; i++, curloop = ((BMLoop*)(curloop->head.next))) + len = bmesh_cycle_length(bply->lbase); + for(i=0, curloop=bply->loopbase; i < len; i++, curloop = ((BMLoop*)(curloop->next))) bmesh_radial_remove_loop(curloop, curloop->e); /*now deallocate the editloops*/ for(i=0; i < len; i++){ - newbase = ((BMLoop*)(bply->loopbase->head.next)); - oldbase = bply->loopbase; + newbase = ((BMLoop*)(bply->lbase->next)); + oldbase = bply->lbase; bmesh_cycle_remove(oldbase, oldbase); bmesh_free_loop(bm, oldbase); bply->loopbase = newbase; @@ -486,36 +489,36 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re){ /*add ne to tv's disk cycle*/ bmesh_disk_append_edge(ne, tv); /*verify disk cycles*/ - diskbase = bmesh_disk_getpointer(ov->edge,ov); + diskbase = bmesh_disk_getpointer(ov->e,ov); edok = bmesh_cycle_validate(valance1, diskbase); if(!edok) bmesh_error(); - diskbase = bmesh_disk_getpointer(tv->edge,tv); + diskbase = bmesh_disk_getpointer(tv->e,tv); edok = bmesh_cycle_validate(valance2, diskbase); if(!edok) bmesh_error(); - diskbase = bmesh_disk_getpointer(nv->edge,nv); + diskbase = bmesh_disk_getpointer(nv->e,nv); edok = bmesh_cycle_validate(2, diskbase); if(!edok) bmesh_error(); /*Split the radial cycle if present*/ - if(e->loop){ + if(e->l){ BMLoop *nl,*l; BMNode *radEBase=NULL, *radNEBase=NULL; - int radlen = bmesh_cycle_length(&(e->loop->radial)); + int radlen = bmesh_cycle_length(&(e->l->radial)); /*Take the next loop. Remove it from radial. Split it. Append to appropriate radials.*/ - while(e->loop){ - l=e->loop; + while(e->l){ + l=e->l; l->f->len++; bmesh_radial_remove_loop(l,e); nl = bmesh_create_loop(bm,NULL,NULL,l->f,l); - nl->head.prev = (BMHeader*)l; - nl->head.next = (BMHeader*)(l->head.next); - nl->head.prev->next = (BMHeader*)nl; - nl->head.next->prev = (BMHeader*)nl; + nl->prev = (BMHeader*)l; + nl->next = (BMHeader*)(l->next); + nl->prev->next = (BMHeader*)nl; + nl->next->prev = (BMHeader*)nl; nl->v = nv; /*assign the correct edge to the correct loop*/ - if(bmesh_verts_in_edge(nl->v, ((BMLoop*)(nl->head.next))->v, e)){ + if(bmesh_verts_in_edge(nl->v, ((BMLoop*)(nl->next))->v, e)){ nl->e = e; l->e = ne; @@ -536,7 +539,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re){ bmesh_cycle_append(radNEBase,&(l->radial)); } - else if(bmesh_verts_in_edge(nl->v,((BMLoop*)(nl->head.next))->v,ne)){ + else if(bmesh_verts_in_edge(nl->v,((BMLoop*)(nl->next))->v,ne)){ nl->e = ne; l->e = e; @@ -556,39 +559,39 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re){ } - e->loop = radEBase->data; - ne->loop = radNEBase->data; + e->l = radEBase->data; + ne->l = radNEBase->data; /*verify length of radial cycle*/ - edok = bmesh_cycle_validate(radlen,&(e->loop->radial)); + edok = bmesh_cycle_validate(radlen,&(e->l->radial)); if(!edok) bmesh_error(); - edok = bmesh_cycle_validate(radlen,&(ne->loop->radial)); + edok = bmesh_cycle_validate(radlen,&(ne->l->radial)); if(!edok) bmesh_error(); /*verify loop->v and loop->next->v pointers for e*/ - for(i=0,l=e->loop; i < radlen; i++, l = l->radial.next->data){ + for(i=0,l=e->l; i < radlen; i++, l = l->radial_next){ if(!(l->e == e)) bmesh_error(); if(!(l->radial.data == l)) bmesh_error(); - if( ((BMLoop*)(l->head.prev))->e != ne && ((BMLoop*)(l->head.next))->e != ne) bmesh_error(); - edok = bmesh_verts_in_edge(l->v, ((BMLoop*)(l->head.next))->v, e); + if( ((BMLoop*)(l->prev))->e != ne && ((BMLoop*)(l->next))->e != ne) bmesh_error(); + edok = bmesh_verts_in_edge(l->v, ((BMLoop*)(l->next))->v, e); if(!edok) bmesh_error(); - if(l->v == ((BMLoop*)(l->head.next))->v) bmesh_error(); - if(l->e == ((BMLoop*)(l->head.next))->e) bmesh_error(); + if(l->v == ((BMLoop*)(l->next))->v) bmesh_error(); + if(l->e == ((BMLoop*)(l->next))->e) bmesh_error(); /*verify loop cycle for kloop->f*/ - edok = bmesh_cycle_validate(l->f->len, l->f->loopbase); + edok = bmesh_cycle_validate(l->f->len, l->f->lbase); if(!edok) bmesh_error(); } /*verify loop->v and loop->next->v pointers for ne*/ - for(i=0,l=ne->loop; i < radlen; i++, l = l->radial.next->data){ + for(i=0,l=ne->l; i < radlen; i++, l = l->radial_next){ if(!(l->e == ne)) bmesh_error(); if(!(l->radial.data == l)) bmesh_error(); - if( ((BMLoop*)(l->head.prev))->e != e && ((BMLoop*)(l->head.next))->e != e) bmesh_error(); - edok = bmesh_verts_in_edge(l->v, ((BMLoop*)(l->head.next))->v, ne); + if( ((BMLoop*)(l->prev))->e != e && ((BMLoop*)(l->next))->e != e) bmesh_error(); + edok = bmesh_verts_in_edge(l->v, ((BMLoop*)(l->next))->v, ne); if(!edok) bmesh_error(); - if(l->v == ((BMLoop*)(l->head.next))->v) bmesh_error(); - if(l->e == ((BMLoop*)(l->head.next))->e) bmesh_error(); + if(l->v == ((BMLoop*)(l->next))->v) bmesh_error(); + if(l->e == ((BMLoop*)(l->next))->e) bmesh_error(); /*verify loop cycle for kloop->f. Redundant*/ - edok = bmesh_cycle_validate(l->f->len, l->f->loopbase); + edok = bmesh_cycle_validate(l->f->len, l->f->lbase); if(!edok) bmesh_error(); } } @@ -635,8 +638,8 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **rl){ /*verify that v1 and v2 are in face.*/ - len = bmesh_cycle_length(f->loopbase); - for(i = 0, curloop = f->loopbase; i < len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + len = bmesh_cycle_length(f->lbase); + for(i = 0, curloop = f->loopbase; i < len; i++, curloop = ((BMLoop*)(curloop->next)) ){ if(curloop->v == v1) v1loop = curloop; else if(curloop->v == v2) v2loop = curloop; } @@ -652,15 +655,15 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **rl){ f1loop = bmesh_create_loop(bm,v2,e,f,v2loop); f2loop = bmesh_create_loop(bm,v1,e,f2,v1loop); - f1loop->head.prev = v2loop->head.prev; - f2loop->head.prev = v1loop->head.prev; - v2loop->head.prev->next = (BMHeader*)f1loop; - v1loop->head.prev->next = (BMHeader*)f2loop; + f1loop->prev = v2loop->prev; + f2loop->prev = v1loop->prev; + v2loop->prev->next = (BMHeader*)f1loop; + v1loop->prev->next = (BMHeader*)f2loop; - f1loop->head.next = (BMHeader*)v1loop; - f2loop->head.next = (BMHeader*)v2loop; - v1loop->head.prev = (BMHeader*)f1loop; - v2loop->head.prev = (BMHeader*)f2loop; + f1loop->next = (BMHeader*)v1loop; + f2loop->next = (BMHeader*)v2loop; + v1loop->prev = (BMHeader*)f1loop; + v2loop->prev = (BMHeader*)f2loop; f2->loopbase = f2loop; f->loopbase = f1loop; @@ -669,8 +672,8 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **rl){ /*I dont know how many loops are supposed to be in each face at this point! FIXME!*/ /*go through all of f2's loops and make sure they point to it properly.*/ - f2len = bmesh_cycle_length(f2->loopbase); - for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->head.next)) ) curloop->f = f2; + f2len = bmesh_cycle_length(f2->lbase); + for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->next)) ) curloop->f = f2; /*link up the new loops into the new edges radial*/ bmesh_radial_append(e, f1loop); @@ -679,7 +682,7 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **rl){ f2->len = f2len; - f1len = bmesh_cycle_length(f->loopbase); + f1len = bmesh_cycle_length(f->lbase); f->len = f1len; if(rl) *rl = f2loop; @@ -727,7 +730,7 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) int len,radlen=0, halt = 0, i, valance1, valance2,edok; if(bmesh_vert_in_edge(ke,kv) == 0) return 0; - diskbase = bmesh_disk_getpointer(kv->edge, kv); + diskbase = bmesh_disk_getpointer(kv->e, kv); len = bmesh_cycle_length(diskbase); if(len == 2){ @@ -740,9 +743,9 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) else{ /*For verification later, count valance of ov and tv*/ - diskbase = bmesh_disk_getpointer(ov->edge, ov); + diskbase = bmesh_disk_getpointer(ov->e, ov); valance1 = bmesh_cycle_length(diskbase); - diskbase = bmesh_disk_getpointer(tv->edge, tv); + diskbase = bmesh_disk_getpointer(tv->e, tv); valance2 = bmesh_cycle_length(diskbase); /*remove oe from kv's disk cycle*/ @@ -757,22 +760,22 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) /*deal with radial cycle of ke*/ - if(ke->loop){ + if(ke->l){ /*first step, fix the neighboring loops of all loops in ke's radial cycle*/ - radlen = bmesh_cycle_length(&(ke->loop->radial)); - for(i=0,killoop = ke->loop; il->radial)); + for(i=0,killoop = ke->l; ihead.next->prev = killoop->head.prev; - killoop->head.prev->next = killoop->head.next; - if( ((BMLoop*)(killoop->head.next))->v == kv) ((BMLoop*)(killoop->head.next))->v = tv; + killoop->next->prev = killoop->prev; + killoop->prev->next = killoop->next; + if( ((BMLoop*)(killoop->next))->v == kv) ((BMLoop*)(killoop->next))->v = tv; /*fix len attribute of face*/ killoop->f->len--; - if(killoop->f->loopbase == killoop) killoop->f->loopbase = ((BMLoop*)(killoop->head.next)); + if(killoop->f->loopbase == killoop) killoop->f->lbase = ((BMLoop*)(killoop->next)); } /*second step, remove all the hanging loops attached to ke*/ - killoop = ke->loop; - radlen = bmesh_cycle_length(&(ke->loop->radial)); + killoop = ke->l; + radlen = bmesh_cycle_length(&(ke->l->radial)); /*make sure we have enough room in bm->lpar*/ if(bm->lparlen < radlen){ MEM_freeN(bm->lpar); @@ -783,7 +786,7 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) i=0; while(ilpar[i] = killoop; - killoop = killoop->radial.next->data; + killoop = killoop->radial_next; i++; } i=0; @@ -792,22 +795,22 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) i++; } /*Validate radial cycle of oe*/ - edok = bmesh_cycle_validate(radlen,&(oe->loop->radial)); + edok = bmesh_cycle_validate(radlen,&(oe->l->radial)); } /*Validate disk cycles*/ - diskbase = bmesh_disk_getpointer(ov->edge,ov); + diskbase = bmesh_disk_getpointer(ov->e,ov); edok = bmesh_cycle_validate(valance1, diskbase); if(!edok) bmesh_error(); - diskbase = bmesh_disk_getpointer(tv->edge,tv); + diskbase = bmesh_disk_getpointer(tv->e,tv); edok = bmesh_cycle_validate(valance2, diskbase); if(!edok) bmesh_error(); /*Validate loop cycle of all faces attached to oe*/ - for(i=0,nextl = oe->loop; if->len,nextl->f->loopbase); + for(i=0,nextl = oe->l; if->len,nextl->f->lbase); if(!edok) bmesh_error(); } /*deallocate edge*/ @@ -849,7 +852,7 @@ int bmesh_loop_reverse(BMesh *bm, BMFace *f){ bm->edarlen = len; } - for(i=0, curloop = l; i< len; i++, curloop= ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = l; i< len; i++, curloop= ((BMLoop*)(curloop->next)) ){ curloop->e->head.eflag1 = 0; curloop->e->head.eflag2 = bmesh_cycle_length(&curloop->radial); bmesh_radial_remove_loop(curloop, curloop->e); @@ -860,23 +863,23 @@ int bmesh_loop_reverse(BMesh *bm, BMFace *f){ /*actually reverse the loop. This belongs in bmesh_cycle_reverse!*/ for(i=0, curloop = l; i < len; i++){ - oldnext = ((BMLoop*)(curloop->head.next)); - oldprev = ((BMLoop*)(curloop->head.prev)); - curloop->head.next = (BMHeader*)oldprev; - curloop->head.prev = (BMHeader*)oldnext; + oldnext = ((BMLoop*)(curloop->next)); + oldprev = ((BMLoop*)(curloop->prev)); + curloop->next = (BMHeader*)oldprev; + curloop->prev = (BMHeader*)oldnext; curloop = oldnext; } if(len == 2){ //two edged face //do some verification here! l->e = bm->edar[1]; - ((BMLoop*)(l->head.next))->e = bm->edar[0]; + ((BMLoop*)(l->next))->e = bm->edar[0]; } else{ - for(i=0, curloop = l; i < len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = l; i < len; i++, curloop = ((BMLoop*)(curloop->next)) ){ edok = 0; for(j=0; j < len; j++){ - edok = bmesh_verts_in_edge(curloop->v, ((BMLoop*)(curloop->head.next))->v, bm->edar[j]); + edok = bmesh_verts_in_edge(curloop->v, ((BMLoop*)(curloop->next))->v, bm->edar[j]); if(edok){ curloop->e = bm->edar[j]; break; @@ -885,10 +888,10 @@ int bmesh_loop_reverse(BMesh *bm, BMFace *f){ } } /*rebuild radial*/ - for(i=0, curloop = l; i < len; i++, curloop = ((BMLoop*)(curloop->head.next)) ) bmesh_radial_append(curloop->e, curloop); + for(i=0, curloop = l; i < len; i++, curloop = ((BMLoop*)(curloop->next)) ) bmesh_radial_append(curloop->e, curloop); /*validate radial*/ - for(i=0, curloop = l; i < len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = l; i < len; i++, curloop = ((BMLoop*)(curloop->next)) ){ edok = bmesh_cycle_validate(curloop->e->head.eflag2, &(curloop->radial)); if(!edok){ bmesh_error(); @@ -939,15 +942,15 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) if(f1 == f2) return NULL; //can't join a face to itself /*verify that e is in both f1 and f2*/ - f1len = bmesh_cycle_length(f1->loopbase); - f2len = bmesh_cycle_length(f2->loopbase); - for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + f1len = bmesh_cycle_length(f1->lbase); + f2len = bmesh_cycle_length(f2->lbase); + for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->next)) ){ if(curloop->e == e){ f1loop = curloop; break; } } - for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->next)) ){ if(curloop->e==e){ f2loop = curloop; break; @@ -966,59 +969,59 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) validate that for each face, each vertex has another edge in its disk cycle that is not e, and not shared. */ - if(bmesh_radial_find_face( ((BMLoop*)(f1loop->head.next))->e,f2)) return NULL; - if(bmesh_radial_find_face( ((BMLoop*)(f1loop->head.prev))->e,f2)) return NULL; - if(bmesh_radial_find_face( ((BMLoop*)(f2loop->head.next))->e,f1)) return NULL; - if(bmesh_radial_find_face( ((BMLoop*)(f2loop->head.prev))->e,f1)) return NULL; + if(bmesh_radial_find_face( ((BMLoop*)(f1loop->next))->e,f2)) return NULL; + if(bmesh_radial_find_face( ((BMLoop*)(f1loop->prev))->e,f2)) return NULL; + if(bmesh_radial_find_face( ((BMLoop*)(f2loop->next))->e,f1)) return NULL; + if(bmesh_radial_find_face( ((BMLoop*)(f2loop->prev))->e,f1)) return NULL; /*validate only one shared edge*/ shared = BM_Face_Sharededges(f1,f2); if(shared > 1) return NULL; /*validate no internal joins*/ - for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->head.next)) ) curloop->v->head.eflag1 = 0; - for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->head.next)) ) curloop->v->head.eflag1 = 0; + for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->next)) ) curloop->v->head.eflag1 = 0; + for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->next)) ) curloop->v->head.eflag1 = 0; - for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->next)) ){ if(curloop != f1loop) curloop->v->head.eflag1++; } - for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->next)) ){ if(curloop != f2loop) curloop->v->head.eflag1++; } - for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = f1->loopbase; i < f1len; i++, curloop = ((BMLoop*)(curloop->next)) ){ if(curloop->v->head.eflag1 > 1) return NULL; } - for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->head.next)) ){ + for(i=0, curloop = f2->loopbase; i < f2len; i++, curloop = ((BMLoop*)(curloop->next)) ){ if(curloop->v->head.eflag1 > 1) return NULL; } /*join the two loops*/ - f1loop->head.prev->next = f2loop->head.next; - f2loop->head.next->prev = f1loop->head.prev; + f1loop->prev->next = f2loop->next; + f2loop->next->prev = f1loop->prev; - f1loop->head.next->prev = f2loop->head.prev; - f2loop->head.prev->next = f1loop->head.next; + f1loop->next->prev = f2loop->prev; + f2loop->prev->next = f1loop->next; /*if f1loop was baseloop, give f1loop->next the base.*/ - if(f1->loopbase == f1loop) f1->loopbase = ((BMLoop*)(f1loop->head.next)); + if(f1->loopbase == f1loop) f1->lbase = ((BMLoop*)(f1loop->next)); /*validate the new loop*/ - loopok = bmesh_cycle_validate((f1len+f2len)-2, f1->loopbase); + loopok = bmesh_cycle_validate((f1len+f2len)-2, f1->lbase); if(!loopok) bmesh_error(); /*make sure each loop points to the proper face*/ - newlen = bmesh_cycle_length(f1->loopbase); - for(i = 0, curloop = f1->loopbase; i < newlen; i++, curloop = ((BMLoop*)(curloop->head.next)) ) curloop->f = f1; + newlen = bmesh_cycle_length(f1->lbase); + for(i = 0, curloop = f1->loopbase; i < newlen; i++, curloop = ((BMLoop*)(curloop->next)) ) curloop->f = f1; f1->len = newlen; - edok = bmesh_cycle_validate(f1->len, f1->loopbase); + edok = bmesh_cycle_validate(f1->len, f1->lbase); if(!edok) bmesh_error(); /*remove edge from the disk cycle of its two vertices.*/ @@ -1063,16 +1066,16 @@ BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv) /*validate the l->e pointers of all affected faces, ie: l->v and l->next->v should be equivalent to l->e*/ /*verify that sv has edges*/ - if(sv->edge == NULL) + if(sv->e == NULL) return NULL; /*first verify no wire edges on sv*/ - curedge = sv->edge; + curedge = sv->e; do{ - if(curedge->loop == NULL) + if(curedge->l == NULL) return NULL; curedge = bmesh_disk_nextedge(curedge, sv); - }while(curedge != sv->edge); + }while(curedge != sv->e); /*next verify that sv is in sf*/ l = sf->loopbase; @@ -1081,8 +1084,8 @@ BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv) sl = l; break; } - l = (BMLoop*)(l->head.next); - }while(l != sf->loopbase); + l = (BMLoop*)(l->next); + }while(l != sf->lbase); if(sl == NULL) return NULL; @@ -1090,17 +1093,17 @@ BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv) /*clear euler flags*/ sv->head.eflag1 = 0; - curedge = sv->edge; + curedge = sv->e; do{ curedge->head.eflag1 = 0; - l = curedge->loop; + l = curedge->l; do{ l->head.eflag1 = 0; l->f->head.eflag1 = 0; l = bmesh_radial_nextloop(l); - }while(l != curedge->loop); + }while(l != curedge->l); curedge = bmesh_disk_nextedge(curedge, sv); - }while(curedge != sv->edge); + }while(curedge != sv->e); /*search through face disk and flag elements as we go.*/ /*Note, test this to make sure that it works correct on @@ -1111,36 +1114,36 @@ BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv) l->f->head.eflag1 |= URMV_VISIT; do{ if(l->v == sv) - l = bmesh_radial_nextloop((BMLoop*)(l->head.prev)); + l = bmesh_radial_nextloop((BMLoop*)(l->prev)); else - l = bmesh_radial_nextloop((BMLoop*)(l->head.next)); + l = bmesh_radial_nextloop((BMLoop*)(l->next)); l->e->head.eflag1 |= URMV_VISIT; l->f->head.eflag1 |= URMV_VISIT; }while(l != sl && (bmesh_cycle_length(&(l->radial)) > 1) ); /*Verify that all visited edges are at least 1 or 2 manifold*/ - curedge = sv->edge; + curedge = sv->e; do{ - if(curedge->head.eflag1 && (bmesh_cycle_length(&(curedge->loop->radial)) > 2) ) + if(curedge->head.eflag1 && (bmesh_cycle_length(&(curedge->l->radial)) > 2) ) return NULL; curedge = bmesh_disk_nextedge(curedge, sv); - }while(curedge != sv->edge); + }while(curedge != sv->e); /*allocate temp storage - we overallocate here instead of trying to be clever*/ maxedges = 0; maxloops = 0; - curedge = sv->edge; + curedge = sv->e; do{ - if(curedge->loop){ - l = curedge->loop; + if(curedge->l){ + l = curedge->l; do{ maxloops += l->f->len; l = bmesh_radial_nextloop(l); - }while(l != curedge->loop); + }while(l != curedge->l); } maxedges+= 1; curedge = bmesh_disk_nextedge(curedge,sv); - }while(curedge != sv->edge); + }while(curedge != sv->e); if(bm->edarlen < maxedges){ MEM_freeN(bm->edar); @@ -1154,10 +1157,10 @@ BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv) } /*first get loops by looping around edges and loops around that edges faces*/ - curedge = sv->edge; + curedge = sv->e; do{ - if(curedge->loop){ - l = curedge->loop; + if(curedge->l){ + l = curedge->l; do{ if( (l->head.eflag1 & URMV_VISIT) && (!(l->head.eflag1 & URMV_VISIT2)) ){ bm->lpar[numloops] = l; @@ -1165,20 +1168,20 @@ BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv) numloops++; } l = bmesh_radial_nextloop(l); - }while(l != curedge->loop); + }while(l != curedge->l); } curedge = bmesh_disk_nextedge(curedge, sv); - }while(curedge != sv->edge); + }while(curedge != sv->e); /*now collect edges by looping around edges and looking at visited flags*/ - curedge = sv->edge; + curedge = sv->e; do{ if(curedge->head.eflag1 & URMV_VISIT){ bm->edar[numedges] = curedge; numedges++; } curedge = bmesh_disk_nextedge(curedge, sv); - }while(curedge != sv->edge); + }while(curedge != sv->e); /*make new vertex*/ nv = bmesh_addvertlist(bm, sv); @@ -1202,3 +1205,4 @@ BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv) } return nv; } +#endif diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 7eab2ca0c3b..9dfe3c63be9 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -83,8 +83,6 @@ void BM_Data_Interp_From_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, flo void BM_Data_Vert_Average(BMesh *bm, BMFace *f) { BMIter iter; - - } /** @@ -105,17 +103,17 @@ void BM_Data_Facevert_Edgeinterp(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, B w[1] = 1.0f - fac; w[0] = fac; - if(!e1->loop) return; - l = e1->loop; + if(!e1->l) return; + l = e1->l; do{ if(l->v == v1){ v1loop = l; - vloop = (BMLoop*)(v1loop->head.next); - v2loop = (BMLoop*)(vloop->head.next); + vloop = (BMLoop*)(v1loop->next); + v2loop = (BMLoop*)(vloop->next); }else if(l->v == v){ - v1loop = (BMLoop*)(l->head.next); + v1loop = (BMLoop*)(l->next); vloop = l; - v2loop = (BMLoop*)(l->head.prev); + v2loop = (BMLoop*)(l->prev); } @@ -123,8 +121,8 @@ void BM_Data_Facevert_Edgeinterp(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, B src[1] = v2loop->head.data; CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, vloop->head.data); - l = l->radial.next->data; - }while(l!=e1->loop); + l = l->radial_next; + }while(l!=e1->l); } void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex, @@ -276,4 +274,24 @@ void BM_free_data_layer(BMesh *bm, CustomData *data, int type) update_data_blocks(bm, &olddata, data); if (olddata.layers) MEM_freeN(olddata.layers); -} \ No newline at end of file +} + +float BM_GetCDf(CustomData *cd, void *element, int type) +{ + if (CustomData_has_layer(cd, type)) { + float *f = CustomData_bmesh_get(cd, ((BMHeader*)element)->data, type); + return *f; + } + + return 0.0; +} + +void BM_SetCDf(CustomData *cd, void *element, int type, float val) +{ + if (CustomData_has_layer(cd, type)) { + float *f = CustomData_bmesh_get(cd, ((BMHeader*)element)->data, type); + *f = val; + } + + return; +} diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 1c88c16acc2..f53a9e4f47b 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -74,68 +74,35 @@ static void init_iterator(BMIter *iter) static void vert_of_mesh_begin(BMIter *iter) { - init_iterator(iter); - if(iter->bm->verts.first){ - iter->firstvert = iter->bm->verts.first; - iter->nextvert = iter->bm->verts.first; - } + BLI_mempool_iternew(iter->bm->vpool, &iter->pooliter); } static void *vert_of_mesh_step(BMIter *iter) { - BMVert *current = iter->nextvert; + return BLI_mempool_iterstep(&iter->pooliter); - if(iter->nextvert) - iter->nextvert = (BMVert*)(iter->nextvert->head.next); - - return current; } -/* - * EDGE OF MESH CALLBACKS - * -*/ - static void edge_of_mesh_begin(BMIter *iter) { - init_iterator(iter); - if(iter->bm->edges.first){ - iter->firstedge = iter->bm->edges.first; - iter->nextedge = iter->bm->edges.first; - } + BLI_mempool_iternew(iter->bm->epool, &iter->pooliter); } static void *edge_of_mesh_step(BMIter *iter) { - BMEdge *current = iter->nextedge; + return BLI_mempool_iterstep(&iter->pooliter); - if(iter->nextedge) - iter->nextedge = (BMEdge*)(iter->nextedge->head.next); - - return current; } -/* - * FACE OF MESH CALLBACKS - * -*/ - static void face_of_mesh_begin(BMIter *iter) { - init_iterator(iter); - if(iter->bm->polys.first){ - iter->firstpoly = iter->bm->polys.first; - iter->nextpoly = iter->bm->polys.first; - } + BLI_mempool_iternew(iter->bm->fpool, &iter->pooliter); } static void *face_of_mesh_step(BMIter *iter) { - BMFace *current = iter->nextpoly; + return BLI_mempool_iterstep(&iter->pooliter); - if(iter->nextpoly) - iter->nextpoly = (BMFace*)(iter->nextpoly->head.next); - return current; } /* @@ -146,9 +113,9 @@ static void *face_of_mesh_step(BMIter *iter) static void edge_of_vert_begin(BMIter *iter) { init_iterator(iter); - if(iter->vdata->edge){ - iter->firstedge = iter->vdata->edge; - iter->nextedge = iter->vdata->edge; + if(iter->vdata->e){ + iter->firstedge = iter->vdata->e; + iter->nextedge = iter->vdata->e; } } @@ -173,12 +140,12 @@ static void face_of_vert_begin(BMIter *iter) { init_iterator(iter); iter->count = 0; - if(iter->vdata->edge) + if(iter->vdata->e) iter->count = bmesh_disk_count_facevert(iter->vdata); if(iter->count){ - iter->firstedge = bmesh_disk_find_first_faceedge(iter->vdata->edge, iter->vdata); + iter->firstedge = bmesh_disk_find_first_faceedge(iter->vdata->e, iter->vdata); iter->nextedge = iter->firstedge; - iter->firstloop = bmesh_radial_find_first_facevert(iter->firstedge->loop, iter->vdata); + iter->firstloop = bmesh_radial_find_first_facevert(iter->firstedge->l, iter->vdata); iter->nextloop = iter->firstloop; } } @@ -186,12 +153,12 @@ static void *face_of_vert_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->count){ + if(iter->count && iter->nextloop) { iter->count--; iter->nextloop = bmesh_radial_find_next_facevert(iter->nextloop, iter->vdata); if(iter->nextloop == iter->firstloop){ iter->nextedge = bmesh_disk_find_next_faceedge(iter->nextedge, iter->vdata); - iter->firstloop = bmesh_radial_find_first_facevert(iter->nextedge->loop, iter->vdata); + iter->firstloop = bmesh_radial_find_first_facevert(iter->nextedge->l, iter->vdata); iter->nextloop = iter->firstloop; } } @@ -213,12 +180,12 @@ static void loop_of_vert_begin(BMIter *iter) { init_iterator(iter); iter->count = 0; - if(iter->vdata->edge) + if(iter->vdata->e) iter->count = bmesh_disk_count_facevert(iter->vdata); if(iter->count){ - iter->firstedge = bmesh_disk_find_first_faceedge(iter->vdata->edge, iter->vdata); + iter->firstedge = bmesh_disk_find_first_faceedge(iter->vdata->e, iter->vdata); iter->nextedge = iter->firstedge; - iter->firstloop = bmesh_radial_find_first_facevert(iter->firstedge->loop, iter->vdata); + iter->firstloop = bmesh_radial_find_first_facevert(iter->firstedge->l, iter->vdata); iter->nextloop = iter->firstloop; } } @@ -231,7 +198,7 @@ static void *loop_of_vert_step(BMIter *iter) iter->nextloop = bmesh_radial_find_next_facevert(iter->nextloop, iter->vdata); if(iter->nextloop == iter->firstloop){ iter->nextedge = bmesh_disk_find_next_faceedge(iter->nextedge, iter->vdata); - iter->firstloop = bmesh_radial_find_first_facevert(iter->nextedge->loop, iter->vdata); + iter->firstloop = bmesh_radial_find_first_facevert(iter->nextedge->l, iter->vdata); iter->nextloop = iter->firstloop; } } @@ -276,9 +243,9 @@ static void face_of_edge_begin(BMIter *iter) { init_iterator(iter); - if(iter->edata->loop){ - iter->firstloop = iter->edata->loop; - iter->nextloop = iter->edata->loop; + if(iter->edata->l){ + iter->firstloop = iter->edata->l; + iter->nextloop = iter->edata->l; } } @@ -301,14 +268,14 @@ static void *face_of_edge_step(BMIter *iter) static void vert_of_face_begin(BMIter *iter) { init_iterator(iter); - iter->firstloop = iter->nextloop = iter->pdata->loopbase; + iter->firstloop = iter->nextloop = ((BMLoopList*)iter->pdata->loops.first)->first; } static void *vert_of_face_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = ((BMLoop*)(iter->nextloop->head.next)); + if(iter->nextloop) iter->nextloop = ((BMLoop*)(iter->nextloop->next)); if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; if(current) return current->v; @@ -323,14 +290,14 @@ static void *vert_of_face_step(BMIter *iter) static void edge_of_face_begin(BMIter *iter) { init_iterator(iter); - iter->firstloop = iter->nextloop = iter->pdata->loopbase; + iter->firstloop = iter->nextloop = ((BMLoopList*)iter->pdata->loops.first)->first; } static void *edge_of_face_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = ((BMLoop*)(iter->nextloop->head.next)); + if(iter->nextloop) iter->nextloop = ((BMLoop*)(iter->nextloop->next)); if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; if(current) return current->e; @@ -345,14 +312,14 @@ static void *edge_of_face_step(BMIter *iter) static void loop_of_face_begin(BMIter *iter) { init_iterator(iter); - iter->firstloop = iter->nextloop = iter->pdata->loopbase; + iter->firstloop = iter->nextloop = bm_firstfaceloop(iter->pdata); } static void *loop_of_face_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = ((BMLoop*)(iter->nextloop->head.next)); + if(iter->nextloop) iter->nextloop = ((BMLoop*)(iter->nextloop->next)); if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; return current; @@ -390,41 +357,65 @@ void *BMIter_New(BMIter *iter, BMesh *bm, int type, void *data) iter->bm = bm; break; case BM_EDGES_OF_VERT: + if (!data) + return NULL; + iter->begin = edge_of_vert_begin; iter->step = edge_of_vert_step; iter->vdata = data; break; case BM_FACES_OF_VERT: + if (!data) + return NULL; + iter->begin = face_of_vert_begin; iter->step = face_of_vert_step; iter->vdata = data; break; case BM_LOOPS_OF_VERT: + if (!data) + return NULL; + iter->begin = loop_of_vert_begin; iter->step = loop_of_vert_step; iter->vdata = data; break; case BM_FACES_OF_EDGE: + if (!data) + return NULL; + iter->begin = face_of_edge_begin; iter->step = face_of_edge_step; iter->edata = data; break; case BM_VERTS_OF_FACE: + if (!data) + return NULL; + iter->begin = vert_of_face_begin; iter->step = vert_of_face_step; iter->pdata = data; break; case BM_EDGES_OF_FACE: + if (!data) + return NULL; + iter->begin = edge_of_face_begin; iter->step = edge_of_face_step; iter->pdata = data; break; case BM_LOOPS_OF_FACE: + if (!data) + return NULL; + iter->begin = loop_of_face_begin; iter->step = loop_of_face_step; iter->pdata = data; break; case BM_LOOPS_OF_LOOP: + if (!data) + return NULL; + iter->begin = loops_of_loop_begin; iter->step = loops_of_loop_step; iter->ldata = data; diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index fa2bd6be481..463cd635696 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -75,12 +75,12 @@ void BM_SelectMode_Flush(BMesh *bm) } for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) { totsel = 0; - l=f->loopbase; + l=(BMLoop*) bm_firstfaceloop(f); do{ if(BM_TestHFlag(l->v, BM_SELECT)) totsel++; - l = ((BMLoop*)(l->head.next)); - } while(l != f->loopbase); + l = ((BMLoop*)(l->next)); + } while(l != bm_firstfaceloop(f)); if(totsel == f->len) BM_SetHFlag(f, BM_SELECT); @@ -91,12 +91,12 @@ void BM_SelectMode_Flush(BMesh *bm) else if(bm->selectmode & SCE_SELECT_EDGE) { for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) { totsel = 0; - l=f->loopbase; + l=(BMLoop*) bm_firstfaceloop(f); do{ if(bmesh_test_sysflag(&(l->e->head), BM_SELECT)) totsel++; - l = ((BMLoop*)(l->head.next)); - }while(l!=f->loopbase); + l = ((BMLoop*)(l->next)); + }while(l!=bm_firstfaceloop(f)); if(totsel == f->len) BM_SetHFlag(f, BM_SELECT); @@ -215,12 +215,12 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select) if (!BM_TestHFlag(f, BM_SELECT)) bm->totfacesel += 1; BM_SetHFlag(&(f->head), BM_SELECT); - l = f->loopbase; + l=(BMLoop*) bm_firstfaceloop(f); do{ BM_Select_Vert(bm, l->v, 1); BM_Select_Edge(bm, l->e, 1); - l = ((BMLoop*)(l->head.next)); - }while(l != f->loopbase); + l = ((BMLoop*)(l->next)); + }while(l != bm_firstfaceloop(f)); } else{ BMIter liter, fiter, eiter; diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index ea69429449a..3675292063e 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -88,31 +88,6 @@ int bmesh_test_sysflag(BMHeader *head, int flag) return 0; } -/* - * BMESH MAKE MESH - * - * Allocates a new BMesh structure. - * Returns - - * Pointer to a BM - * -*/ - -BMesh *BM_Make_Mesh(int allocsize[4]) -{ - /*allocate the structure*/ - BMesh *bm = MEM_callocN(sizeof(BMesh),"BM"); - /*allocate the memory pools for the mesh elements*/ - bm->vpool = BLI_mempool_create(sizeof(BMVert), allocsize[0], allocsize[0], 1); - bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize[1], allocsize[1], 1); - bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize[2], allocsize[2], 1); - bm->ppool = BLI_mempool_create(sizeof(BMFace), allocsize[3], allocsize[3], 1); - - /*allocate one flag pool that we dont get rid of.*/ - bm->flagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, 1); - bm->totflags = 1; - - return bm; -} /* * BMESH FREE MESH * @@ -154,15 +129,11 @@ void BM_Free_Mesh_Data(BMesh *bm) /*destroy element pools*/ BLI_mempool_destroy(bm->vpool); BLI_mempool_destroy(bm->epool); - BLI_mempool_destroy(bm->ppool); + BLI_mempool_destroy(bm->fpool); BLI_mempool_destroy(bm->lpool); /*destroy flag pool*/ - BLI_mempool_destroy(bm->flagpool); - - if (bm->edar) MEM_freeN(bm->edar); - if (bm->vtar) MEM_freeN(bm->vtar); - if (bm->plar) MEM_freeN(bm->plar); + BLI_mempool_destroy(bm->toolflagpool); BLI_freelistN(&bm->selected); @@ -191,7 +162,7 @@ void BM_Compute_Normals(BMesh *bm) BMIter verts; BMIter faces; BMIter loops; - unsigned int maxlength = 0; + unsigned int maxlength = 0, i; float (*projectverts)[3]; /*first, find out the largest face in mesh*/ @@ -227,7 +198,10 @@ void BM_Compute_Normals(BMesh *bm) } /*add face normals to vertices*/ + i = 0; BM_ITER(f, &faces, bm, BM_FACES_OF_MESH, NULL) { + i += 1; + if (BM_TestHFlag(f, BM_HIDDEN)) continue; @@ -262,42 +236,9 @@ void BM_Compute_Normals(BMesh *bm) */ void bmesh_begin_edit(BMesh *bm){ - if(bm->vtar) MEM_freeN(bm->vtar); - if(bm->edar) MEM_freeN(bm->edar); - if(bm->lpar) MEM_freeN(bm->lpar); - if(bm->plar) MEM_freeN(bm->plar); - - /*Initialize some scratch pointer arrays used by eulers*/ - bm->vtar = MEM_callocN(sizeof(BMVert *) * 1024, "BM scratch vert array"); - bm->edar = MEM_callocN(sizeof(BMEdge *) * 1024, "BM scratch edge array"); - bm->lpar = MEM_callocN(sizeof(BMLoop *) * 1024, "BM scratch loop array"); - bm->plar = MEM_callocN(sizeof(BMFace *) * 1024, "BM scratch poly array"); - - bm->vtarlen = bm->edarlen = bm->lparlen = bm->plarlen = 1024; } void bmesh_end_edit(BMesh *bm, int flag){ - int totvert, totedge, totface; - /*verify element counts*/ - totvert = BLI_countlist(&(bm->verts)); - totedge = BLI_countlist(&(bm->edges)); - totface = BLI_countlist(&(bm->polys)); - - if(bm->totvert!=totvert || bm->totedge!=totedge || bm->totface!=totface) BME_error(); - - /*free temp storage*/ - if(bm->vtar) MEM_freeN(bm->vtar); - if(bm->edar) MEM_freeN(bm->edar); - if(bm->lpar) MEM_freeN(bm->lpar); - if(bm->plar) MEM_freeN(bm->plar); - - /*zero out pointers*/ - bm->vtar = NULL; - bm->edar = NULL; - bm->lpar = NULL; - bm->plar = NULL; - bm->vtarlen = bm->edarlen = bm->lparlen = bm->plarlen = 0; - /*compute normals, clear temp flags and flush selections*/ BM_Compute_Normals(bm); BM_SelectMode_Flush(bm); diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 81d192dcdb7..718326b803d 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -54,16 +54,16 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) { } if (len == 1) { - bmesh_ke(bm, v->edge); - bmesh_kv(bm, v); + BM_Kill_Edge(bm, v->e); + BM_Kill_Vert(bm, v); return 1; } if(BM_Nonmanifold_Vert(bm, v)) { - if (!v->edge) bmesh_kv(bm, v); - else if (!v->edge->loop) { - bmesh_ke(bm, v->edge); - bmesh_kv(bm, v); + if (!v->e) BM_Kill_Vert(bm, v); + else if (!v->e->l) { + BM_Kill_Edge(bm, v->e); + BM_Kill_Vert(bm, v); } else return 0; return 1; @@ -82,19 +82,19 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) { return 0; } - if(v->edge){ - /*v->edge we keep, what else?*/ - e = v->edge; + if(v->e){ + /*v->e we keep, what else?*/ + e = v->e; len = 0; do{ e = bmesh_disk_nextedge(e,v); - if(!(BM_Edge_Share_Faces(e, v->edge))){ + if(!(BM_Edge_Share_Faces(e, v->e))){ keepedge = e; - baseedge = v->edge; + baseedge = v->e; break; } len++; - }while(e != v->edge); + }while(e != v->e); } /*this code for handling 2 and 3-valence verts @@ -102,8 +102,8 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) { if (keepedge == NULL && len == 3) { /*handle specific case for three-valence. solve it by increasing valence to four. this may be hackish. . .*/ - loop = e->loop; - if (loop->v == v) loop = (BMLoop*) loop->head.next; + loop = e->l; + if (loop->v == v) loop = (BMLoop*) loop->next; if (!BM_Split_Face(bm, loop->f, v, loop->v, NULL, NULL)) return 0; @@ -111,11 +111,11 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) { return 1; } else if (keepedge == NULL && len == 2) { /*handle two-valence*/ - f = v->edge->loop->f; - f2 = ((BMLoop*)v->edge->loop->radial.next->data)->f; + f = v->e->l->f; + f2 = ((BMLoop*)v->e->l->radial_next)->f; /*collapse the vertex*/ - BM_Collapse_Vert(bm, v->edge, v, 1.0); - BM_Join_Faces(bm, f, f2, NULL); + BM_Collapse_Vert(bm, v->e, v, 1.0); + BM_Join_TwoFaces(bm, f, f2, NULL); return 1; } @@ -124,12 +124,12 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) { done = 0; while(!done){ done = 1; - e = v->edge; + e = v->e; do{ f = NULL; - len = bmesh_cycle_length(&(e->loop->radial)); + len = bmesh_radial_length(e->l); if(len == 2 && (e!=baseedge) && (e!=keepedge)) { - f = BM_Join_Faces(bm, e->loop->f, ((BMLoop*)(e->loop->radial.next->data))->f, e); + f = BM_Join_TwoFaces(bm, e->l->f, ((BMLoop*)(e->l->radial_next))->f, e); /*return if couldn't join faces in manifold conditions.*/ //!disabled for testing why bad things happen @@ -141,19 +141,19 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) { break; } e = bmesh_disk_nextedge(e, v); - }while(e != v->edge); + }while(e != v->e); } /*get remaining two faces*/ - f = v->edge->loop->f; - f2 = ((BMLoop*)v->edge->loop->radial.next->data)->f; + f = v->e->l->f; + f2 = ((BMLoop*)v->e->l->radial_next)->f; /*collapse the vertex*/ BM_Collapse_Vert(bm, baseedge, v, 1.0); if (f != f2) { /*join two remaining faces*/ - if (!BM_Join_Faces(bm, f, f2, NULL)) return 0; + if (!BM_Join_TwoFaces(bm, f, f2, NULL)) return 0; } } @@ -166,7 +166,7 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v){ BMIter iter; int done, len; - if(v->edge){ + if(v->e){ done = 0; while(!done){ done = 1; @@ -175,10 +175,10 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v){ for (e=BMIter_New(&iter, bm, BM_EDGES_OF_VERT, v); e; e = BMIter_Step(&iter)) { f = NULL; - len = bmesh_cycle_length(&(e->loop->radial)); + len = bmesh_cycle_length(&(e->l->radial)); if(len == 2){ - f = BM_Join_Faces(bm,e->loop->f,((BMLoop*) - (e->loop->radial.next->data))->f, + f = BM_Join_TwoFaces(bm,e->l->f,((BMLoop*) + (e->l->radial_next))->f, e); } if(f){ @@ -187,7 +187,7 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v){ } }; } - BM_Collapse_Vert(bm, v->edge, v, 1.0); + BM_Collapse_Vert(bm, v->e, v, 1.0); } } #endif @@ -201,31 +201,32 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v){ * BMFace pointer */ -BMFace *BM_Join_Faces(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) { +BMFace *BM_Join_TwoFaces(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) { BMLoop *l1, *l2; BMEdge *jed=NULL; + BMFace *faces[2] = {f1, f2}; jed = e; if(!jed){ /*search for an edge that has both these faces in its radial cycle*/ - l1 = f1->loopbase; + l1 = bm_firstfaceloop(f1); do{ - if( ((BMLoop*)l1->radial.next->data)->f == f2 ){ + if( ((BMLoop*)l1->radial_next)->f == f2 ){ jed = l1->e; break; } - l1 = ((BMLoop*)(l1->head.next)); - }while(l1!=f1->loopbase); + l1 = ((BMLoop*)(l1->next)); + }while(l1!=bm_firstfaceloop(f1)); } - l1 = jed->loop; - l2 = l1->radial.next->data; + l1 = jed->l; + l2 = l1->radial_next; if (l1->v == l2->v) { bmesh_loop_reverse(bm, f2); } - f1 = bmesh_jfke(bm, f1, f2, jed); + f1 = BM_Join_Faces(bm, faces, 2); return f1; } @@ -274,7 +275,7 @@ BMEdge *BM_Connect_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **nf) { BMFace *BM_Split_Face(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **nl, BMEdge *example) { BMFace *nf; - nf = bmesh_sfme(bm,f,v1,v2,nl); + nf = bmesh_sfme(bm,f,v1,v2,nl, NULL); if (nf) { BM_Copy_Attributes(bm, bm, f, nf); @@ -302,30 +303,66 @@ BMFace *BM_Split_Face(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **nl, */ void BM_Collapse_Vert(BMesh *bm, BMEdge *ke, BMVert *kv, float fac){ - void *src[2]; - float w[2]; + BMFace **faces = NULL, *f; + BLI_array_staticdeclare(faces, 8); + BMIter iter; BMLoop *l=NULL, *kvloop=NULL, *tvloop=NULL; BMVert *tv = bmesh_edge_getothervert(ke,kv); + void *src[2]; + float w[2]; w[0] = 1.0f - fac; w[1] = fac; - if(ke->loop){ - l = ke->loop; + if(ke->l){ + l = ke->l; do{ - if(l->v == tv && ((BMLoop*)(l->head.next))->v == kv){ + if(l->v == tv && ((BMLoop*)(l->next))->v == kv){ tvloop = l; - kvloop = ((BMLoop*)(l->head.next)); + kvloop = ((BMLoop*)(l->next)); src[0] = kvloop->head.data; src[1] = tvloop->head.data; CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, kvloop->head.data); } - l=l->radial.next->data; - }while(l!=ke->loop); + l=l->radial_next; + }while(l!=ke->l); } - BM_Data_Interp_From_Verts(bm, kv, tv, kv, fac); - bmesh_jekv(bm,ke,kv); + + BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, kv) { + BLI_array_append(faces, f); + } + + BM_Data_Interp_From_Verts(bm, kv, tv, kv, fac); + + //bmesh_jekv(bm,ke,kv); + if (faces) { + BMFace *f2; + BMEdge *e2; + BMVert *tv2; + + /*ok, no faces, means we have a wire edge*/ + e2 = bmesh_disk_nextedge(ke, kv); + tv2 = BM_OtherEdgeVert(e2, kv); + + f2 = BM_Join_Faces(bm, faces, BLI_array_count(faces)); + BM_Split_Face(bm, f2, tv, tv2, NULL, NULL); + } else { + BMVert *tv2; + BMEdge *e2, *ne; + + /*ok, no faces, means we have a wire edge*/ + e2 = bmesh_disk_nextedge(ke, kv); + tv2 = BM_OtherEdgeVert(e2, kv); + + ne = BM_Make_Edge(bm, tv, tv2, ke, 0); + + BM_Kill_Edge(bm, ke); + BM_Kill_Edge(bm, e2); + BM_Kill_Vert(bm, kv); + } + + BLI_array_free(faces); } /** @@ -441,7 +478,7 @@ BMEdge *BM_Rotate_Edge(BMesh *bm, BMEdge *e, int ccw) if (BM_Edge_FaceCount(e) != 2) return NULL; - f = BM_Join_Faces(bm, e->loop->f, ((BMLoop*)e->loop->radial.next->data)->f, e); + f = BM_Join_TwoFaces(bm, e->l->f, ((BMLoop*)e->l->radial_next)->f, e); BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { if (l->v == v1) @@ -451,11 +488,11 @@ BMEdge *BM_Rotate_Edge(BMesh *bm, BMEdge *e, int ccw) } if (ccw) { - l1 = (BMLoop*) l1->head.prev; - l2 = (BMLoop*) l2->head.prev; + l1 = (BMLoop*) l1->prev; + l2 = (BMLoop*) l2->prev; } else { - l1 = (BMLoop*) l1->head.next; - l2 = (BMLoop*) l2->head.next; + l1 = (BMLoop*) l1->next; + l2 = (BMLoop*) l2->next; } if (!BM_Split_Face(bm, f, l1->v, l2->v, &nl, NULL)) diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index fdaa231fb9f..8571056bd84 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -594,6 +594,8 @@ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, char *slotname, int flag, } } } + } else { + output->len = 0; } } @@ -641,6 +643,8 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, char *slotname, int flag, int t } } } + } else { + output->len = 0; } } @@ -696,15 +700,13 @@ void BMO_UnHeaderFlag_Buffer(BMesh *bm, BMOperator *op, char *slotname, int flag int BMO_Vert_CountEdgeFlags(BMesh *bm, BMVert *v, int toolflag) { - BMNode *diskbase; BMEdge *curedge; int i, len=0, count=0; - if(v->edge){ - diskbase = bmesh_disk_getpointer(v->edge, v); - len = bmesh_cycle_length(diskbase); + if(v->e) { + len = bmesh_disk_count(v); - for(i = 0, curedge=v->edge; ie; iflagpool; /*old flag pool*/ + BLI_mempool *oldpool = bm->toolflagpool; /*old flag pool*/ void *oldflags; + bm->totflags++; + /*allocate new flag pool*/ - bm->flagpool = BLI_mempool_create(sizeof(BMFlagLayer)*(bm->totflags+1), 512, 512, 1); + bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer)*bm->totflags, 512, 512, 1, 0); /*now go through and memcpy all the flags. Loops don't get a flag layer at this time...*/ for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)){ oldflags = v->head.flags; - v->head.flags = BLI_mempool_calloc(bm->flagpool); + v->head.flags = BLI_mempool_calloc(bm->toolflagpool); memcpy(v->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); /*dont know if this memcpy usage is correct*/ } for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)){ oldflags = e->head.flags; - e->head.flags = BLI_mempool_calloc(bm->flagpool); + e->head.flags = BLI_mempool_calloc(bm->toolflagpool); memcpy(e->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); } for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)){ oldflags = f->head.flags; - f->head.flags = BLI_mempool_calloc(bm->flagpool); + f->head.flags = BLI_mempool_calloc(bm->toolflagpool); memcpy(f->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); } - bm->totflags++; + BLI_mempool_destroy(oldpool); } @@ -819,28 +823,28 @@ static void free_flag_layer(BMesh *bm) BMIter verts; BMIter edges; BMIter faces; - BLI_mempool *oldpool = bm->flagpool; + BLI_mempool *oldpool = bm->toolflagpool; void *oldflags; /*de-increment the totflags first...*/ bm->totflags--; /*allocate new flag pool*/ - bm->flagpool = BLI_mempool_create(sizeof(BMFlagLayer)*bm->totflags, 512, 512, 1); + bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer)*bm->totflags, 512, 512, 1, 0); /*now go through and memcpy all the flags*/ for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)){ oldflags = v->head.flags; - v->head.flags = BLI_mempool_calloc(bm->flagpool); + v->head.flags = BLI_mempool_calloc(bm->toolflagpool); memcpy(v->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); /*correct?*/ } for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)){ oldflags = e->head.flags; - e->head.flags = BLI_mempool_calloc(bm->flagpool); + e->head.flags = BLI_mempool_calloc(bm->toolflagpool); memcpy(e->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); } for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)){ oldflags = f->head.flags; - f->head.flags = BLI_mempool_calloc(bm->flagpool); + f->head.flags = BLI_mempool_calloc(bm->toolflagpool); memcpy(f->head.flags, oldflags, sizeof(BMFlagLayer)*bm->totflags); } @@ -859,13 +863,13 @@ static void clear_flag_layer(BMesh *bm) /*now go through and memcpy all the flags*/ for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)){ - memset(v->head.flags+bm->totflags-1, 0, sizeof(BMFlagLayer)); + memset(v->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); } for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)){ - memset(e->head.flags+bm->totflags-1, 0, sizeof(BMFlagLayer)); + memset(e->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); } for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)){ - memset(f->head.flags+bm->totflags-1, 0, sizeof(BMFlagLayer)); + memset(f->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); } } @@ -1059,6 +1063,18 @@ static int bmesh_name_to_slotcode(BMOpDefine *def, char *name) return 0; } +static int bmesh_name_to_slotcode_check(BMOpDefine *def, char *name) +{ + int i; + + for (i=0; def->slottypes[i].type; i++) { + if (!strcmp(name, def->slottypes[i].name)) return i; + } + + printf("yeek! could not find bmesh slot for name %s!\n", name); + return -1; +} + static int bmesh_opname_to_opcode(char *opname) { int i; @@ -1125,7 +1141,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, char *fmt, va_list vlist) fmt[i] = 0; - if (bmesh_name_to_slotcode(def, fmt) < 0) goto error; + if (bmesh_name_to_slotcode_check(def, fmt) < 0) goto error; strcpy(slotname, fmt); @@ -1284,7 +1300,7 @@ int BMO_CallOpf(BMesh *bm, char *fmt, ...) { void BMO_SetFlag(BMesh *bm, void *element, int flag) { BMHeader *head = element; - head->flags[bm->stackdepth-1].mask |= flag; + head->flags[bm->stackdepth-1].f |= flag; } /* @@ -1300,7 +1316,7 @@ void BMO_SetFlag(BMesh *bm, void *element, int flag) void BMO_ClearFlag(BMesh *bm, void *element, int flag) { BMHeader *head = element; - head->flags[bm->stackdepth-1].mask &= ~flag; + head->flags[bm->stackdepth-1].f &= ~flag; } /* @@ -1317,7 +1333,7 @@ void BMO_ClearFlag(BMesh *bm, void *element, int flag) int BMO_TestFlag(BMesh *bm, void *element, int flag) { BMHeader *head = element; - if(head->flags[bm->stackdepth-1].mask & flag) + if(head->flags[bm->stackdepth-1].f & flag) return 1; return 0; } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 81861b4d509..08c555631eb 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -395,15 +395,16 @@ void BM_Face_UpdateNormal(BMesh *bm, BMFace *f) { float projverts[200][3]; float (*proj)[3] = f->len < 200 ? projverts : MEM_mallocN(sizeof(float)*f->len*3, "projvertsn"); - BMLoop *l = f->loopbase; + BMIter iter; + BMLoop *l; int i=0; if (f->len < 3) return; - do { + BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { VECCOPY(proj[i], l->v->co); i += 1; - } while (l != f->loopbase); + } bmesh_update_face_normal(bm, f, proj); @@ -444,33 +445,33 @@ void BM_Vert_UpdateNormal(BMesh *bm, BMVert *v) void bmesh_update_face_normal(BMesh *bm, BMFace *f, float (*projectverts)[3]) { + BMIter iter; BMLoop *l; int i; if(f->len > 4) { i = 0; - l = f->loopbase; - do{ + BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { VECCOPY(projectverts[i], l->v->co); - l = (BMLoop*)(l->head.next); + l = (BMLoop*)(l->next); i += 1; - }while(l!=f->loopbase); + } compute_poly_normal(f->no, projectverts, f->len); } else if(f->len == 3){ BMVert *v1, *v2, *v3; - v1 = f->loopbase->v; - v2 = ((BMLoop*)(f->loopbase->head.next))->v; - v3 = ((BMLoop*)(f->loopbase->head.next->next))->v; + v1 = bm_firstfaceloop(f)->v; + v2 = bm_firstfaceloop(f)->next->v; + v3 = bm_firstfaceloop(f)->next->next->v; normal_tri_v3( f->no,v1->co, v2->co, v3->co); } else if(f->len == 4){ BMVert *v1, *v2, *v3, *v4; - v1 = f->loopbase->v; - v2 = ((BMLoop*)(f->loopbase->head.next))->v; - v3 = ((BMLoop*)(f->loopbase->head.next->next))->v; - v4 = ((BMLoop*)(f->loopbase->head.prev))->v; + v1 = bm_firstfaceloop(f)->v; + v2 = bm_firstfaceloop(f)->next->v; + v3 = bm_firstfaceloop(f)->next->next->v; + v4 = bm_firstfaceloop(f)->prev->v; normal_quad_v3( f->no,v1->co, v2->co, v3->co, v4->co); } else{ /*horrible, two sided face!*/ @@ -588,7 +589,7 @@ int linecrossesf(float *v1, float *v2, float *v3, float *v4) int goodline(float (*projectverts)[3], BMFace *f, int v1i, int v2i, int v3i, int nvert) { - BMLoop *l = f->loopbase; + BMLoop *l = bm_firstfaceloop(f); double v1[3], v2[3], v3[3], pv1[3], pv2[3]; int i; @@ -602,19 +603,19 @@ int goodline(float (*projectverts)[3], BMFace *f, int v1i, do { i = l->v->head.eflag2; if (i == v1i || i == v2i || i == v3i) { - l = (BMLoop*)l->head.next; + l = (BMLoop*)l->next; continue; } VECCOPY(pv1, projectverts[l->v->head.eflag2]); - VECCOPY(pv2, projectverts[((BMLoop*)l->head.next)->v->head.eflag2]); + VECCOPY(pv2, projectverts[((BMLoop*)l->next)->v->head.eflag2]); //if (linecrosses(pv1, pv2, v1, v3)) return 0; if (point_in_triangle(v1, v2, v3, pv1)) return 0; if (point_in_triangle(v3, v2, v1, pv1)) return 0; - l = (BMLoop*)l->head.next; - } while (l != f->loopbase); + l = (BMLoop*)l->next; + } while (l != bm_firstfaceloop(f)); return 1; } /* @@ -634,13 +635,13 @@ static BMLoop *find_ear(BMesh *bm, BMFace *f, float (*verts)[3], float angle, bestangle = 180.0f; int isear, i=0; - l = f->loopbase; + l = bm_firstfaceloop(f); do { isear = 1; - v1 = ((BMLoop*)(l->head.prev))->v; + v1 = ((BMLoop*)(l->prev))->v; v2 = l->v; - v3 = ((BMLoop*)(l->head.next))->v; + v3 = ((BMLoop*)(l->next))->v; if (BM_Edge_Exist(v1, v3)) isear = 0; @@ -661,9 +662,9 @@ static BMLoop *find_ear(BMesh *bm, BMFace *f, float (*verts)[3], bestear = l; break; } - l = (BMLoop*)(l->head.next); + l = (BMLoop*)(l->next); } - while(l != f->loopbase); + while(l != bm_firstfaceloop(f)); return bestear; } @@ -693,13 +694,13 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], /*copy vertex coordinates to vertspace array*/ i = 0; - l = f->loopbase; + l = bm_firstfaceloop(f); do{ VECCOPY(projectverts[i], l->v->co); l->v->head.eflag2 = i; /*warning, abuse! never duplicate in tools code! never you hear?*/ /*actually, get rid of this completely, use a new structure for this....*/ i++; - l = (BMLoop*)(l->head.next); - }while(l != f->loopbase); + l = (BMLoop*)(l->next); + }while(l != bm_firstfaceloop(f)); ///bmesh_update_face_normal(bm, f, projectverts); @@ -720,8 +721,8 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], if(l) { done = 0; v = l->v; - f = BM_Split_Face(bm, l->f, ((BMLoop*)(l->head.prev))->v, - ((BMLoop*)(l->head.next))->v, + f = BM_Split_Face(bm, l->f, ((BMLoop*)(l->prev))->v, + ((BMLoop*)(l->next))->v, &newl, NULL); VECCOPY(f->no, l->f->no); @@ -741,15 +742,15 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], f->loopbase = l; break; } - l = l->head.next; + l = l->next; } while (l != f->loopbase);*/ } } if (f->len > 3){ - l = f->loopbase; + l = bm_firstfaceloop(f); while (l->f->len > 3){ - nextloop = ((BMLoop*)(l->head.next->next)); + nextloop = ((BMLoop*)(l->next->next)); f = BM_Split_Face(bm, l->f, l->v, nextloop->v, &newl, NULL); if (!f) { @@ -818,7 +819,7 @@ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) poly_rotate_plane(no, projverts, f->len); poly_rotate_plane(no, edgeverts, len*2); - l = f->loopbase; + l = bm_firstfaceloop(f); for (i=0; ilen; i++) { p1 = projverts[i]; out[0] = MAX2(out[0], p1[0]) + 0.01f; @@ -828,7 +829,7 @@ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) //VECCOPY(l->v->co, p1); - l = (BMLoop*) l->head.next; + l = (BMLoop*) l->next; } for (i=0; itype))\ + printf("check_element failure, with code %i on line %i in file\n \"%s\"\n\n", bmesh_check_element(bm, el, ((BMHeader*)el)->type), __LINE__, __FILE__); + +#define bm_get_edge_link(e, v) (Link*)((v) == ((BMEdge*)(e))->v1 ? &(((BMEdge*)(e))->dlink1) : &(((BMEdge*)(e))->dlink2)) + +int bmesh_radial_length(struct BMLoop *l); +int bmesh_disk_count(BMVert *v); /*start/stop edit*/ void bmesh_begin_edit(struct BMesh *bm); @@ -59,10 +73,14 @@ void bmesh_clear_sysflag(struct BMHeader *element, int flag); int bmesh_test_sysflag(struct BMHeader *element, int flag); /*NOTE: ensure different parts of the API do not conflict - on using this! sets and gets the API index member - of the current flag layer.*/ -#define bmesh_api_seti(bm, head, i) ((head)->flags[bm->stackdepth-1].pflag = i) -#define bmesh_api_geti(bm, head) ((head)->flags[bm->stackdepth-1].pflag) + on using these internal flags!*/ +#define _FLAG_JF 1 /*join faces*/ +#define _FLAG_SF 2 /*split faces*/ +#define _FLAG_MF 4 /*make face*/ + +#define bmesh_api_setflag(element, f) (((BMHeader*)(element))->flags[0].pflag |= (f)) +#define bmesh_api_getflag(element, f) (((BMHeader*)(element))->flags[0].pflag & (f)) +#define bmesh_api_clearflag(element, f) (((BMHeader*)(element))->flags[0].pflag &= ~(f)) /*Polygon Utilities ? FIXME... where do these each go?*/ /*newedgeflag sets a flag layer flag, obviously not the header flag.*/ @@ -77,6 +95,9 @@ void bmesh_flip_normal(struct BMesh *bm, struct BMFace *f); /*Error reporting. Shouldnt be called by tools ever.*/ void BME_error(void); +BMEdge *bmesh_disk_next(BMEdge *e, BMVert *v); +BMEdge *bmesh_disk_prev(BMEdge *e, BMVert *v); + /*include the rest of our private declarations*/ #include "bmesh_structure.h" #include "bmesh_operators_private.h" diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index f7bf4188fad..6365482541c 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -8,6 +8,8 @@ #include "BKE_utildefines.h" +#define BM_OVERLAP (1<<13) + /* * BM_QUERIES.C * @@ -61,16 +63,16 @@ int BM_Vert_In_Edge(BMEdge *e, BMVert *v) BMLoop *BM_OtherFaceLoop(BMEdge *e, BMFace *f, BMVert *v) { - BMLoop *l = f->loopbase, *l2, *l3; + BMLoop *l = bm_firstfaceloop(f), *l2, *l3; int found = 0; do { if (l->e == e) break; found = 1; - l = l->head.next; - } while (l != f->loopbase); + l = l->next; + } while (l != bm_firstfaceloop(f)); - return l->v == v ? l->head.prev : l->head.next; + return l->v == v ? l->prev : l->next; } /* @@ -83,13 +85,17 @@ BMLoop *BM_OtherFaceLoop(BMEdge *e, BMFace *f, BMVert *v) int BM_Vert_In_Face(BMFace *f, BMVert *v) { + BMLoopList *lst; BMLoop *l; - l = f->loopbase; - do{ - if(l->v == v) return 1; - l = ((BMLoop*)(l->head.next)); - }while(l != f->loopbase); + for (lst=f->loops.first; lst; lst=lst->next) { + l = lst->first; + do { + if(l->v == v) return 1; + l = l->next; + } while (l != lst->first); + } + return 0; } @@ -102,16 +108,22 @@ int BM_Vert_In_Face(BMFace *f, BMVert *v) */ int BM_Verts_In_Face(BMesh *bm, BMFace *f, BMVert **varr, int len) { + BMLoopList *lst; BMLoop *curloop = NULL; int i, count = 0; for(i=0; i < len; i++) BMO_SetFlag(bm, varr[i], BM_OVERLAP); + + for (lst=f->loops.first; lst; lst=lst->next) { + curloop = lst->first; - curloop = f->loopbase; - do{ - if(BMO_TestFlag(bm, curloop->v, BM_OVERLAP)) count++; - curloop = (BMLoop*)(curloop->head.next); - } while(curloop != f->loopbase); + do { + if(BMO_TestFlag(bm, curloop->v, BM_OVERLAP)) + count++; + + curloop = curloop->next; + } while (curloop != lst->first); + } for(i=0; i < len; i++) BMO_ClearFlag(bm, varr[i], BM_OVERLAP); @@ -130,12 +142,12 @@ int BM_Edge_In_Face(BMFace *f, BMEdge *e) { BMLoop *l; - l = f->loopbase; + l = bm_firstfaceloop(f); do{ if(l->e == e) return 1; - l = ((BMLoop*)(l->head.next)); - }while(l != f->loopbase); + l = ((BMLoop*)(l->next)); + }while(l != bm_firstfaceloop(f)); return 0; } @@ -166,39 +178,6 @@ BMVert *BM_OtherEdgeVert(BMEdge *e, BMVert *v) return bmesh_edge_getothervert(e,v); } -/** - * BMESH EDGE EXIST - * - * Finds out if two vertices already have an edge - * connecting them. Note that multiple edges may - * exist between any two vertices, and therefore - * This function only returns the first one found. - * - * Returns - - * BMEdge pointer - */ - -BMEdge *BM_Edge_Exist(BMVert *v1, BMVert *v2) -{ - BMNode *diskbase; - BMEdge *curedge; - int i, len=0; - - if (!v1 || !v2 || v1 == v2) - return NULL; - - if(v1->edge){ - diskbase = bmesh_disk_getpointer(v1->edge,v1); - len = bmesh_cycle_length(diskbase); - - for(i=0,curedge=v1->edge;iedge->v1) return bmesh_cycle_length(&v->edge->d1); - else return bmesh_cycle_length(&v->edge->d2); + return bmesh_disk_count(v); } /** @@ -222,12 +200,12 @@ int BM_Edge_FaceCount(BMEdge *e) int count = 0; BMLoop *curloop = NULL; - if(e->loop){ - curloop = e->loop; + if(e->l){ + curloop = e->l; do{ count++; curloop = bmesh_radial_nextloop(curloop); - }while(curloop != e->loop); + }while(curloop != e->l); } return count; @@ -251,12 +229,12 @@ int BM_Vert_FaceCount(BMVert *v){ #if 0 //this code isn't working BMEdge *curedge = NULL; - if(v->edge){ - curedge = v->edge; + if(v->e){ + curedge = v->e; do{ - if(curedge->loop) count += BM_Edge_FaceCount(curedge); + if(curedge->l) count += BM_Edge_FaceCount(curedge); curedge = bmesh_disk_nextedge(curedge,v); - }while(curedge != v->edge); + }while(curedge != v->e); } return count; #endif @@ -276,13 +254,13 @@ int BM_Wire_Vert(BMesh *bm, BMVert *v) { BMEdge *curedge; - if(!(v->edge)) return 0; + if(!(v->e)) return 0; - curedge = v->edge; + curedge = v->e; do{ - if(curedge->loop) return 0; + if(curedge->l) return 0; curedge = bmesh_disk_nextedge(curedge, v); - }while(curedge != v->edge); + }while(curedge != v->e); return 1; } @@ -299,7 +277,7 @@ int BM_Wire_Vert(BMesh *bm, BMVert *v) int BM_Wire_Edge(BMesh *bm, BMEdge *e) { - if(e->loop) return 0; + if(e->l) return 0; return 1; } @@ -321,20 +299,20 @@ int BM_Nonmanifold_Vert(BMesh *bm, BMVert *v) { BMLoop *l; int len, count, flag; - if (v->edge == NULL) { + if (v->e == NULL) { /* loose vert */ return 1; } /* count edges while looking for non-manifold edges */ - oe = v->edge; - for (len=0,e=v->edge; e != oe || (e == oe && len == 0); len++,e=bmesh_disk_nextedge(e,v)) { - if (e->loop == NULL) { + oe = v->e; + for (len=0,e=v->e; e != oe || (e == oe && len == 0); len++,e=bmesh_disk_nextedge(e,v)) { + if (e->l == NULL) { /* loose edge */ return 1; } - if (bmesh_cycle_length(&(e->loop->radial)) > 2) { + if (bmesh_radial_length(e->l) > 2) { /* edge shared by more than two faces */ return 1; } @@ -343,28 +321,28 @@ int BM_Nonmanifold_Vert(BMesh *bm, BMVert *v) { count = 1; flag = 1; e = NULL; - oe = v->edge; - l = oe->loop; + oe = v->e; + l = oe->l; while(e != oe) { - if (l->v == v) l = ((BMLoop*)(l->head.prev)); - else l = ((BMLoop*)(l->head.next)); + if (l->v == v) l = ((BMLoop*)(l->prev)); + else l = ((BMLoop*)(l->next)); e = l->e; count++; /* count the edges */ - if (flag && l->radial.next->data == l) { + if (flag && l->radial_next == l) { /* we've hit the edge of an open mesh, reset once */ flag = 0; count = 1; oe = e; e = NULL; - l = oe->loop; + l = oe->l; } - else if (l->radial.next->data == l) { + else if (l->radial_next == l) { /* break the loop */ e = oe; } else { - l = l->radial.next->data; + l = l->radial_next; } } @@ -427,11 +405,11 @@ int BM_Face_Sharededges(BMFace *f1, BMFace *f2){ BMLoop *l; int count = 0; - l = f1->loopbase; + l = bm_firstfaceloop(f1); do{ if(bmesh_radial_find_face(l->e,f2)) count++; - l = ((BMLoop*)(l->head.next)); - }while(l != f1->loopbase); + l = ((BMLoop*)(l->next)); + }while(l != bm_firstfaceloop(f1)); return count; } @@ -449,15 +427,15 @@ int BM_Edge_Share_Faces(BMEdge *e1, BMEdge *e2) BMLoop *l; BMFace *f; - if(e1->loop && e2->loop){ - l = e1->loop; + if(e1->l && e2->l){ + l = e1->l; do{ f = l->f; if(bmesh_radial_find_face(e2,f)){ return 1; } - l = (BMLoop*)(l->radial.next->data); - }while(l != e1->loop); + l = (BMLoop*)(l->radial_next); + }while(l != e1->l); } return 0; } @@ -482,8 +460,8 @@ float BM_Face_Angle(BMesh *bm, BMEdge *e) radlen = BM_Edge_FaceCount(e); if(radlen == 2){ - l1 = e->loop; - l2 = e->loop->radial.next->data; + l1 = e->l; + l2 = e->l->radial_next; edge_angle_cos = INPR(l1->f->no, l2->f->no); } return edge_angle_cos; diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index 664e07f805b..0d6e69dc18a 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -33,6 +33,10 @@ */ #include +#include +#include +#include + #include "MEM_guardedalloc.h" #include "DNA_listBase.h" @@ -63,169 +67,23 @@ BMVert *bmesh_edge_getothervert(BMEdge *e, BMVert *v){ return NULL; } -int bmesh_edge_swapverts(BMEdge *e, BMVert *orig, BMVert *new){ +int bmesh_edge_swapverts(BMEdge *e, BMVert *orig, BMVert *newv){ if(e->v1 == orig){ - e->v1 = new; - e->d1.next = NULL; - e->d1.prev = NULL; + e->v1 = newv; + e->dlink1.next = e->dlink1.prev = NULL; return 1; } else if(e->v2 == orig){ - e->v2 = new; - e->d2.next = NULL; - e->d2.prev = NULL; + e->v2 = newv; + e->dlink2.next = e->dlink2.prev = NULL; return 1; } return 0; } -/** - * ALLOCATION/DEALLOCATION FUNCTIONS - */ - -BMVert *bmesh_addvertlist(BMesh *bm, BMVert *example){ - BMVert *v=NULL; - v = BLI_mempool_calloc(bm->vpool); - v->head.next = v->head.prev = NULL; - v->head.flag = 0; - v->head.EID = bm->nextv; - v->head.type = BM_VERT; - v->co[0] = v->co[1] = v->co[2] = 0.0f; - v->no[0] = v->no[1] = v->no[2] = 0.0f; - v->edge = NULL; - v->head.data = NULL; - v->bweight = 0.0f; - BLI_addtail(&(bm->verts), &(v->head)); - bm->nextv++; - bm->totvert++; - - if(example){ - VECCOPY(v->co,example->co); - CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, example->head.data, &v->head.data); - } - else - CustomData_bmesh_set_default(&bm->vdata, &v->head.data); - - /*allocate flags*/ - v->head.flags = BLI_mempool_calloc(bm->flagpool); - - return v; -} -BMEdge *bmesh_addedgelist(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge *example){ - BMEdge *e=NULL; - e = BLI_mempool_calloc(bm->epool); - e->head.next = e->head.prev = NULL; - e->head.EID = bm->nexte; - e->head.type = BM_EDGE; - e->head.flag = 0; - e->v1 = v1; - e->v2 = v2; - e->d1.next = e->d1.prev = e->d2.next = e->d2.prev = NULL; - e->d1.data = e; - e->d2.data = e; - e->loop = NULL; - e->head.data = NULL; - e->crease = e->bweight = 0.0f; - bm->nexte++; - bm->totedge++; - BLI_addtail(&(bm->edges), &(e->head)); - - if(example) - CustomData_bmesh_copy_data(&bm->edata, &bm->edata, example->head.data, &e->head.data); - else - CustomData_bmesh_set_default(&bm->edata, &e->head.data); - - /*allocate flags*/ - e->head.flags = BLI_mempool_calloc(bm->flagpool); - - return e; -} -BMLoop *bmesh_create_loop(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, BMLoop *example){ - BMLoop *l=NULL; - l = BLI_mempool_calloc(bm->lpool); - l->head.next = l->head.prev = NULL; - l->head.EID = bm->nextl; - l->head.type = BM_LOOP; - l->head.flag = 0; - l->radial.next = l->radial.prev = NULL; - l->radial.data = l; - l->v = v; - l->e = e; - l->f = f; - l->head.data = NULL; - bm->nextl++; - bm->totloop++; - - if(example) - CustomData_bmesh_copy_data(&bm->ldata, &bm->ldata, example->head.data, &l->head.data); - else - CustomData_bmesh_set_default(&bm->ldata, &l->head.data); - - return l; -} - -BMFace *bmesh_addpolylist(BMesh *bm, BMFace *example){ - BMFace *f = NULL; - f = BLI_mempool_calloc(bm->ppool); - f->head.flag = 0; - f->head.next = f->head.prev = NULL; - f->head.EID = bm->nextp; - f->head.type = BM_FACE; - f->loopbase = NULL; - f->len = 0; - f->head.data = NULL; - f->mat_nr = 0; - BLI_addtail(&(bm->polys),&(f->head)); - bm->nextp++; - bm->totface++; - - if(example) - CustomData_bmesh_copy_data(&bm->pdata, &bm->pdata, example->head.data, &f->head.data); - else - CustomData_bmesh_set_default(&bm->pdata, &f->head.data); - - /*allocate flags*/ - f->head.flags = BLI_mempool_calloc(bm->flagpool); - - return f; -} - -/* free functions dont do much *yet*. When per-vertex, per-edge and per-face/faceloop - data is added though these will be needed. -*/ -void bmesh_free_vert(BMesh *bm, BMVert *v){ - bm->totvert--; - BM_remove_selection(bm, v); - - CustomData_bmesh_free_block(&bm->vdata, &v->head.data); - BLI_mempool_free(bm->flagpool, v->head.flags); - BLI_mempool_free(bm->vpool, v); -} -void bmesh_free_edge(BMesh *bm, BMEdge *e){ - bm->totedge--; - BM_remove_selection(bm, e); - - CustomData_bmesh_free_block(&bm->edata, &e->head.data); - BLI_mempool_free(bm->flagpool, e->head.flags); - BLI_mempool_free(bm->epool, e); -} -void bmesh_free_poly(BMesh *bm, BMFace *f){ - if (f == bm->act_face) - bm->act_face = NULL; - BM_remove_selection(bm, f); - - bm->totface--; - CustomData_bmesh_free_block(&bm->pdata, &f->head.data); - BLI_mempool_free(bm->flagpool, f->head.flags); - BLI_mempool_free(bm->ppool, f); -} -void bmesh_free_loop(BMesh *bm, BMLoop *l){ - bm->totloop--; - CustomData_bmesh_free_block(&bm->ldata, &l->head.data); - BLI_mempool_free(bm->lpool, l); -} /** * BMESH CYCLES + * (this is somewhat outdate, though bits of its API are still used) - joeedh * * Cycles are circular doubly linked lists that form the basis of adjacency * information in the BME modeller. Full adjacency relations can be derived @@ -262,7 +120,7 @@ void bmesh_free_loop(BMesh *bm, BMLoop *l){ * bmesh_disk_getpointer * * 2: The Radial Cycle - A circle of face edges (bmesh_Loop) around an edge - * Base: edge->loop->radial structure. + * Base: edge->l->radial structure. * * The radial cycle is similar to the radial cycle in the radial edge data structure.* * Unlike the radial edge however, the radial cycle does not require a large amount of memory @@ -278,7 +136,7 @@ void bmesh_free_loop(BMesh *bm, BMLoop *l){ * * * 3: The Loop Cycle - A circle of face edges around a polygon. - * Base: polygon->loopbase. + * Base: polygon->lbase. * * The loop cycle keeps track of a faces vertices and edges. It should be noted that the * direction of a loop cycle is either CW or CCW depending on the face normal, and is @@ -295,9 +153,307 @@ void bmesh_free_loop(BMesh *bm, BMLoop *l){ * cycle order and all non-manifold conditions are represented trivially. * */ - - -void bmesh_cycle_append(void *h, void *nt) +int bmesh_disk_append_edge(struct BMEdge *e, struct BMVert *v) +{ + if (!v->e) { + Link *e1 = bm_get_edge_link(e, v); + + v->e = e; + e1->next = e1->prev = (Link*)e; + } else { + Link *e1, *e2, *e3; + + e1 = bm_get_edge_link(e, v); + e2 = bm_get_edge_link(v->e, v); + e3 = e2->prev ? bm_get_edge_link(e2->prev, v) : NULL; + + e1->next = (Link*)v->e; + e1->prev = e2->prev; + + e2->prev = (Link*)e; + if (e3) + e3->next = (Link*)e; + } + + return 1; +} + +void bmesh_disk_remove_edge(struct BMEdge *e, struct BMVert *v) +{ + Link *e1, *e2; + + e1 = bm_get_edge_link(e, v); + if (e1->prev) { + e2 = bm_get_edge_link(e1->prev, v); + e2->next = e1->next; + } + + if (e1->next) { + e2 = bm_get_edge_link(e1->next, v); + e2->prev = e1->prev; + } + + if (v->e == e) + v->e = e!=e1->next ? (BMEdge*)e1->next : NULL; + + e1->next = e1->prev = NULL; +} + +struct BMEdge *bmesh_disk_nextedge(struct BMEdge *e, struct BMVert *v) +{ + if (v == e->v1) + return e->dlink1.next; + if (v == e->v2) + return e->dlink2.next; + return NULL; +} + +BMEdge *bmesh_disk_prevedge(BMEdge *e, BMVert *v) +{ + if (v == e->v1) + return e->dlink1.prev; + if (v == e->v2) + return e->dlink2.prev; + return NULL; +} + +int bmesh_disk_count(struct BMVert *v) +{ + BMEdge *e = v->e; + int i=0; + + if (!e) + return 0; + + do { + if (!e) + return 0; + e = bmesh_disk_nextedge(e, v); + + if (i >= (1<<20)) { + printf("bmesh error: infinite loop in disk cycle!\n"); + return 0; + } + + i += 1; + } while (e != v->e); + + return i; +} + +int bmesh_disk_validate(int len, BMEdge *e, BMVert *v) +{ + BMEdge *e2; + + if (!BM_Vert_In_Edge(e, v)) + return 0; + if (bmesh_disk_count(v) != len || len == 0) + return 0; + + e2 = e; + do { + if (len!=1 && bmesh_disk_prevedge(e2, v) == e2) + return 0; + + e2 = bmesh_disk_nextedge(e2, v); + } while (e2 != e); + + return 1; +} + +/* + * BME DISK COUNT FACE VERT + * + * Counts the number of loop users + * for this vertex. Note that this is + * equivalent to counting the number of + * faces incident upon this vertex + * +*/ + +int bmesh_disk_count_facevert(BMVert *v) +{ + BMEdge *curedge; + int count = 0; + + /*is there an edge on this vert at all?*/ + if(!v->e) + return count; + + /*first, loop around edges*/ + curedge = v->e; + do{ + if(curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); + curedge = bmesh_disk_nextedge(curedge, v); + }while(curedge != v->e); + + return count; +} + +struct BMEdge *bmesh_disk_find_first_faceedge(struct BMEdge *e, struct BMVert *v) +{ + BMEdge *searchedge = NULL; + searchedge = e; + do{ + if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; + searchedge = bmesh_disk_nextedge(searchedge,v); + }while(searchedge != e); + + return NULL; +} + +struct BMEdge *bmesh_disk_find_next_faceedge(struct BMEdge *e, struct BMVert *v) +{ + BMEdge *searchedge = NULL; + searchedge = bmesh_disk_nextedge(e,v); + do{ + if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; + searchedge = bmesh_disk_nextedge(searchedge,v); + }while(searchedge !=e); + return e; +} + +/*****radial cycle functions, e.g. loops surrounding edges******/ +int bmesh_radial_validate(int radlen, BMLoop *l) +{ + BMLoop *l2 = l; + + if (bmesh_radial_length(l) != radlen) + return 0; + + do { + if (l2->e != l->e) + return 0; + if (l2->v != l->e->v1 && l2->v != l->e->v2) + return 0; + + l2 = l2->radial_next; + } while (l2 != l); + + return 1; +} + +void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e) +{ + if (l->radial_next != l) { + if (e && l == e->l) + e->l = l->radial_next; + + l->radial_next->radial_prev = l->radial_prev; + l->radial_prev->radial_next = l->radial_next; + } else { + l->radial_next = l->radial_prev = NULL; + if (e && l == e->l) + e->l = NULL; + else if (e) + bmesh_error(); + } +} + + +/* + * BME RADIAL FIND FIRST FACE VERT + * + * Finds the first loop of v around radial + * cycle + * +*/ +BMLoop *bmesh_radial_find_first_facevert(BMLoop *l, BMVert *v) +{ + BMLoop *curloop; + curloop = l; + do{ + if(curloop->v == v) return curloop; + curloop = bmesh_radial_nextloop(curloop); + }while(curloop != l); + return NULL; +} + +BMLoop *bmesh_radial_find_next_facevert(BMLoop *l, BMVert *v) +{ + BMLoop *curloop; + curloop = bmesh_radial_nextloop(l); + do{ + if(curloop->v == v) return curloop; + curloop = bmesh_radial_nextloop(curloop); + }while(curloop !=l); + return l; +} + +BMLoop *bmesh_radial_nextloop(BMLoop *l) +{ + return l->radial_next; +} + +int bmesh_radial_length(BMLoop *l) +{ + BMLoop *l2 = l; + int i = 0; + + if (!l) + return 0; + + do { + i++; + l2 = l2->radial_next; + if (i >= 555555) + return -1; + } while (l2 != l); + + return i; +} + +void bmesh_radial_append(BMEdge *e, BMLoop *l){ + if(e->l == NULL) { + e->l = l; + l->radial_next = l->radial_prev = l; + } else { + l->radial_prev = e->l; + l->radial_next = e->l->radial_next; + + if (e->l == e->l->radial_next) + e->l->radial_prev = e->l->radial_next = l; + else + e->l->radial_next = l; + e->l = l; + } +} + +int bmesh_radial_find_face(BMEdge *e, BMFace *f) +{ + BMLoop *curloop; + int i, len; + + len = bmesh_radial_length(e->l); + for(i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next) { + if(curloop->f == f) + return 1; + } + return 0; +} + +/* + * BME RADIAL COUNT FACE VERT + * + * Returns the number of times a vertex appears + * in a radial cycle + * +*/ + +int bmesh_radial_count_facevert(BMLoop *l, BMVert *v) +{ + BMLoop *curloop; + int count = 0; + curloop = l; + do{ + if(curloop->v == v) count++; + curloop = bmesh_radial_nextloop(curloop); + }while(curloop != l); + return count; +} + +#if 0 + void bmesh_cycle_append(void *h, void *nt) { BMNode *oldtail, *head, *newtail; @@ -329,25 +485,26 @@ void bmesh_cycle_append(void *h, void *nt) * Integer */ -int bmesh_cycle_length(void *h){ +int bmesh_cycle_length(BMEdge *e, BMVert *v) { + BMEdge *next, *prev, *cur; + int len, vi = v == e->v1 ? 0 : 1; - int len = 0; - BMNode *head, *curnode; - head = (BMNode*)h; + /*should skip 2 forward if v is 1, happily reduces to + v*2*/ + prev = *(&e->v1_prev + vi*2); - if(head){ - len = 1; - for(curnode = head->next; curnode != head; curnode=curnode->next){ - if(len == INT_MAX){ //check for infinite loop/corrupted cycle - return -1; - } - len++; - } + cur = e; + len = 1; + while (cur != prev) { + vi = cur->v1 == v ? 0 : 1; + + len++; + cur = *(&cur->v1_next + vi*2); } + return len; } - /** * bmesh_cycle_remove * @@ -466,15 +623,15 @@ int bmesh_disk_append_edge(BMEdge *e, BMVert *v) if(bmesh_vert_in_edge(e, v) == 0) return 0; /*check to make sure v is in e*/ /*check for loose vert first*/ - if(v->edge == NULL){ - v->edge = e; + if(v->e == NULL){ + v->e = e; base = tail = bmesh_disk_getpointer(e, v); bmesh_cycle_append(base, tail); /*circular reference is ok!*/ return 1; } - /*insert e at the end of disk cycle and make it the new v->edge*/ - base = bmesh_disk_getpointer(v->edge, v); + /*insert e at the end of disk cycle and make it the new v->e*/ + base = bmesh_disk_getpointer(v->e, v); tail = bmesh_disk_getpointer(e, v); bmesh_cycle_append(base, tail); return 1; @@ -497,18 +654,18 @@ void bmesh_disk_remove_edge(BMEdge *e, BMVert *v) BMEdge *newbase; int len; - base = bmesh_disk_getpointer(v->edge, v); + base = bmesh_disk_getpointer(v->e, v); remnode = bmesh_disk_getpointer(e, v); - /*first deal with v->edge pointer...*/ + /*first deal with v->e pointer...*/ len = bmesh_cycle_length(base); if(len == 1) newbase = NULL; - else if(v->edge == e) newbase = base->next-> data; - else newbase = v->edge; + else if(v->e == e) newbase = base->next-> data; + else newbase = v->e; /*remove and rebase*/ bmesh_cycle_remove(base, remnode); - v->edge = newbase; + v->e = newbase; } /** @@ -560,12 +717,12 @@ int bmesh_disk_count_edgeflag(BMVert *v, int eflag, int tflag) BMEdge *curedge; int i, len=0, count=0; - if(v->edge){ + if(v->e){ if(eflag && tflag) return 0; /*tflag and eflag are reserved for different functions!*/ - diskbase = bmesh_disk_getpointer(v->edge, v); + diskbase = bmesh_disk_getpointer(v->e, v); len = bmesh_cycle_length(diskbase); - for(i = 0, curedge=v->edge; ie; ihead.eflag1 == eflag) count++; } @@ -581,11 +738,11 @@ int bmesh_disk_hasedge(BMVert *v, BMEdge *e){ BMEdge *curedge; int i, len=0; - if(v->edge){ - diskbase = bmesh_disk_getpointer(v->edge,v); + if(v->e){ + diskbase = bmesh_disk_getpointer(v->e,v); len = bmesh_cycle_length(diskbase); - for(i = 0, curedge=v->edge; ie; iedge){ - diskbase = bmesh_disk_getpointer(v1->edge,v1); + if(v1->e){ + diskbase = bmesh_disk_getpointer(v1->e,v1); len = bmesh_cycle_length(diskbase); - for(i=0,curedge=v1->edge;ie;iradial.next->data); + return (BMLoop*)(l->radial_next); } void bmesh_radial_append(BMEdge *e, BMLoop *l){ - if(e->loop == NULL) e->loop = l; - bmesh_cycle_append(&(e->loop->radial), &(l->radial)); + if(e->l == NULL) e->l = l; + bmesh_cycle_append(&(e->l->radial), &(l->radial)); } void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e) @@ -626,15 +783,15 @@ void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e) BMLoop *newbase; int len; - /*deal with edge->loop pointer*/ - len = bmesh_cycle_length(&(e->loop->radial)); + /*deal with edge->l pointer*/ + len = bmesh_cycle_length(&(e->l->radial)); if(len == 1) newbase = NULL; - else if(e->loop == l) newbase = e->loop->radial.next->data; - else newbase = e->loop; + else if(e->l == l) newbase = e->l->radial_next; + else newbase = e->l; /*remove and rebase*/ - bmesh_cycle_remove(&(e->loop->radial), &(l->radial)); - e->loop = newbase; + bmesh_cycle_remove(&(e->l->radial), &(l->radial)); + e->l = newbase; } int bmesh_radial_find_face(BMEdge *e,BMFace *f) @@ -643,8 +800,8 @@ int bmesh_radial_find_face(BMEdge *e,BMFace *f) BMLoop *curloop; int i, len; - len = bmesh_cycle_length(&(e->loop->radial)); - for(i = 0, curloop = e->loop; i < len; i++, curloop = curloop->radial.next->data){ + len = bmesh_cycle_length(&(e->l->radial)); + for(i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next){ if(curloop->f == f) return 1; } return 0; @@ -687,15 +844,15 @@ int bmesh_disk_count_facevert(BMVert *v) int count = 0; /*is there an edge on this vert at all?*/ - if(!v->edge) + if(!v->e) return count; /*first, loop around edges*/ - curedge = v->edge; + curedge = v->e; do{ - if(curedge->loop) count += bmesh_radial_count_facevert(curedge->loop, v); + if(curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); curedge = bmesh_disk_nextedge(curedge, v); - }while(curedge != v->edge); + }while(curedge != v->e); return count; } @@ -746,7 +903,7 @@ BMEdge *bmesh_disk_find_first_faceedge(BMEdge *e, BMVert *v) BMEdge *searchedge = NULL; searchedge = e; do{ - if(searchedge->loop && bmesh_radial_count_facevert(searchedge->loop,v)) return searchedge; + if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; searchedge = bmesh_disk_nextedge(searchedge,v); }while(searchedge != e); @@ -758,7 +915,7 @@ BMEdge *bmesh_disk_find_next_faceedge(BMEdge *e, BMVert *v) BMEdge *searchedge = NULL; searchedge = bmesh_disk_nextedge(e,v); do{ - if(searchedge->loop && bmesh_radial_count_facevert(searchedge->loop,v)) return searchedge; + if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; searchedge = bmesh_disk_nextedge(searchedge,v); }while(searchedge !=e); return e; @@ -772,9 +929,11 @@ struct BMLoop *bmesh_loop_find_loop(struct BMFace *f, struct BMVert *v) { BMLoop *l; int i, len; - len = bmesh_cycle_length(f->loopbase); - for (i = 0, l=f->loopbase; i < len; i++, l=((BMLoop*)(l->head.next)) ) { + len = bmesh_cycle_length(f->lbase); + for (i = 0, l=f->loopbase; i < len; i++, l=((BMLoop*)(l->next)) ) { if (l->v == v) return l; } return NULL; } + +#endif diff --git a/source/blender/bmesh/intern/bmesh_structure.h b/source/blender/bmesh/intern/bmesh_structure.h index ba63bb8f65f..58f7cbc16f2 100644 --- a/source/blender/bmesh/intern/bmesh_structure.h +++ b/source/blender/bmesh/intern/bmesh_structure.h @@ -36,16 +36,13 @@ #ifndef BM_STRUCTURE_H #define BM_STRUCTURE_H -/*ALLOCATION/DEALLOCATION*/ -struct BMVert *bmesh_addvertlist(struct BMesh *bm, struct BMVert *example); -struct BMEdge *bmesh_addedgelist(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge *example); -struct BMFace *bmesh_addpolylist(struct BMesh *bm, struct BMFace *example); -struct BMLoop *bmesh_create_loop(struct BMesh *bm, struct BMVert *v, struct BMEdge *e, struct BMFace *f, struct BMLoop *example); +/*low-level, base bmesh API. in the vast majority of cases thes should not be + used directly. if absolutely necassary, see function defitions in code for + descriptive comments. but seriously, don't use this stuff. +*/ +struct ListBase; -void bmesh_free_vert(struct BMesh *bm, struct BMVert *v); -void bmesh_free_edge(struct BMesh *bm, struct BMEdge *e); -void bmesh_free_poly(struct BMesh *bm, struct BMFace *f); -void bmesh_free_loop(struct BMesh *bm, struct BMLoop *l); +void remove_loop_radial_link(BMLoop *l); /*DOUBLE CIRCULAR LINKED LIST FUNCTIONS*/ void bmesh_cycle_append(void *h, void *nt); @@ -70,16 +67,18 @@ struct BMLoop *bmesh_radial_nextloop(struct BMLoop *l); int bmesh_radial_count_facevert(struct BMLoop *l, struct BMVert *v); struct BMLoop *bmesh_radial_find_first_facevert(struct BMLoop *l, struct BMVert *v); struct BMLoop *bmesh_radial_find_next_facevert(struct BMLoop *l, struct BMVert *v); +int bmesh_radial_validate(int radlen, struct BMLoop *l); /*EDGE UTILITIES*/ int bmesh_vert_in_edge(struct BMEdge *e, struct BMVert *v); int bmesh_verts_in_edge(struct BMVert *v1, struct BMVert *v2, struct BMEdge *e); -int bmesh_edge_swapverts(struct BMEdge *e, struct BMVert *orig, struct BMVert *new); /*relink edge*/ +int bmesh_edge_swapverts(struct BMEdge *e, struct BMVert *orig, struct BMVert *newv); /*relink edge*/ struct BMVert *bmesh_edge_getothervert(struct BMEdge *e, struct BMVert *v); int bmesh_disk_hasedge(struct BMVert *v, struct BMEdge *e); struct BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2); struct BMEdge *bmesh_disk_next_edgeflag(struct BMEdge *e, struct BMVert *v, int eflag, int tflag); int bmesh_disk_count_edgeflag(struct BMVert *v, int eflag, int tflag); +int bmesh_disk_validate(int len, struct BMEdge *e, struct BMVert *v); /*EULER API - For modifying structure*/ struct BMVert *bmesh_mv(struct BMesh *bm, float *vec); @@ -89,10 +88,11 @@ int bmesh_kv(struct BMesh *bm, struct BMVert *v); int bmesh_ke(struct BMesh *bm, struct BMEdge *e); int bmesh_kf(struct BMesh *bm, struct BMFace *bply); struct BMVert *bmesh_semv(struct BMesh *bm, struct BMVert *tv, struct BMEdge *e, struct BMEdge **re); -struct BMFace *bmesh_sfme(struct BMesh *bm, struct BMFace *f, struct BMVert *v1, struct BMVert *v2, struct BMLoop **rl); +struct BMFace *bmesh_sfme(struct BMesh *bm, struct BMFace *f, struct BMVert *v1, + struct BMVert *v2, struct BMLoop **rl, struct ListBase *holes); int bmesh_jekv(struct BMesh *bm, struct BMEdge *ke, struct BMVert *kv); int bmesh_loop_reverse(struct BMesh *bm, struct BMFace *f); -struct BMFace *bmesh_jfke(struct BMesh *bm, struct BMFace *f1, BMFace *f2, BMEdge *e); +struct BMFace *bmesh_jfke(struct BMesh *bm, struct BMFace *f1, struct BMFace *f2, struct BMEdge *e); struct BMVert *bmesh_urmv(struct BMesh *bm, struct BMFace *sf, struct BMVert *sv); //int *bmesh_grkv(struct BMesh *bm, struct BMFace *sf, struct BMVert *kv); diff --git a/source/blender/bmesh/intern/bmesh_to_editmesh.c b/source/blender/bmesh/intern/bmesh_to_editmesh.c index 6f43df4d75b..67b47064e68 100644 --- a/source/blender/bmesh/intern/bmesh_to_editmesh.c +++ b/source/blender/bmesh/intern/bmesh_to_editmesh.c @@ -67,8 +67,8 @@ static void loops_to_editmesh_corners(BMesh *bm, CustomData *facedata, void *fac texface->uv[j][0] = mloopuv->uv[0]; texface->uv[j][1] = mloopuv->uv[1]; j++; - l = ((BMLoop*)(l->head.next)); - } while(l!=f->loopbase); + l = ((BMLoop*)(l->next)); + } while(l!=f->lbase); } @@ -83,8 +83,8 @@ static void loops_to_editmesh_corners(BMesh *bm, CustomData *facedata, void *fac mcol[j].b = mloopcol->b; mcol[j].a = mloopcol->a; j++; - l = ((BMLoop*)(l->head.next)); - } while(l!=f->loopbase); + l = ((BMLoop*)(l->next)); + } while(l!=f->lbase); } } @@ -146,11 +146,11 @@ static EditFace *bmeshface_to_editface(BMesh *bm, EditMesh *em, BMFace *f, EditV len = f->len; - eve1= evlist[f->loopbase->v->head.eflag1]; - eve2= evlist[((BMLoop*)(f->loopbase->head.next))->v->head.eflag1]; - eve3= evlist[((BMLoop*)(f->loopbase->head.next->next))->v->head.eflag1]; + eve1= evlist[f->lbase->v->head.eflag1]; + eve2= evlist[((BMLoop*)(f->lbase->next))->v->head.eflag1]; + eve3= evlist[((BMLoop*)(f->lbase->next->next))->v->head.eflag1]; if (len == 4) { - eve4= evlist[ ((BMLoop*)(f->loopbase->head.prev))->v->head.eflag1]; + eve4= evlist[ ((BMLoop*)(f->lbase->prev))->v->head.eflag1]; } else { eve4= NULL; @@ -162,11 +162,11 @@ static EditFace *bmeshface_to_editface(BMesh *bm, EditMesh *em, BMFace *f, EditV efa = addfacelist(em, eve1, eve2, eve3, eve4, NULL, NULL); if (!efa) return NULL; - bmeshedge_to_editedge_internal(bm, em, f->loopbase->e, efa->e1); - bmeshedge_to_editedge_internal(bm, em, ((BMLoop*)(f->loopbase->head.next))->e, efa->e2); - bmeshedge_to_editedge_internal(bm, em, ((BMLoop*)(f->loopbase->head.next->next))->e, efa->e3); + bmeshedge_to_editedge_internal(bm, em, f->lbase->e, efa->e1); + bmeshedge_to_editedge_internal(bm, em, ((BMLoop*)(f->lbase->next))->e, efa->e2); + bmeshedge_to_editedge_internal(bm, em, ((BMLoop*)(f->lbase->next->next))->e, efa->e3); if(eve4) - bmeshedge_to_editedge_internal(bm, em, ((BMLoop*)(f->loopbase->head.prev))->e, efa->e4); + bmeshedge_to_editedge_internal(bm, em, ((BMLoop*)(f->lbase->prev))->e, efa->e4); efa->mat_nr = (unsigned char)f->mat_nr; @@ -269,8 +269,8 @@ void bmesh_make_fgons_exec(BMesh *bmesh, BMOperator *op) if (trifan) { while (face->len > 4) { face = BM_Split_Face(bmesh, face, - face->loopbase->v, - ((BMLoop*)face->loopbase->head.next->next)->v, + face->lbase->v, + ((BMLoop*)face->lbase->next->next)->v, &nl, NULL); BM_SetHFlag(nl->e, BM_FGON); } diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c index 4b870f547e7..f57ebddb649 100644 --- a/source/blender/bmesh/intern/bmesh_walkers.c +++ b/source/blender/bmesh/intern/bmesh_walkers.c @@ -212,7 +212,7 @@ void BMW_Init(BMWalker *walker, BMesh *bm, int type, int searchmask, int flag) default: break; } - walker->stack = BLI_mempool_create(size, 100, 100, 1); + walker->stack = BLI_mempool_create(size, 100, 100, 1, 0); walker->currentstate = NULL; } @@ -321,7 +321,7 @@ static void shellWalker_begin(BMWalker *walker, void *data){ BMVert *v = data; shellWalker *shellWalk = NULL; - if (!v->edge) + if (!v->e) return; if (walker->restrictflag) { @@ -330,7 +330,7 @@ static void shellWalker_begin(BMWalker *walker, void *data){ break; } } else { - e = v->edge; + e = v->e; } if (!e) @@ -490,7 +490,7 @@ static void *islandboundWalker_step(BMWalker *walker) f = l->f; e = l->e; if(!BMO_TestFlag(walker->bm, f, walker->restrictflag)){ - l = l->radial.next->data; + l = l->radial_next; break; } } else { @@ -509,7 +509,7 @@ static void *islandboundWalker_step(BMWalker *walker) iwalk->base = owalk.base; //if (!BMO_TestFlag(walker->bm, l->f, walker->restrictflag)) - // iwalk->curloop = l->radial.next->data; + // iwalk->curloop = l->radial_next; iwalk->curloop = l; //else iwalk->curloop = l; iwalk->lastv = v; @@ -651,7 +651,7 @@ static void *loopWalker_step(BMWalker *walker) BMW_popstate(walker); rlen = owalk.startrad; - l = e->loop; + l = e->l; if (!l) return owalk.cur; @@ -680,7 +680,7 @@ static void *loopWalker_step(BMWalker *walker) if (!l) return owalk.cur; - if (l != e->loop && !BLI_ghash_haskey(walker->visithash, l->e)) { + if (l != e->l && !BLI_ghash_haskey(walker->visithash, l->e)) { if (!(rlen != 1 && i != stopi)) { BMW_pushstate(walker); lwalk = walker->currentstate; @@ -701,10 +701,10 @@ static void faceloopWalker_begin(BMWalker *walker, void *data) BMW_pushstate(walker); - if (!e->loop) return; + if (!e->l) return; lwalk = walker->currentstate; - lwalk->l = e->loop; + lwalk->l = e->l; lwalk->nocalc = 0; BLI_ghash_insert(walker->visithash, lwalk->l->f, NULL); @@ -741,18 +741,18 @@ static void *faceloopWalker_step(BMWalker *walker) BMW_popstate(walker); - l = l->radial.next->data; + l = l->radial_next; if (lwalk->nocalc) return f; if (BLI_ghash_haskey(walker->visithash, l->f)) { l = lwalk->l; - l = l->head.next->next; - if (l == l->radial.next->data) { - l = l->head.prev->prev; + l = l->next->next; + if (l == l->radial_next) { + l = l->prev->prev; } - l = l->radial.next->data; + l = l->radial_next; } if (!BLI_ghash_haskey(walker->visithash, l->f)) { @@ -777,12 +777,12 @@ static void edgeringWalker_begin(BMWalker *walker, void *data) edgeringWalker *lwalk, owalk; BMEdge *e = data; - if (!e->loop) return; + if (!e->l) return; BMW_pushstate(walker); lwalk = walker->currentstate; - lwalk->l = e->loop; + lwalk->l = e->l; BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL); /*rewind*/ @@ -796,7 +796,7 @@ static void edgeringWalker_begin(BMWalker *walker, void *data) *lwalk = owalk; if (lwalk->l->f->len != 4) - lwalk->l = lwalk->l->radial.next->data; + lwalk->l = lwalk->l->radial_next; BLI_ghash_free(walker->visithash, NULL, NULL); walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); @@ -820,11 +820,11 @@ static void *edgeringWalker_step(BMWalker *walker) BMW_popstate(walker); - l = l->radial.next->data; - l = l->head.next->next; + l = l->radial_next; + l = l->next->next; if (l->f->len != 4) { - l = lwalk->l->head.next->next; + l = lwalk->l->next->next; } if (l->f->len == 4 && !BLI_ghash_haskey(walker->visithash, l->e)) { @@ -870,7 +870,7 @@ static void *uvedgeWalker_step(BMWalker *walker) int i, j, rlen, type; l = lwalk->l; - nl = l->head.next; + nl = l->next; type = walker->bm->ldata.layers[walker->flag].type; BMW_popstate(walker); @@ -879,7 +879,7 @@ static void *uvedgeWalker_step(BMWalker *walker) return l; /*go over loops around l->v and nl->v and see which ones share l and nl's - mloopuv's coordinates. in addition, push on l->head.next if necassary.*/ + mloopuv's coordinates. in addition, push on l->next if necassary.*/ for (i=0; i<2; i++) { cl = i ? nl : l; BM_ITER(l2, &liter, walker->bm, BM_LOOPS_OF_VERT, cl->v) { @@ -896,7 +896,7 @@ static void *uvedgeWalker_step(BMWalker *walker) continue; } - l3 = l2->v != cl->v ? (BMLoop*)l2->head.next : l2; + l3 = l2->v != cl->v ? (BMLoop*)l2->next : l2; d2 = CustomData_bmesh_get_layer_n(&walker->bm->ldata, l3->head.data, walker->flag); @@ -909,7 +909,7 @@ static void *uvedgeWalker_step(BMWalker *walker) lwalk->l = l2; - l2 = l2->radial.next->data; + l2 = l2->radial_next; } } } diff --git a/source/blender/bmesh/intern/editmesh_to_bmesh.c b/source/blender/bmesh/intern/editmesh_to_bmesh.c index a2a37639670..77f421e7287 100644 --- a/source/blender/bmesh/intern/editmesh_to_bmesh.c +++ b/source/blender/bmesh/intern/editmesh_to_bmesh.c @@ -261,7 +261,7 @@ static void fuse_fgon(BMesh *bm, BMFace *f) if (l->f->head.flag & BM_ACTIVE) act = BM_ACTIVE; if (((BMLoop*)l->radial.next->data)->f->head.flag & BM_ACTIVE) act = BM_ACTIVE; - sf = BM_Join_Faces(bm,l->f, ((BMLoop*)l->radial.next->data)->f, l->e); + sf = BM_Join_TwoFaces(bm,l->f, ((BMLoop*)l->radial.next->data)->f, l->e); if (!sf) { //tesselation error break; @@ -275,7 +275,7 @@ static void fuse_fgon(BMesh *bm, BMFace *f) return; } } - l = ((BMLoop*)(l->head.next)); + l = ((BMLoop*)(l->next)); }while(l != sf->loopbase); } } @@ -293,7 +293,7 @@ static BM_fgonconvert(BMesh *bm, BMOperator *op, EditMesh *em, int numCol, int n f = editface_to_BMFace(bm, em, efa, numCol, numTex); } - for (f=bm->polys.first; f; f=f->head.next) { + for (f=bm->polys.first; f; f=f->next) { fuse_fgon(bm, f); } diff --git a/source/blender/bmesh/operators/bmesh_dupeops.c b/source/blender/bmesh/operators/bmesh_dupeops.c index 8d650a01511..9abdc763c98 100644 --- a/source/blender/bmesh/operators/bmesh_dupeops.c +++ b/source/blender/bmesh/operators/bmesh_dupeops.c @@ -519,7 +519,7 @@ static void delete_context(BMesh *bm, int type){ delete_edges(bm); /*remove loose vertices*/ for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)){ - if(BMO_TestFlag(bm, (BMHeader*)v, DEL_INPUT) && (!(v->edge))) + if(BMO_TestFlag(bm, (BMHeader*)v, DEL_INPUT) && (!(v->e))) BMO_SetFlag(bm, (BMHeader*)v, DEL_WIREVERT); } BM_remove_tagged_verts(bm, DEL_WIREVERT); diff --git a/source/blender/bmesh/operators/connectops.c b/source/blender/bmesh/operators/connectops.c index 673b34415ae..22e9d5494f0 100644 --- a/source/blender/bmesh/operators/connectops.c +++ b/source/blender/bmesh/operators/connectops.c @@ -44,8 +44,8 @@ void connectverts_exec(BMesh *bm, BMOperator *op) continue; } - if (lastl != l->head.prev && lastl != - l->head.next) + if (lastl != l->prev && lastl != + l->next) { BLI_array_growone(loops); loops[BLI_array_count(loops)-1] = lastl; diff --git a/source/blender/bmesh/operators/createops.c b/source/blender/bmesh/operators/createops.c index bfc8dd23e93..61e0bcc3085 100644 --- a/source/blender/bmesh/operators/createops.c +++ b/source/blender/bmesh/operators/createops.c @@ -45,8 +45,8 @@ PathBase *edge_pathbase_new(void) { PathBase *pb = MEM_callocN(sizeof(PathBase), "PathBase"); - pb->nodepool = BLI_mempool_create(sizeof(EPathNode), 1, 512, 1); - pb->pathpool = BLI_mempool_create(sizeof(EPath), 1, 512, 1); + pb->nodepool = BLI_mempool_create(sizeof(EPathNode), 1, 512, 1, 0); + pb->pathpool = BLI_mempool_create(sizeof(EPath), 1, 512, 1, 0); return pb; } diff --git a/source/blender/bmesh/operators/dissolveops.c b/source/blender/bmesh/operators/dissolveops.c index f22ce2477a5..625298421ec 100644 --- a/source/blender/bmesh/operators/dissolveops.c +++ b/source/blender/bmesh/operators/dissolveops.c @@ -183,7 +183,7 @@ void dissolvefaces_exec(BMesh *bm, BMOperator *op) cleanup: /*free/cleanup*/ for (i=0; iv1, VERT_MARK); BMO_SetFlag(bm, e->v2, VERT_MARK); - BM_Join_Faces(bm, e->loop->f, - ((BMLoop*)e->loop->radial.next->data)->f, + BM_Join_TwoFaces(bm, e->l->f, + ((BMLoop*)e->l->radial_next)->f, e); } } @@ -223,7 +223,7 @@ void dissolve_edgeloop_exec(BMesh *bm, BMOperator *op) /*clean up extreneous 2-valence vertices*/ for (i=0; iedge, verts[i], 1.0); + BM_Collapse_Vert(bm, verts[i]->e, verts[i], 1.0); } BLI_array_free(verts); @@ -249,8 +249,8 @@ void dissolveedges_exec(BMesh *bm, BMOperator *op) BMO_ITER(e, &oiter, bm, op, "edges", BM_EDGE) { if (BM_Edge_FaceCount(e) == 2) { - BM_Join_Faces(bm, e->loop->f, - ((BMLoop*)e->loop->radial.next->data)->f, + BM_Join_TwoFaces(bm, e->l->f, + ((BMLoop*)e->l->radial_next)->f, e); } } @@ -312,7 +312,7 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) if (BM_Vert_EdgeCount(v) == 2) { /*collapse the vert*/ - BM_Collapse_Vert(bm, v->edge, v, 0.5f); + BM_Collapse_Vert(bm, v->e, v, 0.5f); continue; } diff --git a/source/blender/bmesh/operators/edgesplitop.c b/source/blender/bmesh/operators/edgesplitop.c index ad2722f7a75..e940b3491a0 100644 --- a/source/blender/bmesh/operators/edgesplitop.c +++ b/source/blender/bmesh/operators/edgesplitop.c @@ -135,7 +135,7 @@ void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *op) continue; et = etags + BMINDEX_GET(e); - if (!et->tag && e->loop) { + if (!et->tag && e->l) { break; } } @@ -146,9 +146,9 @@ void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *op) /*ok we found an edge, part of a region of splits we need to identify. now walk along it.*/ for (i=0; i<2; i++) { - l = e->loop; + l = e->l; - v = i ? ((BMLoop*)l->head.next)->v : l->v; + v = i ? ((BMLoop*)l->next)->v : l->v; while (1) { et = etags + BMINDEX_GET(l->e); @@ -177,14 +177,14 @@ void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *op) l = BM_OtherFaceLoop(l->e, l->f, v); if (BM_Edge_FaceCount(l->e) != 2) break; - l = (BMLoop*) l->radial.next->data; + l = (BMLoop*) l->radial_next; } while (l != startl && !BMO_TestFlag(bm, l->e, EDGE_SEAM)); if (l == startl || !BMO_TestFlag(bm, l->e, EDGE_SEAM)) break; if (l->v == v) { - v = ((BMLoop*)l->head.next)->v; + v = ((BMLoop*)l->next)->v; } else v = l->v; } } @@ -261,8 +261,8 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) BMO_SetFlag(bm, l->e, EDGE_DEL); - nextl = (BMLoop*) l->head.next; - prevl = (BMLoop*) l->head.prev; + nextl = (BMLoop*) l->next; + prevl = (BMLoop*) l->prev; for (j=0; j<2; j++) { l2 = j ? nextl : prevl; @@ -294,7 +294,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) break; } - l3 = (BMLoop*)l3->radial.next->data; + l3 = (BMLoop*)l3->radial_next; l3 = BM_OtherFaceLoop(l3->e, l3->f, v); } while (l3 != l2 && !BMO_TestFlag(bm, l3->e, EDGE_SEAM)); @@ -311,7 +311,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) if (BM_Edge_FaceCount(l3->e) != 2) break; - l3 = (BMLoop*)l3->radial.next->data; + l3 = (BMLoop*)l3->radial_next; l3 = BM_OtherFaceLoop(l3->e, l3->f, v); et = etags + BMINDEX_GET(l3->e); @@ -340,7 +340,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) is set in remake_face*/ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BMO_TestFlag(bm, e, EDGE_MARK)) { - if (!e->loop) + if (!e->l) BMO_SetFlag(bm, e, EDGE_DEL); } } diff --git a/source/blender/bmesh/operators/extrudeops.c b/source/blender/bmesh/operators/extrudeops.c index 22650945c46..e6b7a8aba2a 100644 --- a/source/blender/bmesh/operators/extrudeops.c +++ b/source/blender/bmesh/operators/extrudeops.c @@ -9,6 +9,7 @@ #include "BLI_array.h" #include "bmesh.h" +#include "bmesh_private.h" #include "bmesh_operators_private.h" #include @@ -64,15 +65,15 @@ void bmesh_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) l2 = BMIter_New(&liter2, bm, BM_LOOPS_OF_FACE, f2); BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { BM_Copy_Attributes(bm, bm, l, l2); - l3 = l->head.next; - l4 = l2->head.next; + l3 = l->next; + l4 = l2->next; f3 = BM_Make_QuadTri(bm, l3->v, l4->v, l2->v, l->v, f, 0); - BM_Copy_Attributes(bm, bm, l->head.next, f3->loopbase); - BM_Copy_Attributes(bm, bm, l->head.next, f3->loopbase->head.next); - BM_Copy_Attributes(bm, bm, l, f3->loopbase->head.next->next); - BM_Copy_Attributes(bm, bm, l, f3->loopbase->head.next->next->next); + BM_Copy_Attributes(bm, bm, l->next, bm_firstfaceloop(f3)); + BM_Copy_Attributes(bm, bm, l->next, bm_firstfaceloop(f3)->next); + BM_Copy_Attributes(bm, bm, l, bm_firstfaceloop(f3)->next->next); + BM_Copy_Attributes(bm, bm, l, bm_firstfaceloop(f3)->next->next->next); l2 = BMIter_Step(&liter2); } @@ -105,7 +106,7 @@ void bmesh_extrude_onlyedge_exec(BMesh *bm, BMOperator *op) e2 = BMO_IterMapVal(&siter); e2 = *(BMEdge**)e2; - if (e->loop && e->v1 != e->loop->v) { + if (e->l && e->v1 != e->l->v) { v1 = e->v1; v2 = e->v2; v3 = e2->v2; @@ -245,10 +246,10 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) newedge = BMO_IterMapVal(&siter); newedge = *(BMEdge**)newedge; if (!newedge) continue; - if (!newedge->loop) ce = e; + if (!newedge->l) ce = e; else ce = newedge; - if (ce->loop && (ce->loop->v == ce->v1)) { + if (ce->l && (ce->l->v == ce->v1)) { verts[0] = e->v1; verts[1] = e->v2; verts[2] = newedge->v2; @@ -267,15 +268,15 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) l=BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); for (; l; l=BMIter_Step(&iter)) { if (l->e != e && l->e != newedge) continue; - l2 = l->radial.next->data; + l2 = l->radial_next; if (l2 == l) { - l2 = newedge->loop; + l2 = newedge->l; BM_Copy_Attributes(bm, bm, l2->f, l->f); BM_Copy_Attributes(bm, bm, l2, l); - l2 = (BMLoop*) l2->head.next; - l = (BMLoop*) l->head.next; + l2 = (BMLoop*) l2->next; + l = (BMLoop*) l->next; BM_Copy_Attributes(bm, bm, l2, l); } else { BM_Copy_Attributes(bm, bm, l2->f, l->f); @@ -283,14 +284,14 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) /*copy data*/ if (l2->v == l->v) { BM_Copy_Attributes(bm, bm, l2, l); - l2 = (BMLoop*) l2->head.next; - l = (BMLoop*) l->head.next; + l2 = (BMLoop*) l2->next; + l = (BMLoop*) l->next; BM_Copy_Attributes(bm, bm, l2, l); } else { - l2 = (BMLoop*) l2->head.next; + l2 = (BMLoop*) l2->next; BM_Copy_Attributes(bm, bm, l2, l); - l2 = (BMLoop*) l2->head.prev; - l = (BMLoop*) l->head.next; + l2 = (BMLoop*) l2->prev; + l = (BMLoop*) l->next; BM_Copy_Attributes(bm, bm, l2, l); } } @@ -301,7 +302,7 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) v = BMO_IterNew(&siter, bm, &dupeop, "isovertmap", 0); for (; v; v=BMO_IterStep(&siter)) { v2 = *((void**)BMO_IterMapVal(&siter)); - BM_Make_Edge(bm, v, v2, v->edge, 1); + BM_Make_Edge(bm, v, v2, v->e, 1); } /*cleanup*/ diff --git a/source/blender/bmesh/operators/join_triangles.c b/source/blender/bmesh/operators/join_triangles.c index faea46d1082..5b322489515 100644 --- a/source/blender/bmesh/operators/join_triangles.c +++ b/source/blender/bmesh/operators/join_triangles.c @@ -111,18 +111,18 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) BMLoop *l1, *l2, *l3, *l4; int mergeok_uvs=!douvs, mergeok_vcols=!dovcols; - l1 = e->loop; - l3 = (BMLoop*)e->loop->radial.next->data; + l1 = e->l; + l3 = (BMLoop*)e->l->radial_next; /*match up loops on each side of an edge corrusponding to each vert*/ if (l1->v == l3->v) { - l2 = (BMLoop*)l1->head.next; - l4 = (BMLoop*)l2->head.next; + l2 = (BMLoop*)l1->next; + l4 = (BMLoop*)l2->next; } else { - l2 = (BMLoop*)l1->head.next; + l2 = (BMLoop*)l1->next; l4 = l3; - l3 = (BMLoop*)l4->head.next; + l3 = (BMLoop*)l4->next; } lcol1 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL); @@ -240,8 +240,8 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) continue; } - f1 = e->loop->f; - f2 = ((BMLoop*)e->loop->radial.next->data)->f; + f1 = e->l->f; + f2 = ((BMLoop*)e->l->radial_next)->f; if (f1->len != 3 || f2->len != 3) { BMO_ClearFlag(bm, e, EDGE_MARK); @@ -263,13 +263,13 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) if (!BMO_TestFlag(bm, e, EDGE_MARK)) continue; - f1 = e->loop->f; - f2 = ((BMLoop*)e->loop->radial.next->data)->f; + f1 = e->l->f; + f2 = ((BMLoop*)e->l->radial_next)->f; - v1 = e->loop->v; - v2 = ((BMLoop*)e->loop->head.prev)->v; - v3 = ((BMLoop*)e->loop->head.next)->v; - v4 = ((BMLoop*)((BMLoop*)e->loop->radial.next->data)->head.prev)->v; + v1 = e->l->v; + v2 = ((BMLoop*)e->l->prev)->v; + v3 = ((BMLoop*)e->l->next)->v; + v4 = ((BMLoop*)((BMLoop*)e->l->radial_next)->prev)->v; if (dosharp && BM_TestHFlag(e, BM_SHARP)) continue; @@ -301,8 +301,8 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) BMFace *f1, *f2; e = jedges[i].e; - f1 = e->loop->f; - f2 = ((BMLoop*)e->loop->radial.next->data)->f; + f1 = e->l->f; + f2 = ((BMLoop*)e->l->radial_next)->f; if (BMO_TestFlag(bm, f1, FACE_MARK) || BMO_TestFlag(bm, f2, FACE_MARK)) continue; @@ -316,10 +316,10 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) if (!BMO_TestFlag(bm, e, EDGE_CHOSEN)) continue; - f1 = e->loop->f; - f2 = ((BMLoop*)e->loop->radial.next->data)->f; + f1 = e->l->f; + f2 = ((BMLoop*)e->l->radial_next)->f; - BM_Join_Faces(bm, f1, f2, e); + BM_Join_TwoFaces(bm, f1, f2, e); } BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { @@ -327,8 +327,8 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) /*ok, this edge wasn't merged, check if it's in a 2-tri-pair island, and if so merge*/ - f1 = e->loop->f; - f2 = ((BMLoop*)e->loop->radial.next->data)->f; + f1 = e->l->f; + f2 = ((BMLoop*)e->l->radial_next)->f; if (f1->len != 3 || f2->len != 3) continue; @@ -348,7 +348,7 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) if (i != 2) continue; - BM_Join_Faces(bm, f1, f2, e); + BM_Join_TwoFaces(bm, f1, f2, e); } } diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 590e81cd99f..b34f5cc85c1 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -31,6 +31,7 @@ #include "mesh_intern.h" #include "bmesh.h" +#include "bmesh_private.h" /* * MESH CONV.C @@ -69,6 +70,16 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_ASSIGN, NULL, 0); + if (!CustomData_has_layer(&bm->edata, CD_CREASE)) + CustomData_add_layer(&bm->edata, CD_CREASE, CD_ASSIGN, NULL, 0); + + if (!CustomData_has_layer(&bm->edata, CD_BWEIGHT)) + CustomData_add_layer(&bm->edata, CD_BWEIGHT, CD_ASSIGN, NULL, 0); + + if (!CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) + CustomData_add_layer(&bm->vdata, CD_BWEIGHT, CD_ASSIGN, NULL, 0); + + if (me->key && ob->shapenr > me->key->totkey) { ob->shapenr = me->key->totkey-1; } @@ -116,7 +127,7 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { /*transfer flags*/ v->head.flag = MEFlags_To_BMFlags(mvert->flag, BM_VERT); - v->bweight = (float)mvert->bweight / 255.0f; + BM_SetCDf(&bm->vdata, v, CD_BWEIGHT, (float)mvert->bweight / 255.0f); /*Copy Custom Data*/ CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->head.data); @@ -150,8 +161,8 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { /*Copy Custom Data*/ CustomData_to_bmesh_block(&me->edata, &bm->edata, i, &e->head.data); - e->crease = (float)medge->crease / 255.0f; - e->bweight = (float)medge->bweight / 255.0f; + BM_SetCDf(&bm->edata, e, CD_CREASE, (float)medge->crease / 255.0f); + BM_SetCDf(&bm->edata, e, CD_BWEIGHT, (float)medge->bweight / 255.0f); /*this is necassary for selection counts to work properly*/ if (e->head.flag & BM_SELECT) BM_Select(bm, e, 1); @@ -371,6 +382,8 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i++; mvert++; + + CHECK_ELEMENT(bm, v); } i = 0; @@ -387,6 +400,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i++; medge++; + CHECK_ELEMENT(bm, e); } /*new scanfill tesselation code*/ @@ -511,6 +525,9 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { /*copy over customdata*/ CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l->head.data, j); + CHECK_ELEMENT(bm, l); + CHECK_ELEMENT(bm, l->e); + CHECK_ELEMENT(bm, l->v); } if (f == bm->act_face) me->act_face = i; @@ -520,6 +537,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i++; mpoly++; + CHECK_ELEMENT(bm, f); } /* patch hook indices and vertex parents */ diff --git a/source/blender/bmesh/operators/removedoubles.c b/source/blender/bmesh/operators/removedoubles.c index f8c0086d7fa..a6d921a1bf1 100644 --- a/source/blender/bmesh/operators/removedoubles.c +++ b/source/blender/bmesh/operators/removedoubles.c @@ -33,8 +33,8 @@ void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op) v2 = BMO_Get_MapPointer(bm, op, "targetmap", l->v); /*ok: if v2 is NULL (e.g. not in the map) then it's a target vert, otherwise it's a double*/ - if (v2 && BM_Vert_In_Face(f, v2) && v2 != BL(l->head.prev)->v - && v2 != BL(l->head.next)->v) + if (v2 && BM_Vert_In_Face(f, v2) && v2 != BL(l->prev)->v + && v2 != BL(l->next)->v) { doub = l->v; split = 1; @@ -142,7 +142,7 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op) a = 0; BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { v = l->v; - v2 = BL(l->head.next)->v; + v2 = BL(l->next)->v; if (BMO_TestFlag(bm, v, ELE_DEL)) v = BMO_Get_MapPointer(bm, op, "targetmap", v); if (BMO_TestFlag(bm, v2, ELE_DEL)) diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index 1611c634204..e273a03b17a 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -41,6 +41,8 @@ #include "ED_mesh.h" #include "bmesh.h" +#include "bmesh_private.h" + #include "mesh_intern.h" #include "subdivideop.h" @@ -242,6 +244,10 @@ static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, subdparams *params, BMO_SetFlag(bm, v, ELE_SPLIT); BMO_SetFlag(bm, eed, ELE_SPLIT); BMO_SetFlag(bm, newe, SUBD_SPLIT); + + CHECK_ELEMENT(bm, v); + if (v->e) CHECK_ELEMENT(bm, v->e); + if (v->e && v->e->l) CHECK_ELEMENT(bm, v->e->l->f); } } @@ -475,7 +481,8 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *face, BMVert **verts, b = numcuts + 1 + numcuts + 1 + (numcuts - i - 1); e = connect_smallest_face(bm, verts[a], verts[b], &nf); - if (!e) continue; + if (!e) + continue; BMO_SetFlag(bm, e, ELE_INNER); BMO_SetFlag(bm, nf, ELE_INNER); @@ -488,6 +495,9 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *face, BMVert **verts, for (a=0; alen; i++) { edge = ((BMEdge**)einput->data.p)[i]; bm_subdivide_multicut(bmesh, edge, ¶ms, edge->v1, edge->v2); - //BM_Split_Edge_Multi(bmesh, edge, numcuts); } - //if (facedata) BLI_array_free(facedata); - //return; - i = 0; - for (face=BMIter_New(&fiter, bmesh, BM_FACES_OF_MESH, NULL); - face; face=BMIter_Step(&fiter)) { + for (i=0; iv; j += 1; } - + + CHECK_ELEMENT(bmesh, face); pat->connectexec(bmesh, face, verts, ¶ms); - i++; } if (facedata) BLI_array_free(facedata); diff --git a/source/blender/bmesh/operators/utils.c b/source/blender/bmesh/operators/utils.c index aa46a901ba6..b22099a509a 100644 --- a/source/blender/bmesh/operators/utils.c +++ b/source/blender/bmesh/operators/utils.c @@ -821,9 +821,16 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) break; case SIMEDGE_CREASE: - if( fabs(e->crease - es->crease) <= thresh ) { - BMO_SetFlag(bm, e, EDGE_MARK); - cont = 0; + if (CustomData_has_layer(&bm->edata, CD_CREASE)) { + float *c1, *c2; + + c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE); + c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_CREASE); + + if( c1&&c2 && fabs(*c1 - *c2) <= thresh ) { + BMO_SetFlag(bm, e, EDGE_MARK); + cont = 0; + } } break; diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index f9b1ba1978f..fba5536eb1e 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -212,12 +212,12 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l, * so... here we walk around edges to find the needed verts */ forward = 1; is_split_vert = 0; - if (v->edge == NULL) { + if (v->e == NULL) { //printf("We can't split a loose vert's edge!\n"); return NULL; } - e1 = v->edge; /* we just use the first two edges */ - e2 = bmesh_disk_nextedge(v->edge, v); + e1 = v->e; /* we just use the first two edges */ + e2 = bmesh_disk_nextedge(v->e, v); if (e1 == e2) { //printf("You need at least two edges to use BME_bevel_split_edge()\n"); return NULL; @@ -398,8 +398,8 @@ static float BME_bevel_set_max(BMVert *v1, BMVert *v2, float value, BME_TransDat static BMVert *BME_bevel_wire(BMesh *bm, BMVert *v, float value, int res, int options, BME_TransData_Head *td) { BMVert *ov1, *ov2, *v1, *v2; - ov1 = BM_OtherEdgeVert(v->edge, v); - ov2 = BM_OtherEdgeVert(bmesh_disk_nextedge(v->edge, v), v); + ov1 = BM_OtherEdgeVert(v->e, v); + ov2 = BM_OtherEdgeVert(bmesh_disk_nextedge(v->e, v), v); /* split the edges */ v1 = BME_bevel_split_edge(bm,v,ov1,NULL,NULL,value,td); @@ -418,8 +418,8 @@ static BMVert *BME_bevel_wire(BMesh *bm, BMVert *v, float value, int res, int op //void BM_Collapse_Vert(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, int calcnorm){ //hrm, why is there a fac here? it just removes a vert - BM_Collapse_Vert(bm, v->edge, v, 1.0, 0); - //bmesh_jekv(bm,v->edge,v); + BM_Collapse_Vert(bm, v->e, v, 1.0, 0); + //bmesh_jekv(bm,v->e,v); } return v1; @@ -444,7 +444,7 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int options, fl /* first, check to see if this edge was inset previously */ if ((l->prev->e->tflag1 & BME_BEVEL_ORIG) == 0 && (l->v->tflag1 & BME_BEVEL_NONMAN) == 0) { - kl = l->prev->radial.next->data; + kl = l->prev->radial_next; if (kl->v == l->v) kl = kl->prev; else kl = kl->next; kv = l->v; @@ -464,14 +464,14 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int options, fl l = l->next; if (kl->v == kv) { BM_Split_Face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e); - bmesh_jfke(bm,((BMLoop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e); + bmesh_jfke(bm,((BMLoop*)kl->prev->radial_next)->f,kl->f,kl->prev->e); BM_Collapse_Vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } else { BM_Split_Face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e); - bmesh_jfke(bm,((BMLoop*)kl->next->radial.next->data)->f,kl->f,kl->next->e); + bmesh_jfke(bm,((BMLoop*)kl->next->radial_next)->f,kl->f,kl->next->e); BM_Collapse_Vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } @@ -482,7 +482,7 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int options, fl /* first, check to see if this edge was inset previously */ if ((l->next->e->tflag1 & BME_BEVEL_ORIG) == 0 && (l->next->v->tflag1 & BME_BEVEL_NONMAN) == 0) { - kl = l->next->radial.next->data; + kl = l->next->radial_next; if (kl->v == l->next->v) kl = kl->prev; else kl = kl->next; kv = l->next->v; @@ -501,13 +501,13 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int options, fl if (kv) { if (kl->v == kv) { BM_Split_Face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e); - bmesh_jfke(bm,((BMLoop*)kl->prev->radial.next->data)->f,kl->f,kl->prev->e); + bmesh_jfke(bm,((BMLoop*)kl->prev->radial_next)->f,kl->f,kl->prev->e); BM_Collapse_Vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } else { BM_Split_Face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e); - bmesh_jfke(bm,((BMLoop*)kl->next->radial.next->data)->f,kl->f,kl->next->e); + bmesh_jfke(bm,((BMLoop*)kl->next->radial_next)->f,kl->f,kl->next->e); BM_Collapse_Vert(bm, kl->e, kv, 1.0); //BME_JEKV(bm,kl->e,kv); } @@ -516,7 +516,7 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int options, fl if ((v1->tflag1 & BME_BEVEL_NONMAN)==0 || (v2->tflag1 & BME_BEVEL_NONMAN)==0) { BM_Split_Face(bm,f,v2,v1,&l,e); l->e->tflag1 = BME_BEVEL_BEVEL; - l = l->radial.next->data; + l = l->radial_next; } if (l->f != f){ @@ -726,7 +726,7 @@ static bevel_init_edges(BMesh *bm, int options, BME_TransData_Head *td){ /*clean up edges with 2 faces that share more than one edge*/ for( e = BM_first_element(bm, BME_EDGE); e; e = BM_next_element(bm, BME_EDGE, e)){ if(e->tflag1 & BME_BEVEL_BEVEL){ - count = BM_face_sharededges(e->loop->f, ((BMLoop*)e->loop->radial.next->data)->f); + count = BM_face_sharededges(e->l->f, ((BMLoop*)e->l->radial_next)->f); if(count > 1) e->tflag1 &= ~BME_BEVEL_BEVEL; } } @@ -746,18 +746,18 @@ static BMesh *BME_bevel_initialize(BMesh *bm, int options, int defgrp_index, flo /*tag non-manifold geometry*/ for (v = BMIter_New(&iter, bm, BM_VERTS, nm); v; v = BMIter_Step(&iter)) { v->tflag1 = BME_BEVEL_ORIG; - if(v->edge){ + if(v->e){ BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1, NULL); if (BM_Nonmanifold_Vert(bm,v)) v->tflag1 |= BME_BEVEL_NONMAN; /*test wire vert*/ - len = bmesh_cycle_length(bmesh_disk_getpointer(v->edge,v)); + len = bmesh_cycle_length(bmesh_disk_getpointer(v->e,v)); if(len == 2 && BME_wirevert(bm, v)) v->tflag1 &= ~BME_BEVEL_NONMAN; }else v->tflag1 |= BME_BEVEL_NONMAN; } for (e = BMIter_New(&iter, bm, BM_EDGES, nm); e; e = BMIter_Step(&iter)) { e->tflag1 = BME_BEVEL_ORIG; - if (e->loop == NULL || BME_cycle_length(&(e->loop->radial)) > 2){ + if (e->l == NULL || BME_cycle_length(&(e->l->radial)) > 2){ e->v1->tflag1 |= BME_BEVEL_NONMAN; e->v2->tflag1 |= BME_BEVEL_NONMAN; e->tflag1 |= BME_BEVEL_NONMAN; @@ -828,23 +828,23 @@ static BMMesh *BME_bevel_mesh(BMMesh *bm, float value, int res, int options, int /*get rid of beveled edges*/ for(e = BMeshIter_init(edges, BM_EDGES, bm, 0); e;){ ne = BMeshIter_step(edges); - if( bmesh_test_flag(e, BME_BEVEL_BEVEL) && bmesh_test_flag(e, BME_BEVEL_ORIG) ) bmesh_join_faces(bm, e->loop->f, ((BMLoop*)e->loop->radial.next->data)->f, e, 1); + if( bmesh_test_flag(e, BME_BEVEL_BEVEL) && bmesh_test_flag(e, BME_BEVEL_ORIG) ) bmesh_join_faces(bm, e->l->f, ((BMLoop*)e->l->radial_next)->f, e, 1); e = ne; } /*link up corners and clip*/ for(v = BMeshIter_init(verts, BM_VERTS, bm, 0); v;){ nv = BMeshIter_step(verts) if( bmesh_test_flag(v, BME_BEVEL_ORIG) && bmesh_test_flag(v, BME_BEVEL_BEVEL)){ - curedge = v->edge; + curedge = v->e; do{ - l = curedge->loop; - l2 = l->radial.next->data; + l = curedge->l; + l2 = l->radial_next; if(l->v != v) l = l->next; if(l2->v != v) l2 = l2->next; if(l->f->len > 3) BM_split_face(bm,l->f,l->next->v,l->prev->v,&l,l->e); /* clip this corner off */ if(l2->f->len > 3) BM_split_face(bm,l2->f,l2->next->v,l2->prev->v,&l,l2->e); /* clip this corner off */ curedge = BM_edge_of_vert(curedge, v); - }while(curedge != v->edge); + }while(curedge != v->e); BM_dissolve_disk(bm,v); } v = nv; diff --git a/source/blender/bmesh/tools/BME_dupe_ops.c b/source/blender/bmesh/tools/BME_dupe_ops.c index 533e278ea68..ad5739e9abc 100644 --- a/source/blender/bmesh/tools/BME_dupe_ops.c +++ b/source/blender/bmesh/tools/BME_dupe_ops.c @@ -88,17 +88,17 @@ static BMFace *copy_face(BMMesh *source_mesh, BMFace *source_face, BMMesh *targe int i; /*lookup the first and second verts*/ - target_vert1 = BLI_ghash_lookup(vhash, source_face->loopbase->v); - target_vert2 = BLI_ghash_lookup(vhash, source_face->loopbase->next->v); + target_vert1 = BLI_ghash_lookup(vhash, source_face->lbase->v); + target_vert2 = BLI_ghash_lookup(vhash, source_face->lbase->next->v); /*lookup edges*/ i = 0; - source_loop = source_face->loopbase; + source_loop = source_face->lbase; do{ edar[i] = BLI_ghash_lookup(ehash, source_loop->e); i++; source_loop = source_loop->next; - }while(source_loop != source_face->loopbase); + }while(source_loop != source_face->lbase); /*create new face*/ target_face = BM_Make_Ngon(target_mesh, target_vert1, target_vert2, edar, source_face->len, 0); @@ -114,13 +114,13 @@ static BMFace *copy_face(BMMesh *source_mesh, BMFace *source_face, BMMesh *targe BMO_SetFlag(target_mesh, (BMHeader*)target_face, DUPE_NEW); /*copy per-loop custom data*/ - source_loop = source_face->loopbase; - target_loop = target_face->loopbase; + source_loop = source_face->lbase; + target_loop = target_face->lbase; do{ CustomData_bmesh_copy_data(&source_mesh->ldata, &target_mesh->ldata, source_loop->data, &target_loop->data); source_loop = source_loop->next; target_loop = target_loop->next; - }while(source_loop != source_face->loopbase); + }while(source_loop != source_face->lbase); return target_face; } diff --git a/source/blender/bmesh/tools/BME_duplicate.c b/source/blender/bmesh/tools/BME_duplicate.c index 7c679ff6a89..ec3cfe56fc9 100644 --- a/source/blender/bmesh/tools/BME_duplicate.c +++ b/source/blender/bmesh/tools/BME_duplicate.c @@ -85,17 +85,17 @@ static BMFace *bmesh_copy_face(BMMesh *source_mesh, BMFace *source_face, BMMesh /*lookup the first and second verts*/ - target_vert1 = BLI_ghash_lookup(vhash, source_face->loopbase->v); - target_vert2 = BLI_ghash_lookup(vhash, source_face->loopbase->next->v); + target_vert1 = BLI_ghash_lookup(vhash, source_face->lbase->v); + target_vert2 = BLI_ghash_lookup(vhash, source_face->lbase->next->v); /*lookup edges*/ i = 0; - source_loop = source_face->loopbase; + source_loop = source_face->lbase; do{ edar[i] = BLI_ghash_lookup(ehash, source_loop->e); i++; source_loop = source_loop->next; - }while(source_loop != source_face->loopbase); + }while(source_loop != source_face->lbase); /*create new face*/ target_face = bmesh_make_ngon(target_mesh, target_vert1, target_vert2, edar, source_face->len, 0); @@ -111,13 +111,13 @@ static BMFace *bmesh_copy_face(BMMesh *source_mesh, BMFace *source_face, BMMesh bmesh_set_flag(target_face, BMESH_DIRTY); /*copy per-loop custom data*/ - source_loop = source_face->loopbase; - target_loop = target_face->loopbase; + source_loop = source_face->lbase; + target_loop = target_face->lbase; do{ CustomData_bmesh_copy_data(&source_mesh->ldata, &target_mesh->ldata, source_loop->data, &target_loop->data); source_loop = source_loop->next; target_loop = target_loop->next; - }while(source_loop != source_face->loopbase); + }while(source_loop != source_face->lbase); return target_face; } diff --git a/source/blender/bmesh/tools/BME_extrude.c b/source/blender/bmesh/tools/BME_extrude.c index b7b3a94893d..70baff2adf6 100644 --- a/source/blender/bmesh/tools/BME_extrude.c +++ b/source/blender/bmesh/tools/BME_extrude.c @@ -42,19 +42,19 @@ void BME_extrude_skirt(BME_Mesh *bm, GHash *ehash){ for(e=BME_first(bm,BME_EDGE);e;e=BME_next(bm,BME_EDGE,e)){ if(BME_SELECTED(e)){ /*find one face incident upon e and use it for winding of new face*/ - if(e->loop){ - v1 = e->loop->next->v; - v2 = e->loop->v; + if(e->l){ + v1 = e->l->next->v; + v2 = e->l->v; } else{ v1 = e->v1; v2 = e->v2; } - if(v1->edge->tflag1 == 2) l = v1->edge; - else l = BME_disk_next_edgeflag(v1->edge, v1, 0, 2); - if(v2->edge->tflag1 == 2) r = v2->edge; - else r = BME_disk_next_edgeflag(v2->edge, v2, 0, 2); + if(v1->e->tflag1 == 2) l = v1->e; + else l = BME_disk_next_edgeflag(v1->e, v1, 0, 2); + if(v2->e->tflag1 == 2) r = v2->e; + else r = BME_disk_next_edgeflag(v2->e, v2, 0, 2); lv = BME_edge_getothervert(l,v1); rv = BME_edge_getothervert(r,v2); @@ -98,14 +98,14 @@ void BME_cap_skirt(BME_Mesh *bm, GHash *vhash, GHash *ehash){ BME_VISIT(l->v); //we dont want to dupe it again. } l=l->next; - }while(l!=f->loopbase); + }while(l!=f->lbase); } } //find out if we delete old faces or not. This needs to be improved a lot..... for(e=BME_first(bm,BME_EDGE);e;e=BME_next(bm,BME_EDGE,e)){ - if(BME_SELECTED(e) && e->loop){ - i= BME_cycle_length(&(e->loop->radial)); + if(BME_SELECTED(e) && e->l){ + i= BME_cycle_length(&(e->l->radial)); if(i > 2){ del_old = 1; break; @@ -128,7 +128,7 @@ void BME_cap_skirt(BME_Mesh *bm, GHash *vhash, GHash *ehash){ BME_VISIT(l->e); //we dont want to dupe it again. } l=l->next; - }while(l!=f->loopbase); + }while(l!=f->lbase); } } @@ -168,12 +168,12 @@ void BME_extrude_mesh(BME_Mesh *bm, int type){ if(type & BME_EXTRUDE_FACES){ //Find selected edges with more than one incident face that is also selected. deselect them. for(e=BME_first(bm,BME_EDGE);e;e=BME_next(bm,BME_EDGE,e)){ int totsel=0; - if(e->loop){ - l= e->loop; + if(e->l){ + l= e->l; do{ if(BME_SELECTED(l->f)) totsel++; l=BME_radial_nextloop(l); - }while(l!=e->loop); + }while(l!=e->l); } if(totsel > 1) BME_select_edge(bm,e,0); } diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 1d1f812b4c3..58c3f5d6088 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -27,21 +27,6 @@ FILE(GLOB SRC */*.c) SET(INC ../windowmanager -<<<<<<< .working - ../editors/include - ../../../intern/guardedalloc ../../../intern/memutil - ../blenlib ../makesdna ../makesrna ../blenkernel - ../include ../imbuf ../render/extern/include - ../../../intern/bsp/extern ../radiosity/extern/include - ../../../intern/decimation/extern ../blenloader ../python - ../../kernel/gen_system ../../../intern/SoundSystem ../readstreamglue - ../quicktime ../../../intern/elbeem/extern - ../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include ../../../intern/smoke/extern - ../nodes ../bmesh - ../gpu - ../blenfont - ${SDL_INC} -======= ../editors/include ../editors/interface ../../../intern/guardedalloc ../../../intern/memutil ../blenlib ../makesdna ../makesrna ../blenkernel @@ -49,13 +34,12 @@ SET(INC ../windowmanager ../../../intern/bsp/extern ../../../intern/decimation/extern ../blenloader ../python ../../kernel/gen_system ../readstreamglue - ../../../intern/elbeem/extern + ../../../intern/elbeem/extern ../bmesh ../../../intern/ghost ../../../intern/opennl/extern ../../../extern/glew/include ../../../intern/smoke/extern ../../../intern/audaspace/intern ../nodes ../gpu ../blenfont ->>>>>>> .merge-right.r27259 ../ikplugin ) @@ -66,25 +50,25 @@ IF(WITH_GAMEENGINE) ENDIF(WITH_GAMEENGINE) IF(WITH_INTERNATIONAL) - ADD_DEFINITIONS(-DINTERNATIONAL) + ADD_DEFINITIONS(-DINTERNATIONAL) ENDIF(WITH_INTERNATIONAL) IF(WITH_OPENEXR) - ADD_DEFINITIONS(-DWITH_OPENEXR) + ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) IF(WITH_OPENJPEG) - ADD_DEFINITIONS(-DWITH_OPENJPEG) + ADD_DEFINITIONS(-DWITH_OPENJPEG) ENDIF(WITH_OPENJPEG) IF(WITH_QUICKTIME) - SET(INC ${INC} ${QUICKTIME_INC}) - ADD_DEFINITIONS(-DWITH_QUICKTIME) + SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) + ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) IF(WITH_FFMPEG) - SET(INC ${INC} ${FFMPEG_INC}) - ADD_DEFINITIONS(-DWITH_FFMPEG) + SET(INC ${INC} ${FFMPEG_INC}) + ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) IF(WITH_OPENMP) @@ -92,22 +76,22 @@ IF(WITH_OPENMP) ENDIF(WITH_OPENMP) IF(NOT WITH_ELBEEM) - ADD_DEFINITIONS(-DDISABLE_ELBEEM) + ADD_DEFINITIONS(-DDISABLE_ELBEEM) ENDIF(NOT WITH_ELBEEM) IF(WITH_PYTHON) - SET(INC ${INC} ${PYTHON_INC}) + SET(INC ${INC} ${PYTHON_INC}) ELSE(WITH_PYTHON) - ADD_DEFINITIONS(-DDISABLE_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) ENDIF(WITH_PYTHON) IF(WIN32) - SET(INC ${INC} ${PTHREADS_INC}) + SET(INC ${INC} ${PTHREADS_INC}) ENDIF(WIN32) IF(WITH_BUILDINFO) - ADD_DEFINITIONS(-DNAN_BUILDINFO) + ADD_DEFINITIONS(-DNAN_BUILDINFO) ENDIF(WITH_BUILDINFO) -BLENDERLIB_NOLIST(bf_editors "${SRC}" "${INC}") +BLENDERLIB(bf_editors "${SRC}" "${INC}") diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index d4f37e7c0e9..a1655065e1e 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -50,6 +50,7 @@ struct MCol; struct UvVertMap; struct UvMapVert; struct CustomData; +struct BMEditMesh; struct BMEditSelection; struct BMesh; struct BMVert; @@ -83,6 +84,8 @@ struct rcti; #define B_FRACTAL 0x2000 #define B_SPHERE 0x4000 +float *bm_get_cd_float(struct CustomData *cdata, void *data, int type); + /* bmeshutils.c */ /*x-mirror editing api. usage: diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index f5c6ea351af..2199a4bc594 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -1613,12 +1613,12 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event } if (efa) { - eed = efa->loopbase->e; + eed = bm_firstfaceloop(efa)->e; } else if (!eed) { - if (!eve || !eve->edge) + if (!eve || !eve->e) return OPERATOR_CANCELLED; - eed = eve->edge; + eed = eve->e; } BMW_Init(&walker, em->bm, BMW_SHELL, 0, 0); @@ -2092,11 +2092,11 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op) sharp = (sharp * M_PI) / 180.0; BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - if (BM_TestHFlag(e, BM_HIDDEN) || !e->loop) + if (BM_TestHFlag(e, BM_HIDDEN) || !e->l) continue; - l1 = e->loop; - l2 = l1->radial.next->data; + l1 = e->l; + l2 = l1->radial_next; if (l1 == l2) continue; diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index ff852a51a2e..8291c46eedd 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -1510,8 +1510,12 @@ void MESH_OT_flip_normals(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -//#define DIRECTION_CW 1 -//#define DIRECTION_CCW 2 +float *bm_get_cd_float(CustomData *cdata, void *data, int type) +{ + float *f = CustomData_bmesh_get(cdata, data, type); + + return f; +} static const EnumPropertyItem direction_items[]= { {DIRECTION_CW, "CW", 0, "Clockwise", ""}, @@ -1538,8 +1542,8 @@ static int edge_rotate_selected(bContext *C, wmOperator *op) /*first see if we have two adjacent faces*/ BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { if (BM_Edge_FaceCount(eed) == 2) { - if ((BM_TestHFlag(eed->loop->f, BM_SELECT) && BM_TestHFlag(((BMLoop*)eed->loop->radial.next->data)->f, BM_SELECT)) - && !(BM_TestHFlag(eed->loop->f, BM_HIDDEN) || BM_TestHFlag(((BMLoop*)eed->loop->radial.next->data)->f, BM_HIDDEN))) + if ((BM_TestHFlag(eed->l->f, BM_SELECT) && BM_TestHFlag(((BMLoop*)eed->l->radial_next)->f, BM_SELECT)) + && !(BM_TestHFlag(eed->l->f, BM_HIDDEN) || BM_TestHFlag(((BMLoop*)eed->l->radial_next)->f, BM_HIDDEN))) { break; } @@ -2904,18 +2908,18 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) /*rip two adjacent edges*/ if (BM_Edge_FaceCount(e2) == 1) { - l = e2->loop; + l = e2->l; e = BM_OtherFaceLoop(e2, l->f, v)->e; BMINDEX_SET(e, 1); BM_SetHFlag(e, BM_SELECT); } else if (BM_Edge_FaceCount(e2) == 2) { - l = e2->loop; + l = e2->l; e = BM_OtherFaceLoop(e2, l->f, v)->e; BMINDEX_SET(e, 1); BM_SetHFlag(e, BM_SELECT); - l = e2->loop->radial.next->data; + l = e2->l->radial_next; e = BM_OtherFaceLoop(e2, l->f, v)->e; BMINDEX_SET(e, 1); BM_SetHFlag(e, BM_SELECT); @@ -2934,9 +2938,9 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - if (i == 1 && e2->loop) { - l = BM_OtherFaceLoop(e2, e2->loop->f, v); - l = (BMLoop*)l->radial.next->data; + if (i == 1 && e2->l) { + l = BM_OtherFaceLoop(e2, e2->l->f, v); + l = (BMLoop*)l->radial_next; l = BM_OtherFaceLoop(l->e, l->f, v); if (l) @@ -2958,7 +2962,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) BMO_ITER(e, &siter, em->bm, &bmop, i ? "edgeout2":"edgeout1", BM_EDGE) { float cent[3] = {0, 0, 0}, mid[4], vec[3]; - if (!BMBVH_EdgeVisible(bvhtree, e, rv3d, obedit)) + if (!BMBVH_EdgeVisible(bvhtree, e, rv3d, obedit) || !e->l) continue; /*method for calculating distance: @@ -2966,10 +2970,10 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) for each edge: calculate face center, then made a vector from edge midpoint to face center. offset edge midpoint by a small amount along this vector.*/ - BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, e->loop->f) { + BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, e->l->f) { add_v3_v3v3(cent, cent, l->v->co); } - mul_v3_fl(cent, 1.0f/(float)e->loop->f->len); + mul_v3_fl(cent, 1.0f/(float)e->l->f->len); add_v3_v3v3(mid, e->v1->co, e->v2->co); mul_v3_fl(mid, 0.5f); diff --git a/source/blender/editors/mesh/editbmesh_bvh.c b/source/blender/editors/mesh/editbmesh_bvh.c index 1428073fd21..e783e855d5e 100644 --- a/source/blender/editors/mesh/editbmesh_bvh.c +++ b/source/blender/editors/mesh/editbmesh_bvh.c @@ -353,7 +353,7 @@ static float topo_compare(BMesh *bm, BMVert *v1, BMVert *v2, int tag) } } - if (!cure1 || !cure1->loop || !cure2->loop) { + if (!cure1 || !cure1->l || !cure2->l) { /*just return 1.0 in this case*/ return 1.0f; } @@ -364,11 +364,11 @@ static float topo_compare(BMesh *bm, BMVert *v1, BMVert *v2, int tag) e.g. a hole or an edge with more then 2 faces around it, we um ignore that edge I guess, and try to make the algorithm go around as necassary.*/ - l1 = cure1->loop; - l2 = cure2->loop; + l1 = cure1->l; + l2 = cure2->l; - lastv1 = l1->v == v1 ? ((BMLoop*)l1->head.next)->v : ((BMLoop*)l1->head.prev)->v; - lastv2 = l2->v == v2 ? ((BMLoop*)l2->head.next)->v : ((BMLoop*)l2->head.prev)->v; + lastv1 = l1->v == v1 ? ((BMLoop*)l1->next)->v : ((BMLoop*)l1->prev)->v; + lastv2 = l2->v == v2 ? ((BMLoop*)l2->next)->v : ((BMLoop*)l2->prev)->v; /*we can only provide meaningful comparisons if v1 and v2 have the same valence*/ if (BM_Vert_EdgeCount(v1) != BM_Vert_EdgeCount(v2)) @@ -407,35 +407,35 @@ static float topo_compare(BMesh *bm, BMVert *v1, BMVert *v2, int tag) /*find next case to do*/ if (!s1->curl) - s1->curl = s1->cure->loop; + s1->curl = s1->cure->l; if (!s2->curl) { float no1[3], no2[3], angle; int wind1, wind2; - s2->curl = s2->cure->loop; + s2->curl = s2->cure->l; /*find which of two possible faces to use*/ l1 = BM_OtherFaceLoop(s1->curl->e, s1->curl->f, s1->lastv); l2 = BM_OtherFaceLoop(s2->curl->e, s2->curl->f, s2->lastv); if (l1->v == s2->lastv) { - l1 = (BMLoop*) l1->head.next; + l1 = (BMLoop*) l1->next; if (l1->v == s2->v) - l1 = (BMLoop*) l1->head.prev->prev; + l1 = (BMLoop*) l1->prev->prev; } else if (l1->v == s2->v) { - l1 = (BMLoop*) l1->head.next; + l1 = (BMLoop*) l1->next; if (l1->v == s2->lastv) - l1 = (BMLoop*) l1->head.prev->prev; + l1 = (BMLoop*) l1->prev->prev; } if (l2->v == s2->lastv) { - l2 = (BMLoop*) l2->head.next; + l2 = (BMLoop*) l2->next; if (l2->v == s2->v) - l2 = (BMLoop*) l2->head.prev->prev; + l2 = (BMLoop*) l2->prev->prev; } else if (l2->v == s2->v) { - l2 = (BMLoop*) l2->head.next; + l2 = (BMLoop*) l2->next; if (l2->v == s2->lastv) - l2 = (BMLoop*) l2->head.prev->prev; + l2 = (BMLoop*) l2->prev->prev; } wind1 = winding(s1->v->co, s1->lastv->co, l1->v->co); @@ -445,17 +445,17 @@ static float topo_compare(BMesh *bm, BMVert *v1, BMVert *v2, int tag) /*if angle between the two adjacent faces is greater then 90 degrees, we need to flip wind2*/ l1 = l2; - l2 = s2->curl->radial.next->data; + l2 = s2->curl->radial_next; l2 = BM_OtherFaceLoop(l2->e, l2->f, s2->lastv); if (l2->v == s2->lastv) { - l2 = (BMLoop*) l2->head.next; + l2 = (BMLoop*) l2->next; if (l2->v == s2->v) - l2 = (BMLoop*) l2->head.prev->prev; + l2 = (BMLoop*) l2->prev->prev; } else if (l2->v == s2->v) { - l2 = (BMLoop*) l2->head.next; + l2 = (BMLoop*) l2->next; if (l2->v == s2->lastv) - l2 = (BMLoop*) l2->head.prev->prev; + l2 = (BMLoop*) l2->prev->prev; } normal_tri_v3(no1, s2->v->co, s2->lastv->co, l1->v->co); @@ -469,15 +469,15 @@ static float topo_compare(BMesh *bm, BMVert *v1, BMVert *v2, int tag) wind2 = !wind2; if (wind1 == wind2) - s2->curl = s2->curl->radial.next->data; + s2->curl = s2->curl->radial_next; } /*handle termination cases of having already looped through all child nodes, or the valence mismatching between v1 and v2, or we hit max recursion depth*/ term |= s1->valence != s2->valence || lvl+1 > maxlevel; - term |= s1->curl->radial.next->data == (BMLoop*)l1; - term |= s2->curl->radial.next->data == (BMLoop*)l2; + term |= s1->curl->radial_next == (BMLoop*)l1; + term |= s2->curl->radial_next == (BMLoop*)l2; if (!term) { lastv1 = s1->v; @@ -507,11 +507,11 @@ static float topo_compare(BMesh *bm, BMVert *v1, BMVert *v2, int tag) s2 = stack2 + lvl - 2; } - s1->curl = s1->curl->v == s1->v ? (BMLoop*) s1->curl->head.prev : (BMLoop*) s1->curl->head.next; - s2->curl = s2->curl->v == s2->v ? (BMLoop*) s2->curl->head.prev : (BMLoop*) s2->curl->head.next; + s1->curl = s1->curl->v == s1->v ? (BMLoop*) s1->curl->prev : (BMLoop*) s1->curl->next; + s2->curl = s2->curl->v == s2->v ? (BMLoop*) s2->curl->prev : (BMLoop*) s2->curl->next; - s1->curl = (BMLoop*) s1->curl->radial.next->data; - s2->curl = (BMLoop*) s2->curl->radial.next->data; + s1->curl = (BMLoop*) s1->curl->radial_next; + s2->curl = (BMLoop*) s2->curl->radial_next; } #define WADD(stack, s)\ @@ -605,7 +605,6 @@ static void vertsearchcallback_topo(void *userdata, int index, const float *co, BMVert *BMBVH_FindClosestVertTopo(BMBVHTree *tree, float *co, float maxdist, BMVert *sourcev) { BVHTreeNearest hit; - BMVert *v; BMIter iter; memset(&hit, 0, sizeof(hit)); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 97f253b294f..442a0121ca5 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -525,7 +525,7 @@ static void edgetag_add_adjacent(BMEditMesh *em, Heap *heap, int mednum, int ver BMEdge *eedadj = EDBM_get_edge_for_index(em, adjnum); float newcost; - if (eedadj->head.eflag2 & ME_SEAM_DONE) + if (eedadj->head.flags[0].f & ME_SEAM_DONE) continue; newcost = cost[mednum] + edgetag_cut_cost(em, mednum, adjnum, vertnum); @@ -553,18 +553,39 @@ void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *eed, int val) if (val) {BM_SetHFlag(eed, BM_SEAM);} else {BM_ClearHFlag(eed, BM_SEAM);} break; - case EDGE_MODE_TAG_CREASE: - if (val) {eed->crease = 1.0f;} - else {eed->crease = 0.0f;} + case EDGE_MODE_TAG_CREASE: + { + float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE); + + if (val) {*crease = 1.0f;} + else {*crease = 0.0f;} break; + } case EDGE_MODE_TAG_BEVEL: - if (val) {eed->bweight = 1.0f;} - else {eed->bweight = 0.0f;} + { + float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); + + if (val) {*bweight = 1.0f;} + else {*bweight = 0.0f;} break; + } } } -int edgetag_context_check(Scene *scene, BMEdge *eed) +static float bm_cdata_get_single_float(BMesh *bm, CustomData *cdata, void *element, int type) +{ + BMHeader *ele = element; + float *f; + + if (!CustomData_has_layer(cdata, type)) + return 0.0f; + + f = CustomData_bmesh_get(cdata, ele->data, type); + + return *f; +} + +int edgetag_context_check(Scene *scene, BMEditMesh *em, BMEdge *eed) { switch (scene->toolsettings->edge_mode) { case EDGE_MODE_SELECT: @@ -574,9 +595,9 @@ int edgetag_context_check(Scene *scene, BMEdge *eed) case EDGE_MODE_TAG_SHARP: return BM_TestHFlag(eed, BM_SHARP); case EDGE_MODE_TAG_CREASE: - return eed->crease ? 1 : 0; + return bm_cdata_get_single_float(em->bm, &em->bm->edata, eed, CD_CREASE) ? 1 : 0; case EDGE_MODE_TAG_BEVEL: - return eed->bweight ? 1 : 0; + return bm_cdata_get_single_float(em->bm, &em->bm->edata, eed, CD_BWEIGHT) ? 1 : 0; } return 0; } @@ -599,9 +620,9 @@ int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, BMEdge * } BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - eed->head.eflag2 = 0; + eed->head.flags[0].f = 0; if (BM_TestHFlag(eed, BM_SELECT)) { - eed->head.eflag2 |= ME_SEAM_DONE; + eed->head.flags[0].f |= ME_SEAM_DONE; } BMINDEX_SET(eed, totedge); @@ -650,10 +671,10 @@ int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, BMEdge * if (mednum == BMINDEX_GET(target)) break; - if (eed->head.eflag2 & ME_SEAM_DONE) + if (eed->head.flags[0].f & ME_SEAM_DONE) continue; - eed->head.eflag2 |= ME_SEAM_DONE; + eed->head.flags[0].f |= ME_SEAM_DONE; edgetag_add_adjacent(em, heap, mednum, BMINDEX_GET(eed->v1), nedges, edges, prevedge, cost); edgetag_add_adjacent(em, heap, mednum, BMINDEX_GET(eed->v2), nedges, edges, prevedge, cost); @@ -665,7 +686,7 @@ int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, BMEdge * BLI_heap_free(heap, NULL); BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - eed->head.eflag2 &= ~ME_SEAM_DONE; + eed->head.flags[0].f &= ~ME_SEAM_DONE; } if (mednum != BMINDEX_GET(target)) { @@ -681,7 +702,7 @@ int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, BMEdge * mednum = BMINDEX_GET(target); do { eed = EDBM_get_edge_for_index(em, mednum); - if (!edgetag_context_check(scene, eed)) { + if (!edgetag_context_check(scene, em, eed)) { allseams = 0; break; } diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 92cdc0e1ac6..4d5af4eb236 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -134,7 +134,7 @@ static void edgering_find_order(BMEditMesh *em, BMEdge *lasteed, BMEdge *eed, BMLoop *l, *l2; int rev; - l = eed->loop; + l = eed->l; /*find correct order for v[1]*/ if (!(BM_Edge_In_Face(l->f, eed) && BM_Edge_In_Face(l->f, lasteed))) { @@ -154,9 +154,9 @@ static void edgering_find_order(BMEditMesh *em, BMEdge *lasteed, BMEdge *eed, } l2 = BM_OtherFaceLoop(l->e, l->f, eed->v1); - rev = (l2 == (BMLoop*)l->head.prev); + rev = (l2 == (BMLoop*)l->prev); while (l2->v != lasteed->v1 && l2->v != lasteed->v2) { - l2 = rev ? (BMLoop*)l2->head.prev : (BMLoop*)l2->head.next; + l2 = rev ? (BMLoop*)l2->prev : (BMLoop*)l2->next; } if (l2->v == lastv1) { diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 7ce7f97260e..27312b83c14 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -90,7 +90,7 @@ void EDBM_stats_update(struct BMEditMesh *em); /* ******************** editface.c */ -int edgetag_context_check(Scene *scene, BMEdge *eed); +int edgetag_context_check(Scene *scene, BMEditMesh *em, BMEdge *eed); void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *eed, int val); int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, BMEdge *target); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index ded9004d9c6..36475eaeaa1 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -351,6 +351,17 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) { + /* + It should be ridiculously easy to extract the original verts that we want + and form the shape data. We can probably use the CD KEYINDEX layer (or + whatever I ended up calling it, too tired to check now), though this would + by necassity have to make some potentially ugly assumptions about the order + of the mesh data :-/ you can probably assume in 99% of cases that the first + element of a given index is the original, and any subsequent duplicates are + copies/interpolates, but that's an assumption that would need to be tested + and then predominantly stated in comments in a half dozen headers. + */ + if (ob->type==OB_MESH) { DerivedMesh *dm; Mesh *me= ob->data; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 04c73fce48c..addbc6d2387 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1367,7 +1367,6 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, StrokeCache *cache) Brush *brush = paint_brush(&sd->paint); PBVHNode **nodes= NULL; rctf mr; - ARegion *ar = cache->vc->ar; float xrad, yrad; int totnode; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 60ae10f596b..8dbaeed97fa 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1978,10 +1978,15 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba static int draw_dm_creases__setDrawOptions(void *userData, int index) { + BMEditMesh *em = userData; BMEdge *eed = EDBM_get_edge_for_index(userData, index); - - if (!BM_TestHFlag(eed, BM_HIDDEN) && eed->crease!=0.0) { - UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, eed->crease); + float *crease = bm_get_cd_float(&em->bm->edata, eed->head.data, CD_CREASE); + + if (!crease) + return 0; + + if (!BM_TestHFlag(eed, BM_HIDDEN) && *crease!=0.0) { + UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, *crease); return 1; } else { return 0; @@ -1996,10 +2001,15 @@ static void draw_dm_creases(BMEditMesh *em, DerivedMesh *dm) static int draw_dm_bweights__setDrawOptions(void *userData, int index) { + BMEditMesh *em = userData; BMEdge *eed = EDBM_get_edge_for_index(userData, index); + float *bweight = bm_get_cd_float(&em->bm->edata, eed->head.data, CD_BWEIGHT); - if (!BM_TestHFlag(eed, BM_HIDDEN) && eed->bweight!=0.0) { - UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, eed->bweight); + if (!bweight) + return 0; + + if (!BM_TestHFlag(eed, BM_HIDDEN) && *bweight!=0.0) { + UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, *bweight); return 1; } else { return 0; @@ -2007,10 +2017,15 @@ static int draw_dm_bweights__setDrawOptions(void *userData, int index) } static void draw_dm_bweights__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s) { + BMEditMesh *em = userData; BMVert *eve = EDBM_get_vert_for_index(userData, index); - - if (!BM_TestHFlag(eve, BM_HIDDEN) && eve->bweight!=0.0) { - UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, eve->bweight); + float *bweight = bm_get_cd_float(&em->bm->vdata, eve->head.data, CD_BWEIGHT); + + if (!bweight) + return; + + if (!BM_TestHFlag(eve, BM_HIDDEN) && *bweight!=0.0) { + UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, *bweight); bglVertex3fv(co); } } @@ -2483,7 +2498,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object glLineWidth(1); } - if(me->drawflag & ME_DRAWCREASES) { + if(me->drawflag & ME_DRAWCREASES && CustomData_has_layer(&em->bm->edata, CD_CREASE)) { draw_dm_creases(em, cageDM); } if(me->drawflag & ME_DRAWBWEIGHTS) { diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index f2c2c7ff4d4..e679310b224 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -185,8 +185,10 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) { if(BM_TestHFlag(eed, BM_SELECT)) { + float *f = bm_get_cd_float(&bm->edata, eed->head.data, CD_CREASE); + totedge++; - median[3]+= eed->crease; + median[3]+= f ? *f : 0.0f; } } @@ -393,12 +395,15 @@ static void v3d_editvertex_buts(const bContext *C, uiLayout *layout, View3D *v3d BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { if(BM_TestHFlag(eed, BM_SELECT)) { + float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE); + if (!crease) continue; + /* ensure the median can be set to zero or one */ - if(ve_median[3]==0.0f) eed->crease= 0.0f; - else if(ve_median[3]==1.0f) eed->crease= 1.0f; + if(ve_median[3]==0.0f) *crease= 0.0f; + else if(ve_median[3]==1.0f) *crease= 1.0f; else { - eed->crease+= median[3]; - CLAMP(eed->crease, 0.0, 1.0); + *crease+= median[3]; + CLAMP(*crease, 0.0, 1.0); } } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 48f28368a76..5adda8d09e5 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4116,7 +4116,7 @@ static BMLoop *get_next_loop(BMesh *bm, BMVert *v, BMLoop *l, firstl = l; do { l = BM_OtherFaceLoop(l->e, l->f, v); - if (l->radial.next->data == l) + if (l->radial_next == l) return NULL; if (l->e == nexte) { @@ -4152,7 +4152,7 @@ static BMLoop *get_next_loop(BMesh *bm, BMVert *v, BMLoop *l, return BM_OtherFaceLoop(l->e, l->f, v); } - l = l->radial.next->data; + l = l->radial_next; } while (l != firstl); if (i) @@ -4198,8 +4198,8 @@ static int createSlideVerts(TransInfo *t) BM_ITER(e, &iter2, em->bm, BM_EDGES_OF_VERT, v) { if (BM_TestHFlag(e, BM_SELECT)) { /*BMESH_TODO: this is probably very evil, - set v->edge to a selected edge*/ - v->edge = e; + set v->e to a selected edge*/ + v->e = e; numsel++; } @@ -4243,20 +4243,20 @@ static int createSlideVerts(TransInfo *t) if (!v) break; - if (!v->edge) + if (!v->e) continue; first = v; /*walk along the edge loop*/ - e = v->edge; + e = v->e; /*first, rewind*/ numsel = 0; do { e = get_other_edge(bm, v, e); if (!e) { - e = v->edge; + e = v->e; break; } @@ -4266,13 +4266,13 @@ static int createSlideVerts(TransInfo *t) break; v = BM_OtherEdgeVert(e, v); - } while (e != first->edge); + } while (e != first->e); BMINDEX_SET(v, 0); l1 = l2 = l = NULL; - l1 = e->loop; - l2 = e->loop->radial.next->data; + l1 = e->l; + l2 = e->l->radial_next; l = BM_OtherFaceLoop(l1->e, l1->f, v); sub_v3_v3v3(vec, BM_OtherEdgeVert(l->e, v)->co, v->co); @@ -4339,7 +4339,7 @@ static int createSlideVerts(TransInfo *t) BMINDEX_SET(v, 0); BMINDEX_SET(v2, 0); - } while (e != first->edge && l1); + } while (e != first->e && l1); } //EDBM_clear_flag_all(em, BM_SELECT); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d280b23752a..f47a2414a24 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -368,6 +368,9 @@ static void createTransEdge(bContext *C, TransInfo *t) { BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { if(!BM_TestHFlag(eed, BM_HIDDEN) && (BM_TestHFlag(eed, BM_SELECT) || propmode)) { + float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); + float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE); + /* need to set center for center calculations */ add_v3_v3v3(td->center, eed->v1->co, eed->v2->co); mul_v3_fl(td->center, 0.5f); @@ -384,12 +387,12 @@ static void createTransEdge(bContext *C, TransInfo *t) { td->ext = NULL; if (t->mode == TFM_BWEIGHT) { - td->val = &(eed->bweight); - td->ival = eed->bweight; + td->val = bweight; + td->ival = bweight ? *bweight : 1.0f; } else { - td->val = &(eed->crease); - td->ival = eed->crease; + td->val = crease; + td->ival = crease ? *crease : 0.0f; } td++; @@ -1922,7 +1925,7 @@ static void editmesh_set_connectivity_distance(EditMesh *em, float mtx[][3]) VECCOPY(centout, cent); } -#define VertsToTransData(t, td, em, eve) \ +#define VertsToTransData(t, td, em, eve, bweight) \ td->flag = 0;\ td->loc = eve->co;\ VECCOPY(td->center, td->loc);\ @@ -1940,8 +1943,8 @@ static void editmesh_set_connectivity_distance(EditMesh *em, float mtx[][3]) td->val = NULL;\ td->extra = NULL;\ if (t->mode == TFM_BWEIGHT) {\ - td->val = &(eve->bweight);\ - td->ival = eve->bweight;\ + td->val = bweight;\ + td->ival = bweight ? *(bweight) : 1.0f;\ } #if 0 @@ -2122,6 +2125,7 @@ static void set_crazyspace_quats(BMEditMesh *em, float *origcos, float *mappedco } void createTransBMeshVerts(TransInfo *t, BME_Mesh *bm, BME_TransData_Head *td) { +#if 0 BME_Vert *v; BME_TransData *vtd; TransData *tob; @@ -2144,6 +2148,8 @@ void createTransBMeshVerts(TransInfo *t, BME_Mesh *bm, BME_TransData_Head *td) { /* since td is a memarena, it can hold more transdata than actual elements * (i.e. we can't depend on td->len to determine the number of actual elements) */ t->total = i; +#endif + t->total = 0; } static void createTransEditVerts(bContext *C, TransInfo *t) @@ -2305,7 +2311,9 @@ static void createTransEditVerts(bContext *C, TransInfo *t) for(a=0; eve; eve=BMIter_Step(&iter), a++) { if(!BM_TestHFlag(eve, BM_HIDDEN)) { if(propmode || selstate[a]) { - VertsToTransData(t, tob, bm, eve); + float *bweight = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_BWEIGHT); + + VertsToTransData(t, tob, bm, eve, bweight); /* pinned */ if(BM_TestHFlag(eve,BM_PINNED)) tob->flag |= TD_SKIP; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 536ebfc27d3..bbff86a8b11 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -631,8 +631,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if(BM_TestHFlag(efa, BM_SELECT)) { VECADD(normal, normal, efa->no); - sub_v3_v3v3(vec, efa->loopbase->v->co, - ((BMLoop*)efa->loopbase->head.next)->v->co); + sub_v3_v3v3(vec, ((BMLoopList*)efa->loops.first)->first->v->co, + (((BMLoopList*)efa->loops.first)->first->next)->v->co); VECADD(plane, plane, vec); } } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index e96fda1eca6..f13ea513987 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -631,9 +631,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glEnd(); /*glBegin(GL_LINE_STRIP); - luv = CustomData_bmesh_get(&em->bm->ldata, efa->loopbase->head.data, CD_MLOOPUV); + luv = CustomData_bmesh_get(&em->bm->ldata, efa->lbase->head.data, CD_MLOOPUV); glVertex2fv(luv->uv); - luv = CustomData_bmesh_get(&em->bm->ldata, efa->loopbase->head.next->data, CD_MLOOPUV); + luv = CustomData_bmesh_get(&em->bm->ldata, efa->lbase->next->head.data, CD_MLOOPUV); glVertex2fv(luv->uv); glEnd();*/ @@ -697,7 +697,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); glVertex2fv(luv->uv); - luv = CustomData_bmesh_get(&em->bm->ldata, l->head.next->data, CD_MLOOPUV); + luv = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); glVertex2fv(luv->uv); i += 1; } @@ -719,7 +719,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); glVertex2fv(luv->uv); - luv = CustomData_bmesh_get(&em->bm->ldata, l->head.next->data, CD_MLOOPUV); + luv = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); glVertex2fv(luv->uv); i += 1; } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index e7ae94f97c4..1f97aab8e1a 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -288,13 +288,13 @@ int uvedit_edge_selected(BMEditMesh *em, Scene *scene, BMLoop *l) return BM_TestHFlag(l->e, BM_SELECT); } else return BM_TestHFlag(l->v, BM_SELECT) && - BM_TestHFlag(((BMLoop*)l->head.next)->v, BM_SELECT); + BM_TestHFlag(((BMLoop*)l->next)->v, BM_SELECT); } else { MLoopUV *luv1, *luv2; luv1 = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - luv2 = CustomData_bmesh_get(&em->bm->ldata, l->head.next->data, CD_MLOOPUV); + luv2 = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); return (luv1->flag & MLOOPUV_VERTSEL) && (luv2->flag & MLOOPUV_VERTSEL); } @@ -319,7 +319,7 @@ void uvedit_edge_select(BMEditMesh *em, Scene *scene, BMLoop *l) MLoopUV *luv1, *luv2; luv1 = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - luv2 = CustomData_bmesh_get(&em->bm->ldata, l->head.next->data, CD_MLOOPUV); + luv2 = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); luv1->flag |= MLOOPUV_VERTSEL; luv2->flag |= MLOOPUV_VERTSEL; @@ -345,7 +345,7 @@ void uvedit_edge_deselect(BMEditMesh *em, Scene *scene, BMLoop *l) MLoopUV *luv1, *luv2; luv1 = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - luv2 = CustomData_bmesh_get(&em->bm->ldata, l->head.next->data, CD_MLOOPUV); + luv2 = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); luv1->flag &= ~MLOOPUV_VERTSEL; luv2->flag &= ~MLOOPUV_VERTSEL; @@ -592,7 +592,7 @@ static void find_nearest_uv_edge(Scene *scene, Image *ima, BMEditMesh *em, float i = 0; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - nextluv = CustomData_bmesh_get(&em->bm->ldata, l->head.next->data, CD_MLOOPUV); + nextluv = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); dist= dist_to_line_segment_v2(co, luv->uv, nextluv->uv); @@ -601,12 +601,12 @@ static void find_nearest_uv_edge(Scene *scene, Image *ima, BMEditMesh *em, float hit->efa= efa; hit->l = l; - hit->nextl = (BMLoop*)l->head.next; + hit->nextl = (BMLoop*)l->next; hit->luv = luv; hit->nextluv = nextluv; hit->lindex = i; hit->vert1 = BMINDEX_GET(hit->l->v); - hit->vert2 = BMINDEX_GET(((BMLoop*)hit->l->head.next)->v); + hit->vert2 = BMINDEX_GET(((BMLoop*)hit->l->next)->v); mindist = dist; } @@ -753,9 +753,9 @@ static void find_nearest_uv_vert(Scene *scene, Image *ima, BMEditMesh *em, mindist= dist; hit->l = l; - hit->nextl = (BMLoop*)l->head.next; + hit->nextl = (BMLoop*)l->next; hit->luv = luv; - hit->nextluv = CustomData_bmesh_get(&em->bm->ldata, l->head.next->data, CD_MLOOPUV); + hit->nextluv = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); hit->tf= tf; hit->efa= efa; hit->lindex = i; diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 28dd4911ffd..831dbd6bdaa 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -27,8 +27,12 @@ FILE(GLOB SRC intern/*.c) SET(INC - . ../blenlib ../blenkernel ../makesdna ../include - ../../../extern/glew/include ../../../intern/guardedalloc ../../../intern/smoke/extern ../imbuf) + . ../blenlib ../blenkernel ../makesdna ../makesrna ../include + ../../../extern/glew/include ../bmesh ../../../intern/guardedalloc ../../../intern/smoke/extern ../imbuf) + +IF(WIN32) + INCLUDE_DIRECTORIES(${PTHREADS_INC}) +ENDIF(WIN32) ADD_DEFINITIONS(-DGLEW_STATIC) diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 23fb50508b6..52822b67b68 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -89,7 +89,9 @@ typedef struct CustomData { #define CD_TEXTURE_MCOL 25 #define CD_SHAPE_KEYINDEX 26 #define CD_SHAPEKEY 27 -#define CD_NUMTYPES 28 +#define CD_BWEIGHT 28 +#define CD_CREASE 29 +#define CD_NUMTYPES 30 /* Bits for CustomDataMask */ #define CD_MASK_MVERT (1 << CD_MVERT) @@ -118,9 +120,10 @@ typedef struct CustomData { #define CD_MASK_WEIGHT_MLOOPCOL (1 << CD_WEIGHT_MLOOPCOL) #define CD_MASK_SHAPE_KEYINDEX (1 << CD_SHAPE_KEYINDEX) #define CD_MASK_SHAPEKEY (1 << CD_SHAPEKEY) - /* derivedmesh wants CustomDataMask for weightpaint too, is not customdata though */ #define CD_MASK_WEIGHTPAINT (1 << CD_WEIGHTPAINT) +#define CD_MASK_BWEIGHT (1 << CD_BWEIGHT) +#define CD_MASK_CREASE (1 << CD_CREASE) /* CustomData.flag */ diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 58931165638..6a773da3d1f 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -39,7 +39,7 @@ SET(SRC ../../../../intern/guardedalloc/intern/mallocn.c ../../../../intern/guardedalloc/intern/mmap_win.c) -INCLUDE_DIRECTORIES(../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../ikplugin ../../windowmanager ../../editors/include ../../gpu ../../imbuf ../../render/extern/include .) +INCLUDE_DIRECTORIES(../../../../intern/audaspace/intern ../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../ikplugin ../../windowmanager ../../editors/include ../../bmesh ../../gpu ../../imbuf ../../render/extern/include .) FILE(GLOB INC_FILES ../*.h ../../makesdna/*.h) IF(NOT WITH_PYTHON) diff --git a/source/blender/quicktime/CMakeLists.txt b/source/blender/quicktime/CMakeLists.txt index f1b2a121b50..2b5c8a53e9b 100644 --- a/source/blender/quicktime/CMakeLists.txt +++ b/source/blender/quicktime/CMakeLists.txt @@ -45,6 +45,7 @@ SET(INC ../render/extern/include ../include ../windowmanager + ../../../intern/audaspace/intern ) SET(INC ${INC} ${QUICKTIME_INC}) diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index 5dc89af5632..0f72546724e 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -28,7 +28,7 @@ FILE(GLOB SRC intern/source/*.c intern/raytrace/*.cpp) SET(INC intern/include ../../../intern/guardedalloc ../blenlib ../makesdna - extern/include ../blenkernel ../imbuf + extern/include ../blenkernel ../imbuf ../bmesh ../include ../../kernel/gen_messaging ../blenloader ../../../intern/smoke/extern ../makesrna diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 6db32f8bba9..d880f4fc7d9 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -39,7 +39,7 @@ SET(INC . ../python ../nodes ../gpu - ../blenfont + ../blenfont ../bmesh ${OPENGL_INCLUDE_DIR} ) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index e30716f16bf..7ead3868fa4 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -107,16 +107,6 @@ ADD_EXECUTABLE(blender ${EXETYPE} ${EXESRC}) SET(TARGETDIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}) -<<<<<<< .working -IF(UNIX) - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/plugins ${TARGETDIR}/ - #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/ - ) -ENDIF(UNIX) -======= IF(UNIX) ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD @@ -125,24 +115,6 @@ ENDIF(UNIX) #COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/text/* ${TARGETDIR}/ ) ENDIF(UNIX) ->>>>>>> .merge-right.r23146 - -<<<<<<< .working -IF(UNIX AND NOT APPLE) - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND rm -Rf ${TARGETDIR}/.blender - COMMAND mkdir ${TARGETDIR}/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/.blender/ - COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;" - ) -ENDIF(UNIX AND NOT APPLE) -======= IF(UNIX AND NOT APPLE) # Local installation, "make install" can be done after this optionally @@ -188,14 +160,6 @@ ENDIF(UNIX AND NOT APPLE) COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/site-packages COMMAND mkdir ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/site-packages # python needs it. ->>>>>>> .merge-right.r23146 - -<<<<<<< .working -IF(APPLE) - SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) - SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) - SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist) -======= COMMAND rm -f ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/lib-dynload/_tkinter.so COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "test" -prune -exec rm -rf {} "\;" COMMAND find ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION} -name "*.py?" -exec rm -rf {} "\;" @@ -231,78 +195,10 @@ IF(APPLE) # end "make install" ENDIF(UNIX AND NOT APPLE) ->>>>>>> .merge-right.r23146 - -<<<<<<< .working - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND cp -R ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/ - COMMAND cp -R ${SOURCEDIR}/Contents/PkgInfo ${TARGETDIR}/blender.app/Contents/ - COMMAND cp -R ${SOURCEDIR}/Contents/Resources ${TARGETDIR}/blender.app/Contents/ - COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO} - COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/.blender - COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/Resources/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/Resources/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/ui ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/io ${TARGETDIR}/blender.app/Contents/MacOS/.blender/ - COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/ - COMMAND unzip -q ${LIBDIR}/release/python.zip -d ${TARGETDIR}/blender.app/Contents/MacOS/.blender/python/ - COMMAND find ${TARGETDIR}/blender.app -name CVS -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name CVS.sandboxinfo -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name .DS_Store -prune -exec rm -rf {} "\;" - COMMAND find ${TARGETDIR}/blender.app -name .svn -prune -exec rm -rf {} "\;" - ) -ENDIF(APPLE) -======= IF(APPLE) SET(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) SET(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) SET(TARGETINFO ${TARGETDIR}/blender.app/Contents/Info.plist) ->>>>>>> .merge-right.r23146 - -<<<<<<< .working -IF(WIN32) - FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR) - - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND if not exist \"${TARGETDIR}\\.blender\" mkdir \"${TARGETDIR}\\.blender\" - COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\" - COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\" - COMMAND if not exist \"${TARGETDIR}\\.blender\\ui\" mkdir \"${TARGETDIR}\\.blender\\ui\" - COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\ui\\*.*\" \"${TARGETDIR}\\.blender\\ui\" - COMMAND xcopy /E /Y \"${WIN_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\" - COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python26.zip\" \"${TARGETDIR}\\\" - ) - - FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR) - - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND copy /Y \"${WIN_LIBDIR}\\gettext\\lib\\gnu_gettext.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\png\\lib\\libpng.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\sdl\\lib\\SDL.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\zlib\\lib\\zlib.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\tiff\\lib\\libtiff.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\python\\lib\\python26_d.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" - ) -======= ADD_CUSTOM_COMMAND( TARGET blender POST_BUILD MAIN_DEPENDENCY blender COMMAND cp -Rf ${SOURCEINFO} ${TARGETDIR}/blender.app/Contents/ @@ -346,22 +242,9 @@ IF(WIN32) COMMAND find ${TARGETDIR}/blender.app -name __MACOSX -prune -exec rm -rf {} "\;" ) ENDIF(APPLE) ->>>>>>> .merge-right.r23146 - -<<<<<<< .working - IF(WITH_INTERNATIONAL) -======= IF(WIN32) FILE(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} WIN_SOURCE_DIR) ->>>>>>> .merge-right.r23146 -<<<<<<< .working - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND copy /Y \"${WIN_LIBDIR}\\iconv\\lib\\iconv.dll\" \"${TARGETDIR}\\\" - ) -======= ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDENCY blender @@ -378,32 +261,9 @@ IF(WIN32) # TODO, copy python bundle # COMMAND copy /Y \"${WIN_SOURCE_DIR}\\release\\windows\\extra\\python31.zip\" \"${TARGETDIR}\\\" ) ->>>>>>> .merge-right.r23146 -<<<<<<< .working - ENDIF(WITH_INTERNATIONAL) - - IF(WITH_FFMPEG) -======= FILE(TO_NATIVE_PATH "${LIBDIR}" WIN_LIBDIR) ->>>>>>> .merge-right.r23146 -<<<<<<< .working - ADD_CUSTOM_COMMAND(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avcodec-52.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avformat-52.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avdevice-52.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\avutil-50.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaac-0.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libfaad-2.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libmp3lame-0.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\libx264-67.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\swscale-0.dll\" \"${TARGETDIR}\\\" - COMMAND copy /Y \"${WIN_LIBDIR}\\ffmpeg\\lib\\xvidcore.dll\" \"${TARGETDIR}\\\" - ) -======= ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD MAIN_DEPENDENCY blender @@ -419,12 +279,6 @@ IF(WIN32) COMMAND copy /Y \"${WIN_LIBDIR}\\pthreads\\lib\\pthreadVC2.dll\" \"${TARGETDIR}\\\" COMMAND copy /Y \"${WIN_LIBDIR}\\samplerate\\lib\\libsamplerate-0.dll\" \"${TARGETDIR}\\\" ) ->>>>>>> .merge-right.r23146 - ENDIF(WITH_FFMPEG) -ENDIF(WIN32) - -<<<<<<< .working -======= IF(WITH_INTERNATIONAL) ADD_CUSTOM_COMMAND(TARGET blender POST_BUILD @@ -475,12 +329,8 @@ ENDIF(WIN32) ) ENDIF(WITH_OPENAL) - - ENDIF(WIN32) -ENDIF(WITH_INSTALL) ->>>>>>> .merge-right.r23146 ADD_DEPENDENCIES(blender makesdna) FILE(READ ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt BLENDER_LINK_LIBS) @@ -496,77 +346,6 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") #IF(UNIX) -<<<<<<< .working - # Sort libraries - SET(BLENDER_SORTED_LIBS - bf_windowmanager - bf_editors - bf_decimation - blender_BSP - bf_ghost - bf_string - blender_render - blender_ONL - bf_python - bf_gen_python - bf_blenkernel - bf_nodes - bf_bmesh - bf_gpu - bf_blenloader - bf_blenpluginapi - bf_imbuf - bf_blenlib - bf_avi - bf_cineon - bf_openexr - bf_dds - bf_readblenfile - blender_bop - bf_kernel - bf_decimation - bf_elbeem - bf_IK - bf_memutil - bf_guardedalloc - blender_CTR - bf_moto - bf_windowmanager - bf_editors - bf_blroutines - bf_converter - bf_dummy - bf_bullet - bf_smoke - bf_common - bf_ketsji - bf_logic - bf_rasterizer - bf_oglrasterizer - bf_expressions - bf_scenegraph - bf_moto - bf_blroutines - kx_network - bf_kernel - bf_ngnetwork - extern_bullet - bf_loopbacknetwork - bf_common - bf_moto - bf_python - bf_gen_python - bf_quicktime - extern_binreloc - extern_glew - extern_libopenjpeg - bf_videotex - bf_rna - bf_dna - bf_blenfont - bf_soundsystem - ) -======= # Sort libraries SET(BLENDER_SORTED_LIBS bf_windowmanager @@ -580,7 +359,8 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") bf_python bf_gen_python bf_ikplugin - bf_blenkernel + bf_bmesh + bf_blenkernel bf_nodes bf_gpu bf_blenloader @@ -640,10 +420,6 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") bf_blenfont bf_audaspace ) ->>>>>>> .merge-right.r23146 - -<<<<<<< .working -======= IF(WITH_CXX_GUARDEDALLOC) SET(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} bf_guardedalloc_cpp) ENDIF(WITH_CXX_GUARDEDALLOC) @@ -653,7 +429,6 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") ENDIF(WITH_QUICKTIME) ->>>>>>> .merge-right.r23146 FOREACH(SORTLIB ${BLENDER_SORTED_LIBS}) SET(REMLIB ${SORTLIB}) FOREACH(SEARCHLIB ${BLENDER_LINK_LIBS}) diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 7a6fc044637..e0a29cb8027 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -68,8 +68,7 @@ * When it is about to evaluate the pose, set the KX object position in the obmat of the corresponding * Blender objects and restore after the evaluation. */ -void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) -{ +void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) { bPose *out; bPoseChannel *pchan, *outpchan; GHash *ghash; diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index 616c205732c..5e68c975e76 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -20,6 +20,7 @@ incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu' incs += ' #source/blender/windowmanager' incs += ' #source/blender/makesrna' incs += ' #source/blender/ikplugin' +incs += ' #source/blender/bmesh' incs += ' ' + env['BF_BULLET_INC'] diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 58dc8a314bf..1845fda2081 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -19,6 +19,7 @@ incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions #source/ga incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common #source/gameengine/Physics/Bullet' incs += ' #source/gameengine/Physics/Dummy' incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu' +incs += ' #source/blender/bmesh' incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index 976c6825351..2554ada2e8c 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -14,6 +14,7 @@ incs += ' #source/gameengine/Expressions' incs += ' #source/gameengine/GameLogic' incs += ' #source/gameengine/SceneGraph' incs += ' #source/blender/makesdna' +incs += ' #source/blender/bmesh' incs += ' #source/blender/blenkernel' incs += ' #source/blender/blenlib' incs += ' #intern/guardedalloc' diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index 68e6789c05e..c09edff8437 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -8,6 +8,6 @@ defs = [ 'GLEW_STATIC' ] incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines ' incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC'] incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #source/blender/makesdna #source/blender/blenkernel' -incs += ' #intern/guardedalloc #source/blender/blenlib' +incs += ' #intern/guardedalloc #source/blender/blenlib #source/blender/bmesh' env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), defines = defs, libtype=['core','player'], priority=[350,75], cxx_compileflags=env['BGE_CXXFLAGS']) diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index 8bc99f1596e..143727e0ab0 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('*.cpp') -incs = '. #intern/guardedalloc #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/gameengine/SceneGraph #source/blender/blenkernel #source/blender/makesdna' +incs = '. #intern/guardedalloc #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/gameengine/SceneGraph #source/blender/blenkernel #source/blender/makesdna #source/blender/bmesh' defs = [ 'GLEW_STATIC' ]