wip commit; DO NOT USE. almost done with phase 1 of this restructuring, basically...
authorJoseph Eagar <joeedh@gmail.com>
Wed, 14 Jul 2010 22:06:10 +0000 (22:06 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Wed, 14 Jul 2010 22:06:10 +0000 (22:06 +0000)
93 files changed:
intern/guardedalloc/MEM_guardedalloc.h
intern/guardedalloc/intern/mallocn.c
source/blender/CMakeLists.txt
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_utildefines.h
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/intern/BME_Customdata.c
source/blender/blenkernel/intern/BME_conversions.c
source/blender/blenkernel/intern/BME_eulers.c
source/blender/blenkernel/intern/BME_mesh.c
source/blender/blenkernel/intern/BME_structure.c
source/blender/blenkernel/intern/BME_tools.c
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/editderivedbmesh.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/modifiers_bmesh.c
source/blender/blenlib/BLI_array.h
source/blender/blenlib/BLI_ghash.h
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/BLI_mempool.h
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/intern/BLI_cellalloc.c
source/blender/blenlib/intern/BLI_ghash.c
source/blender/blenlib/intern/BLI_mempool.c
source/blender/blenlib/intern/DLRB_tree.c
source/blender/blenlib/intern/edgehash.c
source/blender/blenloader/CMakeLists.txt
source/blender/bmesh/bmesh.h
source/blender/bmesh/bmesh_iterators.h
source/blender/bmesh/bmesh_operator_api.h
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_eulers.c
source/blender/bmesh/intern/bmesh_interp.c
source/blender/bmesh/intern/bmesh_iterators.c
source/blender/bmesh/intern/bmesh_marking.c
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_mods.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_polygon.c
source/blender/bmesh/intern/bmesh_private.h
source/blender/bmesh/intern/bmesh_queries.c
source/blender/bmesh/intern/bmesh_structure.c
source/blender/bmesh/intern/bmesh_structure.h
source/blender/bmesh/intern/bmesh_to_editmesh.c
source/blender/bmesh/intern/bmesh_walkers.c
source/blender/bmesh/intern/editmesh_to_bmesh.c
source/blender/bmesh/operators/bmesh_dupeops.c
source/blender/bmesh/operators/connectops.c
source/blender/bmesh/operators/createops.c
source/blender/bmesh/operators/dissolveops.c
source/blender/bmesh/operators/edgesplitop.c
source/blender/bmesh/operators/extrudeops.c
source/blender/bmesh/operators/join_triangles.c
source/blender/bmesh/operators/mesh_conv.c
source/blender/bmesh/operators/removedoubles.c
source/blender/bmesh/operators/subdivideop.c
source/blender/bmesh/operators/utils.c
source/blender/bmesh/tools/BME_bevel.c
source/blender/bmesh/tools/BME_dupe_ops.c
source/blender/bmesh/tools/BME_duplicate.c
source/blender/bmesh/tools/BME_extrude.c
source/blender/editors/CMakeLists.txt
source/blender/editors/include/ED_mesh.h
source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/mesh/editbmesh_bvh.c
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/loopcut.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/object/object_modifier.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/gpu/CMakeLists.txt
source/blender/makesdna/DNA_customdata_types.h
source/blender/makesrna/intern/CMakeLists.txt
source/blender/quicktime/CMakeLists.txt
source/blender/render/CMakeLists.txt
source/blender/windowmanager/CMakeLists.txt
source/creator/CMakeLists.txt
source/gameengine/Converter/BL_ArmatureObject.cpp
source/gameengine/Converter/SConscript
source/gameengine/Ketsji/SConscript
source/gameengine/Physics/Bullet/SConscript
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
source/gameengine/Rasterizer/SConscript

index 69bb9347df747a9f48f6355e8ca8ac8337438f62..1d001ea6074e6efb6af3ee08f1567759307ffbef 100644 (file)
@@ -176,7 +176,7 @@ typedef struct MemHead {
 } MemHead;
 
 typedef struct MemTail {
-       int tag3, pad;
+       int tag3, tag4;
 } MemTail;
 
 /*memory bias to hopefully account 
index 33ca1ba9a9791faa5b1a9089d13a5f3ecbd4c021..42f5443aef2352ba5aa81415deb7b3747b296507 100644 (file)
@@ -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);
 
index b0c88a48536eccb8acff59d759b90691bbca4cb5..b7686752882ea7a226c5e6b77f61207f8bbd84a2 100644 (file)
@@ -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)
index 4a09961388772d2b30e39263e3bff65fc57a3894..1440176f1d91bcde38cb5dc58a14dcff5d76977f 100644 (file)
@@ -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 {
index 1ad411b4c898372da601f376daa5b580922ecbd2..f9252eac875de378cb5d8b3da84d37951e9c54e4 100644 (file)
@@ -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; _i<size; _i++) *_c++ = val;}
-
 #endif
index da5e73bbb45043336f2f0b10e850b1922537bc83..801abe7324d3624b9afd17e01138cbe6ae5629e4 100644 (file)
 FILE(GLOB SRC intern/*.c)
 
 SET(INC 
-       . ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna
+       . ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna ../modifiers
        ../render/extern/include ../../../intern/decimation/extern
        ../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern
-       ../../../intern/iksolver/extern ../blenloader ../ikplugin
+       ../../../intern/iksolver/extern ../blenloader ../ikplugin ../bmesh
        ../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern
        ../../../intern/bsp/extern ../blenfont
        ../../../intern/audaspace/intern
@@ -38,6 +38,7 @@ SET(INC
        ${ZLIB_INC}
 )
 
+
 ADD_DEFINITIONS(-DGLEW_STATIC)
 
 IF(WITH_BULLET)
index 9caffd162f36bdb9496b082296f83da1d4d18200..d70478bac210d4930aa67ce0f7d7688a52165394 100644 (file)
@@ -1,3 +1,4 @@
+#if 0
 /**
  * BME_customdata.c    jan 2007
  *
@@ -197,3 +198,4 @@ void BME_CD_set_default(BME_CustomData *data, void **block)
                        typeInfo->set_default((char*)*block + offset, 1);
        }
 }
+#endif
index 160a073be806ba3a67bcb6fd66ec77552d057645..4181825acb50d2ea9945a1b622236eb26d325673 100644 (file)
@@ -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
index 647671d0ed8822ec9b436f4aa2ef28c618c8f22e..9c83f6aaf6581025e17098bc12d29c938424337e 100644 (file)
@@ -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;i<len;i++){
                        curvert = vlist[i];
                        l = BME_create_loop(bm,curvert,NULL,f,NULL);
-                       if(!(f->loopbase)) 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; i<len; i++, l=l->next){
                        /*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; i<radlen; i++, killoop = BME_radial_nextloop(killoop)){
+                               radlen = BME_cycle_length(&(ke->l->radial));
+                               for(i=0,killoop = ke->l; i<radlen; i++, killoop = BME_radial_nextloop(killoop)){
                                        /*relink loops and fix vertex pointer*/
                                        killoop->next->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(i<radlen){
                                        bm->lpar[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; i<radlen; i++, nextl = BME_radial_nextloop(nextl)){
-                               edok = BME_cycle_validate(nextl->f->len,nextl->f->loopbase);
+                       for(i=0,nextl = oe->l; i<radlen; i++, nextl = BME_radial_nextloop(nextl)){
+                               edok = BME_cycle_validate(nextl->f->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
index f1f9f27031b6f8894d733b095465891dada1e62e..e9a1284809ab97f81d6c3323c4ede2d9bab26653 100644 (file)
@@ -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
index da0ce4da43b1957128e1b44976b98e8c5f99c171..bc14e5d37d6d3928f88616b17e3db6ba67ae61b7 100644 (file)
@@ -1,3 +1,4 @@
+#if 0
 /**
  * BME_structure.c    jan 2007
  *
@@ -31,7 +32,7 @@
  *
  * ***** END GPL LICENSE BLOCK *****
  */
-
+#if 0
 #include <limits.h>
 #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; i<len; i++){
+               for(i = 0, curedge=v->e; i<len; i++){
                        if(tflag){
                                if(curedge->tflag1 == 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; i<len; i++){
+               for(i = 0, curedge=v->e; i<len; i++){
                        if(curedge == e) return 1;
                        else curedge=BME_disk_nextedge(curedge, v);
                }
@@ -578,12 +579,12 @@ int BME_disk_hasedge(BME_Vert *v, BME_Edge *e){
 /*end disk cycle routines*/
 
 BME_Loop *BME_radial_nextloop(BME_Loop *l){
-       return (BME_Loop*)(l->radial.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
index fe82d2dab956f358dc7cdb5e3b134783a1f60af5..483e7ad150ec274a87cfe84e95e1ef9d044614c1 100644 (file)
@@ -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
index fce6b5ae9fcfefbe53661543c2290cb7d0ab3926..3235ccbbaa5cffcd8c149e9efb743b76769932bb 100644 (file)
@@ -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;
        }
index 89fb01dc5c7d7ad4212a667084a555837bf98471..9ee4b66b194f9baea2e7c6f657123deb182dddfb 100644 (file)
@@ -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);
index 6f133f85b7f80f5758359b3bfb1165566a2087c0..1cf8be330e6492ad6ee073bddda1272f2c615a62 100644 (file)
@@ -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);
        }
 }
 
index d1a503b36dd7a4159ed57632e21279dc0d14eccc..3063d42cbe5c533b5f906d33ae017a1fd9c0f619 100644 (file)
@@ -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);
 
index d5696dd03d4ef6b0e0d42917df0cf9c213a263c8..20e8542fb56c6f3d6a7598407ee0496e12adf5e5 100644 (file)
@@ -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;
 }
 
index 4fde1d45dcbcb3fdefb71a6c4e8b29f0818e64e5..250a272015ea5186c054ef460cb8d0e6b14b5b37 100644 (file)
@@ -152,7 +152,6 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing)
        for (i=0; i<totvert; i++, mv++) {
                v = BM_Make_Vert(bm, mv->co, 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; i<totedge; i++, me++) {
                e = BM_Make_Edge(bm, vtable[me->v1], 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);
index c01d821cb8b94ee3eaa0e466c059b71a9dea0311..7c1dfb1d3a44795ef477899d48856a030b152856 100644 (file)
@@ -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)
index 2d37438a9441eda9d24c3cb218327c06e02332bd..56f1f40be3365668217222420ca1611fe260bc39 100644 (file)
 #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
index fc2d257707a989a6bcb6800bd34c916605e5699e..ee7deb19544f9ef9091559e63672653af360f31d 100644 (file)
@@ -34,6 +34,8 @@ extern "C" {
 
 #ifdef BLI_MATH_INLINE
 #include "intern/math_vector_inline.c"
+#else
+#define MINLINE
 #endif
 
 /************************************* Init ***********************************/
index a9f5d9c6200eb2054306ad2377435f81d93e9e6b..c7be8f50cf35e0f2264e38ee642a5517a8fb011d 100644 (file)
@@ -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
+
+/*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);
+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
 }
index fec5f1803eb07c7233134c063bd9f33d429e9573..75e36895abe857a1866346083d5e867b1c99cf72 100644 (file)
@@ -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'
index 1244fa32d48febf076da4baf3e7cd4a195f12a45..715c66fae7b59476142d06d6e6133ed1e1765793 100644 (file)
@@ -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]);
index d5617cecc270d6e78dcc9b9e4d1043807a482c93..6ef8d9e5f1934f5c02da9d5ea548da1aa62cd9f6 100644 (file)
@@ -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;
index 1ad685b34f23c9e31a358b4f6585673ca2401ac2..7eec62c74949394b43e32ff8429446d8ca197247 100644 (file)
 #include "BLI_linklist.h"
 
 #include "DNA_listBase.h"
+#include "DNA_ID.h"
 
 #include <string.h> 
 
+#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;
index 9b38289f15b92428de500606def73f250b56c9f8..69c9cc7e522593f80544a0d1a19e29f392a0196c 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_dlrbTree.h"
 
-#include "DNA_listBase.h"
-
 /* *********************************************** */
 /* Tree API */
 
index a32666757a30d86bbea8f8db130c8e98a94be67e..1f70a34329fad5a03540c13d11efe4dab25b9aa3 100644 (file)
@@ -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;
 }
index cae0fccd12a89be3c389cfc07debbea01c0bf9ac..29b81a6f11b2db58b69407d2acaa86a73ef8298c 100644 (file)
@@ -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}
 )
index 0bdeaa97e4a5a57a4f503d71ddc36438768dbce1..53d724d6e8def4c26df7c65528ee28775f0e15fb 100644 (file)
@@ -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
 #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
index cae022d66bddf70853ac5ca7313e1f6077e13659..16127f54e9d11b20b5da893a24e78dd51012ebf2 100644 (file)
@@ -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"
 #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;
index 820f43a3094189c230c33cd69ba445ec299934c6..2bf091a3cf7b9f5931ee1c119af8da8e98d2cb5c 100644 (file)
@@ -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
index c444927824abdb62da9c42acfa7ac726ef0b7b7e..2364f6d554b3f8fcdbff4ed8ce2172f0f074578c 100644 (file)
 #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; i<len; i++) {
+               bmesh_api_setflag(edges[i], _FLAG_MF);
        }
 
-       if(nodouble) {
-               if(len > 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; i<len; i++) {
-                       if (!BMO_TestFlag
-               }*/
-
-               /*clear flags first*/
-               for(i = 0; i < len; i++){
-                       BMO_ClearFlag(bm, edges[i]->v1, BM_EDGEVERT);
-                       BMO_ClearFlag(bm, edges[i]->v2, BM_EDGEVERT);
-               }
+       BLI_array_append(verts, edges[0]->v1);
+
+       v = edges[0]->v2;
+       e = edges[0];
+       do {
+               BMEdge *e2 = e;
+
+               BLI_array_append(verts, v);
+               BLI_array_append(edges2, e);
 
-               for(i = 0, j=0; i < len; i++){
-                       if(!BMO_TestFlag(bm, edges[i]->v1, BM_EDGEVERT)){
-                               BMO_SetFlag(bm, edges[i]->v1, BM_EDGEVERT);
-                               verts[j++] = edges[i]->v1;
+               do {
+                       e2 = bmesh_disk_nextedge(e2, v);
+                       if (e2 != e && bmesh_api_getflag(e2, _FLAG_MF)) {
+                               v = BM_OtherEdgeVert(e2, v);
+                               break;
                        }
-                       if(!BMO_TestFlag(bm, edges[i]->v2, BM_EDGEVERT)) {
-                               BMO_SetFlag(bm, edges[i]->v2, BM_EDGEVERT);
-                               verts[j++] = edges[i]->v2;
+               } 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<len; i++) {
+               if (BM_Vert_In_Edge(edges2[i], v1)) {
+                       /*see if v1 and v2 are in the same edge*/
+                       if (BM_Vert_In_Edge(edges2[i], v2)) {
+                               /*if v1 is shared by the *next* edge, then the winding
+                                 is incorrect*/
+                               if (BM_Vert_In_Edge(edges2[(i+1)%len], v1)) {
+                                       reverse = 1;
+                                       break;
+                               }
                        }
+
+                       v1found = 1;
                }
-               
-               if (j != len) {
-                       /*sanity check*/
-                       return NULL;
+
+               if (!v1found && BM_Vert_In_Edge(edges2[i], v2)) {
+                       reverse = 1;
+                       break;
                }
+       }
 
-               overlap = BM_Face_Exists(bm, verts, len, &f);
-               
-               /*clear flags*/
-               for(i = 0; i < len; i++){
-                       BMO_ClearFlag(bm, edges[i]->v1, BM_EDGEVERT);
-                       BMO_ClearFlag(bm, edges[i]->v2, BM_EDGEVERT);
+       if (reverse) {
+               for (i=0; i<len/2; i++) {
+                       v = verts[i];
+                       verts[i] = verts[len-i-1];
+                       verts[len-i-1] = v;
                }
-               
-               if(len > VERT_BUF_SIZE)
-                       MEM_freeN(verts);
        }
 
-       if((!f) && (!overlap)) {
-               f = bmesh_mf(bm, v1, v2, edges, len);
-       } else return NULL;
+       for (i=0; i<len; i++) {
+               edges2[i] = BM_Edge_Exist(verts[i], verts[(i+1)%len]);
+       }
+
+       /*check if face already exists*/
+       if(nodouble)
+               overlap = BM_Face_Exists(bm, verts, len, &f);
+
+       /*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; i<len; i++) {
+               bmesh_api_clearflag(edges2[i], _FLAG_MF);
+       }
+
+       BLI_array_free(verts);
+       BLI_array_free(edges2);
 
        return f;
+
+err:
+       for (i=0; i<len; i++) {
+               bmesh_api_clearflag(edges[i], _FLAG_MF);
+       }
+
+       BLI_array_free(verts);
+       BLI_array_free(edges2);
+
+       return NULL;
 }
 
 
@@ -332,52 +378,42 @@ BMFace *BM_Make_Ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len,
 
 void BM_remove_tagged_faces(BMesh *bm, int flag)
 {
-       BMHeader *current, *next;
+       BMFace *f;
+       BMIter iter;
 
-       current = bm->polys.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;
-
-       current = bm->verts.first;
+       BMVert *v;
+       BMIter iter;
 
-       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
+}
index 746969a00e066cde735b9f6370425f0ebecdce78..43b1ee76ffd808ae6da60283a4f96f51f7e705a7 100644 (file)
@@ -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;i<len;i++) {
@@ -217,10 +220,10 @@ BMFace *bmesh_mf(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **elist, int len)
                        int a, len=0;
                        
                        v1 = j ? elist[i]->v2 : 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;a<len;a++,curedge = bmesh_disk_nextedge(curedge,v1)){
+                       for(a=0,curedge=v1->e;a<len;a++,curedge = bmesh_disk_nextedge(curedge,v1)){
                                curedge->head.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; i<len; i++){
-               edok = bmesh_disk_count_edgeflag(elist[i]->v1, 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; i<len; i++){
+//             edok = bmesh_disk_count_edgeflag(elist[i]->v1, 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; i<len; i++){
-               if((elist[i]->head.eflag1 & MF_VISITED) == 0) cont = 0;
-       }
+//     for(i=0; i<len; i++){
+//             if((elist[i]->head.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;i<len;i++){
                        curvert = vlist[i];
                        l = bmesh_create_loop(bm,curvert,NULL,f,NULL);
-                       if(!(f->loopbase)) 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; i<len; i++, l=((BMLoop*)(l->head.next))){
+               for(i=0, l = f->loopbase; i<len; i++, l=((BMLoop*)(l->next))){
                        e = NULL;
                        if(l == f->loopbase) e = elist[0]; /*first edge*/
                        
                        else{/*search elist for others*/
                                for(j=1; j<len; j++){
-                                       edok = bmesh_verts_in_edge(l->v, ((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; i<len; i++, l=((BMLoop*)(l->head.next))){
+               for(i=0, l = f->loopbase; i<len; i++, l=((BMLoop*)(l->next))){
                        /*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; i<radlen; i++, killoop = bmesh_radial_nextloop(killoop)){
+                               radlen = bmesh_cycle_length(&(ke->l->radial));
+                               for(i=0,killoop = ke->l; i<radlen; i++, killoop = bmesh_radial_nextloop(killoop)){
                                        /*relink loops and fix vertex pointer*/
-                                       killoop->head.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(i<radlen){
                                        bm->lpar[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; i<radlen; i++, nextl = bmesh_radial_nextloop(nextl)){
-                               edok = bmesh_cycle_validate(nextl->f->len,nextl->f->loopbase);
+                       for(i=0,nextl = oe->l; i<radlen; i++, nextl = bmesh_radial_nextloop(nextl)){
+                               edok = bmesh_cycle_validate(nextl->f->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
index 7eab2ca0c3b22ae24b39ed9345cbb3cbdfba4375..9dfe3c63be933b044d560009c94f7bf6242e4311 100644 (file)
@@ -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;
+}
index 1c88c16acc29c8f77116fa2b6e9b219bd2a129a0..f53a9e4f47b3ececd3886b3dd5bd485dedb198ac 100644 (file)
@@ -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;
index fa2bd6be4813fec0ae7537b9d173eee0c5c6d065..463cd635696c8fe783101795c8dce2f724c8f18d 100644 (file)
@@ -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;
index ea69429449aa1d15c644312c63586021e1538028..3675292063e7efa286843c20f6b56f86648d894f 100644 (file)
@@ -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);
index 81d192dcdb771866a6c7cd03c1aac4ee3b7e7299..718326b803dadbce50dfcfd5623aff8e52be4b1f 100644 (file)
@@ -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))
index fdaa231fb9f19efd18c3030ec7e54f6e36b208b5..8571056bd8421fe45af460204714c82034a3daac 100644 (file)
@@ -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; i<len; i++){
+               for(i = 0, curedge=v->e; i<len; i++){
                        if (BMO_TestFlag(bm, curedge, toolflag))
                                count++;
                        curedge = bmesh_disk_nextedge(curedge, v);
@@ -784,29 +786,31 @@ static void alloc_flag_layer(BMesh *bm)
        BMIter verts;
        BMIter edges;
        BMIter faces;
-       BLI_mempool *oldpool = bm->flagpool;            /*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;
 }
index 81861b4d509cca3e2eb53d0d44d4b2ad33229873..08c555631ebf7bc162598bfc8d94fa57ece0ec41 100644 (file)
@@ -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; i<f->len; 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; i<len; i++) {
index 999285a6d1200e7d2cf3d1321a142a3676284f28..fa3172055d8cd406eb723099adca8dda9d17b8c2 100644 (file)
 #define BMESH_PRIVATE_H
 
 #include "bmesh.h"
+struct Link;
+struct BMLoop;
+
+/*returns positive nonzero on error*/
+int bmesh_check_element(BMesh *bm, void *element, int type);
+
+#define CHECK_ELEMENT(bm, el) \
+if (bmesh_check_element(bm, el, ((BMHeader*)el)->type))\
+               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"
index f7bf4188fad7b8d44a6f6c2a65601febbfb57be3..6365482541cab699f1c279c09b7e23e6053e9ed0 100644 (file)
@@ -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;i<len;i++,curedge = bmesh_disk_nextedge(curedge,v1)){
-                       if(bmesh_verts_in_edge(v1,v2,curedge)) return curedge;
-               }
-       }
-       
-       return NULL;
-}
-
 /*
  *  BMESH VERT EDGECOUNT
  *
@@ -207,8 +186,7 @@ BMEdge *BM_Edge_Exist(BMVert *v1, BMVert *v2)
 
 int BM_Vert_EdgeCount(BMVert *v)
 {
-       if (v == v->edge->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;
index 664e07f805baa4a35df582459c4a688ea1329c8c..0d6e69dc18ad77ea46076b213daeb61c497ff83a 100644 (file)
  */
 
 #include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
 #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; i<len; i++){
+               for(i = 0, curedge=v->e; i<len; i++){
                        if(eflag){
                                if(curedge->head.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; i<len; i++){
+               for(i = 0, curedge=v->e; i<len; i++){
                        if(curedge == e) return 1;
                        else curedge=bmesh_disk_nextedge(curedge, v);
                }
@@ -598,11 +755,11 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2){
        BMEdge *curedge;
        int i, len=0;
        
-       if(v1->edge){
-               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;i<len;i++,curedge = bmesh_disk_nextedge(curedge,v1)){
+               for(i=0,curedge=v1->e;i<len;i++,curedge = bmesh_disk_nextedge(curedge,v1)){
                        if(bmesh_verts_in_edge(v1,v2,curedge)) return curedge;
                }
        }
@@ -613,12 +770,12 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2){
 /*end disk cycle routines*/
 
 BMLoop *bmesh_radial_nextloop(BMLoop *l){
-       return (BMLoop*)(l->radial.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
index ba63bb8f65f69c5da82f9d7c6208915023f2ee30..58f7cbc16f2119002926393751d29faa3d7ea29b 100644 (file)
 #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);
@@