more knit-picky memory saving
authorCampbell Barton <ideasman42@gmail.com>
Thu, 16 Feb 2012 16:44:10 +0000 (16:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 16 Feb 2012 16:44:10 +0000 (16:44 +0000)
don't store a flag array, (or pointer to a flag array) per BMLoop.
saves 4 pointers per quad - obviously, so this can add up a bit.

source/blender/bmesh/bmesh_class.h
source/blender/bmesh/bmesh_operator_api.h
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_newcore.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_private.h
source/blender/bmesh/intern/bmesh_walkers_impl.c
source/blender/bmesh/operators/bmo_create.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/editors/mesh/bmesh_select.c

index 50f9247211c5cf00490d9cc8889bc7426a18c995..3a62eaa2eeb7c7fdee0e0fd8cd83e3c3ccdad332 100644 (file)
@@ -50,7 +50,6 @@ struct Object;
 */
 typedef struct BMHeader {
        void *data; /* customdata layers */
-       struct BMFlagLayer *flags;
        int index; /* notes:
                    * - Use BM_elem_index_get/SetIndex macros for index
                    * - Unitialized to -1 so we can easily tell its not set.
@@ -68,6 +67,8 @@ typedef struct BMHeader {
 
 typedef struct BMVert {
        BMHeader head;
+       struct BMFlagLayer *oflags; /* keep after header, an array of flags, mostly used by the operator stack */
+
        float co[3];
        float no[3];
        struct BMEdge *e;
@@ -80,6 +81,8 @@ typedef struct BMDiskLink {
 
 typedef struct BMEdge {
        BMHeader head;
+       struct BMFlagLayer *oflags; /* keep after header, an array of flags, mostly used by the operator stack */
+
        struct BMVert *v1, *v2;
        struct BMLoop *l;
        
@@ -89,6 +92,8 @@ typedef struct BMEdge {
 
 typedef struct BMLoop {
        BMHeader head;
+       /* notice no flags layer */
+
        struct BMVert *v;
        struct BMEdge *e;
        struct BMFace *f;
@@ -100,6 +105,12 @@ typedef struct BMLoop {
        struct BMLoop *next, *prev;
 } BMLoop;
 
+/* can cast BMFace/BMEdge/BMVert, but NOT BMLoop, since these dont have a flag layer */
+typedef struct BMElemF {
+       BMHeader head;
+       struct BMFlagLayer *oflags; /* keep after header, an array of flags, mostly used by the operator stack */
+} BMElemF;
+
 #ifdef USE_BMESH_HOLES
 /* eventually, this structure will be used for supporting holes in faces */
 typedef struct BMLoopList {
@@ -110,6 +121,8 @@ typedef struct BMLoopList {
 
 typedef struct BMFace {
        BMHeader head;
+       struct BMFlagLayer *oflags; /* an array of flags, mostly used by the operator stack */
+
        int len; /*includes all boundary loops*/
 #ifdef USE_BMESH_HOLES
        int totbounds; /*total boundaries, is one plus the number of holes in the face*/
index 793c1748af714464948a961173c06e806fe1c5cb..7bbb579685d8d1dcd344883e3ecbf2c96579963f 100644 (file)
@@ -178,10 +178,10 @@ void BMO_op_finish(struct BMesh *bm, struct BMOperator *op);
  * 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_elem_flag_test(bm, element, oflag) (((BMHeader*)(element))->flags[bm->stackdepth-1].f & (oflag))
-#define BMO_elem_flag_enable(bm, element, oflag) (((BMHeader*)(element))->flags[bm->stackdepth-1].f |= (oflag))
-#define BMO_elem_flag_disable(bm, element, oflag) (((BMHeader*)(element))->flags[bm->stackdepth-1].f &= ~(oflag))
-#define BMO_elem_flag_toggle(bm, element, oflag) (((BMHeader*)(element))->flags[bm->stackdepth-1].f ^= (oflag))
+#define BMO_elem_flag_test(bm, element, oflag)    ((element)->oflags[bm->stackdepth-1].f &   (oflag))
+#define BMO_elem_flag_enable(bm, element, oflag)  ((element)->oflags[bm->stackdepth-1].f |=  (oflag))
+#define BMO_elem_flag_disable(bm, element, oflag) ((element)->oflags[bm->stackdepth-1].f &= ~(oflag))
+#define BMO_elem_flag_toggle(bm, element, oflag)  ((element)->oflags[bm->stackdepth-1].f ^=  (oflag))
 
 /* profiling showed a significant amount of time spent in BMO_elem_flag_test */
 #if 0
index b7c5c8e8b551d630477e03b2796cefa81a974935..b678473b45c0693227f9a78437cc709dde5c06f3 100644 (file)
@@ -408,20 +408,20 @@ static void bmo_remove_tagged_context_verts(BMesh *bm, const short oflag)
 {
        BMVert *v;
        BMEdge *e;
-       BMLoop *f;
+       BMFace *f;
 
        BMIter verts;
        BMIter edges;
        BMIter faces;
 
        for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts)) {
-               if (BMO_elem_flag_test(bm, (BMHeader *)v, oflag)) {
+               if (BMO_elem_flag_test(bm, v, oflag)) {
                        /* Visit edge */
                        for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_VERT, v); e; e = BM_iter_step(&edges))
-                               BMO_elem_flag_enable(bm, (BMHeader *)e, oflag);
+                               BMO_elem_flag_enable(bm, e, oflag);
                        /* Visit face */
                        for (f = BM_iter_new(&faces, bm, BM_FACES_OF_VERT, v); f; f = BM_iter_step(&faces))
-                               BMO_elem_flag_enable(bm, (BMHeader *)f, oflag);
+                               BMO_elem_flag_enable(bm, f, oflag);
                }
        }
 
@@ -439,9 +439,9 @@ static void bmo_remove_tagged_context_edges(BMesh *bm, const short oflag)
        BMIter faces;
 
        for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) {
-               if (BMO_elem_flag_test(bm, (BMHeader *)e, oflag)) {
+               if (BMO_elem_flag_test(bm, e, oflag)) {
                        for (f = BM_iter_new(&faces, bm, BM_FACES_OF_EDGE, e); f; f = BM_iter_step(&faces)) {
-                               BMO_elem_flag_enable(bm, (BMHeader *)f, oflag);
+                               BMO_elem_flag_enable(bm, f, oflag);
                        }
                }
        }
@@ -474,16 +474,16 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                {
                        /* flush down to vert */
                        for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) {
-                               if (BMO_elem_flag_test(bm, (BMHeader *)e, oflag)) {
-                                       BMO_elem_flag_enable(bm, (BMHeader *)(e->v1), oflag);
-                                       BMO_elem_flag_enable(bm, (BMHeader *)(e->v2), oflag);
+                               if (BMO_elem_flag_test(bm, e, oflag)) {
+                                       BMO_elem_flag_enable(bm, e->v1, oflag);
+                                       BMO_elem_flag_enable(bm, e->v2, oflag);
                                }
                        }
                        bmo_remove_tagged_context_edges(bm, oflag);
                        /* remove loose vertice */
                        for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts)) {
-                               if (BMO_elem_flag_test(bm, (BMHeader *)v, oflag) && (!(v->e)))
-                                       BMO_elem_flag_enable(bm, (BMHeader *)v, DEL_WIREVERT);
+                               if (BMO_elem_flag_test(bm, v, oflag) && (!(v->e)))
+                                       BMO_elem_flag_enable(bm, v, DEL_WIREVERT);
                        }
                        BMO_remove_tagged_verts(bm, DEL_WIREVERT);
 
@@ -513,29 +513,29 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                {
                        /* go through and mark all edges and all verts of all faces for delet */
                        for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) {
-                               if (BMO_elem_flag_test(bm, (BMHeader *)f, oflag)) {
+                               if (BMO_elem_flag_test(bm, f, oflag)) {
                                        for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&edges))
-                                               BMO_elem_flag_enable(bm, (BMHeader *)e, oflag);
+                                               BMO_elem_flag_enable(bm, e, oflag);
                                        for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&verts))
-                                               BMO_elem_flag_enable(bm, (BMHeader *)v, oflag);
+                                               BMO_elem_flag_enable(bm, v, oflag);
                                }
                        }
                        /* now go through and mark all remaining faces all edges for keeping */
                        for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces)) {
-                               if (!BMO_elem_flag_test(bm, (BMHeader *)f, oflag)) {
+                               if (!BMO_elem_flag_test(bm, f, oflag)) {
                                        for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&edges)) {
-                                               BMO_elem_flag_disable(bm, (BMHeader *)e, oflag);
+                                               BMO_elem_flag_disable(bm, e, oflag);
                                        }
                                        for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&verts)) {
-                                               BMO_elem_flag_disable(bm, (BMHeader *)v, oflag);
+                                               BMO_elem_flag_disable(bm, v, oflag);
                                        }
                                }
                        }
                        /* also mark all the vertices of remaining edges for keeping */
                        for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges)) {
-                               if (!BMO_elem_flag_test(bm, (BMHeader *)e, oflag)) {
-                                       BMO_elem_flag_disable(bm, (BMHeader *)e->v1, oflag);
-                                       BMO_elem_flag_disable(bm, (BMHeader *)e->v2, oflag);
+                               if (!BMO_elem_flag_test(bm, e, oflag)) {
+                                       BMO_elem_flag_disable(bm, e->v1, oflag);
+                                       BMO_elem_flag_disable(bm, e->v2, oflag);
                                }
                        }
                        /* now delete marked face */
@@ -551,11 +551,11 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                {
                        /* does this option even belong in here? */
                        for (f = BM_iter_new(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BM_iter_step(&faces))
-                               BMO_elem_flag_enable(bm, (BMHeader *)f, oflag);
+                               BMO_elem_flag_enable(bm, f, oflag);
                        for (e = BM_iter_new(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&edges))
-                               BMO_elem_flag_enable(bm, (BMHeader *)e, oflag);
+                               BMO_elem_flag_enable(bm, e, oflag);
                        for (v = BM_iter_new(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BM_iter_step(&verts))
-                               BMO_elem_flag_enable(bm, (BMHeader *)v, oflag);
+                               BMO_elem_flag_enable(bm, v, oflag);
 
                        BMO_remove_tagged_faces(bm, oflag);
                        BMO_remove_tagged_edges(bm, oflag);
index b77f8146caa9ba48f5e8604d4dbd4c30053948e9..98b2f3e0dc1cf8bf7b4d7e5975269caf8f8755e8 100644 (file)
@@ -70,7 +70,7 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const struct BMVert *exampl
        if (co) copy_v3_v3(v->co, co);
        
        /* allocate flag */
-       v->head.flags = BLI_mempool_calloc(bm->toolflagpool);
+       v->oflags = BLI_mempool_calloc(bm->toolflagpool);
 
        CustomData_bmesh_set_default(&bm->vdata, &v->head.data);
        
@@ -129,7 +129,7 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example,
        e->head.htype = BM_EDGE;
        
        /* allocate flag */
-       e->head.flags = BLI_mempool_calloc(bm->toolflagpool);
+       e->oflags = BLI_mempool_calloc(bm->toolflagpool);
 
        e->v1 = (BMVert *) v1;
        e->v2 = (BMVert *) v2;
@@ -307,7 +307,7 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
        }
        
        /* allocate flag */
-       f->head.flags = BLI_mempool_calloc(bm->toolflagpool);
+       f->oflags = BLI_mempool_calloc(bm->toolflagpool);
 
        CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
        
@@ -464,7 +464,7 @@ static void bmesh_kill_only_vert(BMesh *bm, BMVert *v)
        if (v->head.data)
                CustomData_bmesh_free_block(&bm->vdata, &v->head.data);
 
-       BLI_mempool_free(bm->toolflagpool, v->head.flags);
+       BLI_mempool_free(bm->toolflagpool, v->oflags);
        BLI_mempool_free(bm->vpool, v);
 }
 
@@ -478,7 +478,7 @@ static void bmesh_kill_only_edge(BMesh *bm, BMEdge *e)
        if (e->head.data)
                CustomData_bmesh_free_block(&bm->edata, &e->head.data);
 
-       BLI_mempool_free(bm->toolflagpool, e->head.flags);
+       BLI_mempool_free(bm->toolflagpool, e->oflags);
        BLI_mempool_free(bm->epool, e);
 }
 
@@ -495,7 +495,7 @@ static void bmesh_kill_only_face(BMesh *bm, BMFace *f)
        if (f->head.data)
                CustomData_bmesh_free_block(&bm->pdata, &f->head.data);
 
-       BLI_mempool_free(bm->toolflagpool, f->head.flags);
+       BLI_mempool_free(bm->toolflagpool, f->oflags);
        BLI_mempool_free(bm->fpool, f);
 }
 
@@ -505,8 +505,6 @@ static void bmesh_kill_only_loop(BMesh *bm, BMLoop *l)
        if (l->head.data)
                CustomData_bmesh_free_block(&bm->ldata, &l->head.data);
 
-       if (l->head.flags)
-               BLI_mempool_free(bm->toolflagpool, l->head.flags);
        BLI_mempool_free(bm->lpool, l);
 }
 
@@ -766,7 +764,7 @@ static void bmesh_systag_elements(BMesh *UNUSED(bm), void *veles, int tot, int f
        int i;
 
        for (i = 0; i < tot; i++) {
-               BM_ELEM_API_FLAG_ENABLE(eles[i], flag);
+               BM_ELEM_API_FLAG_ENABLE((BMElemF *)eles[i], flag);
        }
 }
 
@@ -776,7 +774,7 @@ static void bmesh_clear_systag_elements(BMesh *UNUSED(bm), void *veles, int tot,
        int i;
 
        for (i = 0; i < tot; i++) {
-               BM_ELEM_API_FLAG_DISABLE(eles[i], flag);
+               BM_ELEM_API_FLAG_DISABLE((BMElemF *)eles[i], flag);
        }
 }
 
@@ -1070,7 +1068,7 @@ static BMFace *bmesh_addpolylist(BMesh *bm, BMFace *UNUSED(example))
        bm->totface++;
 
        /* allocate flag */
-       f->head.flags = BLI_mempool_calloc(bm->toolflagpool);
+       f->oflags = BLI_mempool_calloc(bm->toolflagpool);
 
        CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
 
@@ -1685,14 +1683,14 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
        bmesh_disk_remove_edge(f1loop->e, f1loop->e->v2);
        
        /* deallocate edge and its two loops as well as f2 */
-       BLI_mempool_free(bm->toolflagpool, f1loop->e->head.flags);
+       BLI_mempool_free(bm->toolflagpool, f1loop->e->oflags);
        BLI_mempool_free(bm->epool, f1loop->e);
        bm->totedge--;
        BLI_mempool_free(bm->lpool, f1loop);
        bm->totloop--;
        BLI_mempool_free(bm->lpool, f2loop);
        bm->totloop--;
-       BLI_mempool_free(bm->toolflagpool, f2->head.flags);
+       BLI_mempool_free(bm->toolflagpool, f2->oflags);
        BLI_mempool_free(bm->fpool, f2);
        bm->totface--;
        /* account for both above */
index af38a1870f03a3f9e78a350eaeec8919bc30c7ea..66222c39c68c91313b1955b77de88bb96ed5684a 100644 (file)
@@ -432,24 +432,24 @@ void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3])
 int BMO_mesh_flag_count(BMesh *bm, const short oflag, const char htype)
 {
        BMIter elements;
-       BMHeader *e;
        int count = 0;
+       BMElemF *ele_f;
 
        if (htype & BM_VERT) {
-               for (e = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BM_iter_step(&elements)) {
-                       if (BMO_elem_flag_test(bm, e, oflag))
+               for (ele_f = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); ele_f; ele_f = BM_iter_step(&elements)) {
+                       if (BMO_elem_flag_test(bm, ele_f, oflag))
                                count++;
                }
        }
        if (htype & BM_EDGE) {
-               for (e = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&elements)) {
-                       if (BMO_elem_flag_test(bm, e, oflag))
+               for (ele_f = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); ele_f; ele_f = BM_iter_step(&elements)) {
+                       if (BMO_elem_flag_test(bm, ele_f, oflag))
                                count++;
                }
        }
        if (htype & BM_FACE) {
-               for (e = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BM_iter_step(&elements)) {
-                       if (BMO_elem_flag_test(bm, e, oflag))
+               for (ele_f = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); ele_f; ele_f = BM_iter_step(&elements)) {
+                       if (BMO_elem_flag_test(bm, ele_f, oflag))
                                count++;
                }
        }
@@ -466,7 +466,7 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty
        const char flag_types[3] = {BM_VERT, BM_EDGE, BM_FACE};
 
        BMIter iter;
-       BMHeader *ele;
+       BMElemF *ele;
        int i;
 
        for (i = 0; i < 3; i++) {
@@ -546,15 +546,15 @@ void BMO_slot_map_to_flag(struct BMesh *bm, struct BMOperator *op,
 {
        GHashIterator it;
        BMOpSlot *slot = BMO_slot_get(op, slotname);
-       BMHeader *ele;
+       BMElemF *ele_f;
 
        /* sanity check */
        if (slot->slottype != BMO_OP_SLOT_MAPPING) return;
        if (!slot->data.ghash) return;
 
        BLI_ghashIterator_init(&it, slot->data.ghash);
-       for ( ; (ele = BLI_ghashIterator_getKey(&it)); BLI_ghashIterator_step(&it)) {
-               BMO_elem_flag_enable(bm, ele, oflag);
+       for ( ; (ele_f = BLI_ghashIterator_getKey(&it)); BLI_ghashIterator_step(&it)) {
+               BMO_elem_flag_enable(bm, ele_f, oflag);
        }
 }
 
@@ -678,7 +678,7 @@ void BMO_slot_from_flag(BMesh *bm, BMOperator *op, const char *slotname,
                         const short oflag, const char htype)
 {
        BMIter elements;
-       BMHeader *e;
+       BMHeader *ele;
        BMOpSlot *output = BMO_slot_get(op, slotname);
        int totelement = BMO_mesh_flag_count(bm, oflag, htype), i = 0;
 
@@ -686,27 +686,27 @@ void BMO_slot_from_flag(BMesh *bm, BMOperator *op, const char *slotname,
                bmo_slot_buffer_alloc(op, slotname, totelement);
 
                if (htype & BM_VERT) {
-                       for (e = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BM_iter_step(&elements)) {
-                               if (BMO_elem_flag_test(bm, e, oflag)) {
-                                       ((BMHeader **)output->data.p)[i] = e;
+                       for (ele = BM_iter_new(&elements, bm, BM_VERTS_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) {
+                               if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag)) {
+                                       ((BMHeader **)output->data.p)[i] = ele;
                                        i++;
                                }
                        }
                }
 
                if (htype & BM_EDGE) {
-                       for (e = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BM_iter_step(&elements)) {
-                               if (BMO_elem_flag_test(bm, e, oflag)) {
-                                       ((BMHeader **)output->data.p)[i] = e;
+                       for (ele = BM_iter_new(&elements, bm, BM_EDGES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) {
+                               if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag)) {
+                                       ((BMHeader **)output->data.p)[i] = ele;
                                        i++;
                                }
                        }
                }
 
                if (htype & BM_FACE) {
-                       for (e = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BM_iter_step(&elements)) {
-                               if (BMO_elem_flag_test(bm, e, oflag)) {
-                                       ((BMHeader **)output->data.p)[i] = e;
+                       for (ele = BM_iter_new(&elements, bm, BM_FACES_OF_MESH, bm); ele; ele = BM_iter_step(&elements)) {
+                               if (BMO_elem_flag_test(bm, (BMElemF *)ele, oflag)) {
+                                       ((BMHeader **)output->data.p)[i] = ele;
                                        i++;
                                }
                        }
@@ -803,7 +803,7 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname
                if (!(htype & data[i]->htype))
                        continue;
 
-               BMO_elem_flag_enable(bm, data[i], oflag);
+               BMO_elem_flag_enable(bm, (BMElemF *)data[i], oflag);
        }
 }
 
@@ -824,7 +824,7 @@ void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotnam
                if (!(htype & data[i]->htype))
                        continue;
 
-               BMO_elem_flag_disable(bm, data[i], oflag);
+               BMO_elem_flag_disable(bm, (BMElemF *)data[i], oflag);
        }
 }
 
@@ -845,7 +845,7 @@ void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotnam
  */
 static void bmo_flag_layer_alloc(BMesh *bm)
 {
-       BMHeader *ele;
+       BMElemF *ele;
        /* set the index values since we are looping over all data anyway,
         * may save time later on */
        int i;
@@ -865,21 +865,21 @@ static void bmo_flag_layer_alloc(BMesh *bm)
        
        /* now go through and memcpy all the flags. Loops don't get a flag layer at this time.. */
        for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               oldflags = ele->flags;
-               ele->flags = BLI_mempool_calloc(newpool);
-               memcpy(ele->flags, oldflags, old_totflags_size);
+               oldflags = ele->oflags;
+               ele->oflags = BLI_mempool_calloc(newpool);
+               memcpy(ele->oflags, oldflags, old_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
        for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               oldflags = ele->flags;
-               ele->flags = BLI_mempool_calloc(newpool);
-               memcpy(ele->flags, oldflags, old_totflags_size);
+               oldflags = ele->oflags;
+               ele->oflags = BLI_mempool_calloc(newpool);
+               memcpy(ele->oflags, oldflags, old_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
        for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               oldflags = ele->flags;
-               ele->flags = BLI_mempool_calloc(newpool);
-               memcpy(ele->flags, oldflags, old_totflags_size);
+               oldflags = ele->oflags;
+               ele->oflags = BLI_mempool_calloc(newpool);
+               memcpy(ele->oflags, oldflags, old_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
 
@@ -890,7 +890,7 @@ static void bmo_flag_layer_alloc(BMesh *bm)
 
 static void bmo_flag_layer_free(BMesh *bm)
 {
-       BMHeader *ele;
+       BMElemF *ele;
        /* set the index values since we are looping over all data anyway,
         * may save time later on */
        int i;
@@ -910,21 +910,21 @@ static void bmo_flag_layer_free(BMesh *bm)
        
        /* now go through and memcpy all the flag */
        for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               oldflags = ele->flags;
-               ele->flags = BLI_mempool_calloc(newpool);
-               memcpy(ele->flags, oldflags, new_totflags_size);
+               oldflags = ele->oflags;
+               ele->oflags = BLI_mempool_calloc(newpool);
+               memcpy(ele->oflags, oldflags, new_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
        for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               oldflags = ele->flags;
-               ele->flags = BLI_mempool_calloc(newpool);
-               memcpy(ele->flags, oldflags, new_totflags_size);
+               oldflags = ele->oflags;
+               ele->oflags = BLI_mempool_calloc(newpool);
+               memcpy(ele->oflags, oldflags, new_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
        for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               oldflags = ele->flags;
-               ele->flags = BLI_mempool_calloc(newpool);
-               memcpy(ele->flags, oldflags, new_totflags_size);
+               oldflags = ele->oflags;
+               ele->oflags = BLI_mempool_calloc(newpool);
+               memcpy(ele->oflags, oldflags, new_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
 
@@ -935,7 +935,7 @@ static void bmo_flag_layer_free(BMesh *bm)
 
 static void bmo_flag_layer_clear(BMesh *bm)
 {
-       BMHeader *ele;
+       BMElemF *ele;
        /* set the index values since we are looping over all data anyway,
         * may save time later on */
        int i;
@@ -945,15 +945,15 @@ static void bmo_flag_layer_clear(BMesh *bm)
 
        /* now go through and memcpy all the flag */
        for (ele = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               memset(ele->flags + totflags_offset, 0, sizeof(BMFlagLayer));
+               memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer));
                BM_elem_index_set(ele, i); /* set_inline */
        }
        for (ele = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               memset(ele->flags + totflags_offset, 0, sizeof(BMFlagLayer));
+               memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer));
                BM_elem_index_set(ele, i); /* set_inline */
        }
        for (ele = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, bm), i = 0; ele; ele = BM_iter_step(&iter), i++) {
-               memset(ele->flags + totflags_offset, 0, sizeof(BMFlagLayer));
+               memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer));
                BM_elem_index_set(ele, i); /* set_inline */
        }
 
index d362479c4d1b0e0e63b5bd50e47c176e30ee7126..694d68549cda2f546a74654d76d00f23a7fc65cc 100644 (file)
@@ -71,9 +71,9 @@ int bmesh_get_filter_argtype(int type);
 #define _FLAG_JF       1 /* join faces */
 #define _FLAG_MF       2 /* make face */
 
-#define BM_ELEM_API_FLAG_ENABLE(element, f)  (((BMHeader*)(element))->flags[0].pflag |=  (f))
-#define BM_ELEM_API_FLAG_DISABLE(element, f) (((BMHeader*)(element))->flags[0].pflag &= ~(f))
-#define BM_ELEM_API_FLAG_TEST(element, f)    (((BMHeader*)(element))->flags[0].pflag &   (f))
+#define BM_ELEM_API_FLAG_ENABLE(element, f)  ((element)->oflags[0].pflag |=  (f))
+#define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->oflags[0].pflag &= ~(f))
+#define BM_ELEM_API_FLAG_TEST(element, f)    ((element)->oflags[0].pflag &   (f))
 
 /* Polygon Utilities ? FIXME... where do these each go? */
 /* newedgeflag sets a flag layer flag, obviously not the header flag. */
index d9678399a12202d25aa92a48cb6538b029ba773b..345c3358677bb06115d4dccf463691ca16b23f6b 100644 (file)
@@ -333,7 +333,7 @@ static void islandWalker_begin(BMWalker *walker, void *data)
 {
        islandWalker *iwalk = NULL;
 
-       if (walker->mask_face && !BMO_elem_flag_test(walker->bm, data, walker->mask_face)) {
+       if (walker->mask_face && !BMO_elem_flag_test(walker->bm, (BMElemF *)data, walker->mask_face)) {
                return;
        }
 
index 325156aa5688e87c1d72d182c70bf639e0bdafdc..42758c7221bf0beb7bb22e18b12c66408b369fbc 100644 (file)
@@ -1254,7 +1254,7 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op)
                        case BM_FACE: totf++; break;
                }
 
-               BMO_elem_flag_enable(bm, h, ELE_NEW);
+               BMO_elem_flag_enable(bm, (BMElemF *)h, ELE_NEW);
        }
        
        /* --- Support for Special Case ---
@@ -1317,10 +1317,10 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op)
 
                if (ok == TRUE && v_free && v_a && v_b) {
                        e = BM_edge_create(bm, v_free, v_a, NULL, TRUE);
-                       BMO_elem_flag_enable(bm, &e->head, ELE_NEW);
+                       BMO_elem_flag_enable(bm, e, ELE_NEW);
 
                        e = BM_edge_create(bm, v_free, v_b, NULL, TRUE);
-                       BMO_elem_flag_enable(bm, &e->head, ELE_NEW);
+                       BMO_elem_flag_enable(bm, e, ELE_NEW);
                }
        }
        /* --- end special case support, continue as normal --- */
index f9617d0affd7ad3ac83247eaf0cc09267f255f65..2e1c91d920c7679c6ef0a91d323e1f32581c0465 100644 (file)
@@ -54,7 +54,7 @@ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *tar
        BM_elem_attrs_copy(source_mesh, target_mesh, source_vertex, target_vertex);
        
        /* Set internal op flag */
-       BMO_elem_flag_enable(target_mesh, (BMHeader *)target_vertex, DUPE_NEW);
+       BMO_elem_flag_enable(target_mesh, target_vertex, DUPE_NEW);
        
        return target_vertex;
 }
@@ -110,7 +110,7 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh,
        BM_elem_attrs_copy(source_mesh, target_mesh, source_edge, target_edge);
        
        /* Set internal op flags */
-       BMO_elem_flag_enable(target_mesh, (BMHeader *)target_edge, DUPE_NEW);
+       BMO_elem_flag_enable(target_mesh, target_edge, DUPE_NEW);
        
        return target_edge;
 }
@@ -159,7 +159,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh,
        BM_elem_attrs_copy(source_mesh, target_mesh, source_face, target_face);
 
        /* mark the face for outpu */
-       BMO_elem_flag_enable(target_mesh, (BMHeader *)target_face, DUPE_NEW);
+       BMO_elem_flag_enable(target_mesh, target_face, DUPE_NEW);
        
        /* copy per-loop custom dat */
        BM_ITER(source_loop, &iter, source_mesh, BM_LOOPS_OF_FACE, source_face) {
@@ -203,8 +203,8 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
        ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops e");
        
        for (v = BM_iter_new(&verts, source, BM_VERTS_OF_MESH, source); v; v = BM_iter_step(&verts)) {
-               if ( BMO_elem_flag_test(source, (BMHeader *)v, DUPE_INPUT) &&
-                   !BMO_elem_flag_test(source, (BMHeader *)v, DUPE_DONE))
+               if ( BMO_elem_flag_test(source, v, DUPE_INPUT) &&
+                   !BMO_elem_flag_test(source, v, DUPE_DONE))
                {
                        BMIter iter;
                        int iso = 1;
@@ -231,46 +231,46 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
                                BMO_slot_map_ptr_insert(source, op, "isovertmap", v, v2);
                        }
 
-                       BMO_elem_flag_enable(source, (BMHeader *)v, DUPE_DONE);
+                       BMO_elem_flag_enable(source, v, DUPE_DONE);
                }
        }
 
        /* now we dupe all the edge */
        for (e = BM_iter_new(&edges, source, BM_EDGES_OF_MESH, source); e; e = BM_iter_step(&edges)) {
-               if ( BMO_elem_flag_test(source, (BMHeader *)e, DUPE_INPUT) &&
-                   !BMO_elem_flag_test(source, (BMHeader *)e, DUPE_DONE))
+               if ( BMO_elem_flag_test(source, e, DUPE_INPUT) &&
+                   !BMO_elem_flag_test(source, e, DUPE_DONE))
                {
                        /* make sure that verts are copie */
-                       if (!BMO_elem_flag_test(source, (BMHeader *)e->v1, DUPE_DONE)) {
+                       if (!BMO_elem_flag_test(source, e->v1, DUPE_DONE)) {
                                copy_vertex(source, e->v1, target, vhash);
-                               BMO_elem_flag_enable(source, (BMHeader *)e->v1, DUPE_DONE);
+                               BMO_elem_flag_enable(source, e->v1, DUPE_DONE);
                        }
-                       if (!BMO_elem_flag_test(source, (BMHeader *)e->v2, DUPE_DONE)) {
+                       if (!BMO_elem_flag_test(source, e->v2, DUPE_DONE)) {
                                copy_vertex(source, e->v2, target, vhash);
-                               BMO_elem_flag_enable(source, (BMHeader *)e->v2, DUPE_DONE);
+                               BMO_elem_flag_enable(source, e->v2, DUPE_DONE);
                        }
                        /* now copy the actual edg */
                        copy_edge(op, source, e, target,  vhash,  ehash);
-                       BMO_elem_flag_enable(source, (BMHeader *)e, DUPE_DONE);
+                       BMO_elem_flag_enable(source, e, DUPE_DONE);
                }
        }
 
        /* first we dupe all flagged faces and their elements from sourc */
        for (f = BM_iter_new(&faces, source, BM_FACES_OF_MESH, source); f; f = BM_iter_step(&faces)) {
-               if (BMO_elem_flag_test(source, (BMHeader *)f, DUPE_INPUT)) {
+               if (BMO_elem_flag_test(source, f, DUPE_INPUT)) {
                        /* vertex pas */
                        for (v = BM_iter_new(&verts, source, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&verts)) {
-                               if (!BMO_elem_flag_test(source, (BMHeader *)v, DUPE_DONE)) {
+                               if (!BMO_elem_flag_test(source, v, DUPE_DONE)) {
                                        copy_vertex(source, v, target, vhash);
-                                       BMO_elem_flag_enable(source, (BMHeader *)v, DUPE_DONE);
+                                       BMO_elem_flag_enable(source, v, DUPE_DONE);
                                }
                        }
 
                        /* edge pas */
                        for (e = BM_iter_new(&edges, source, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&edges)) {
-                               if (!BMO_elem_flag_test(source, (BMHeader *)e, DUPE_DONE)) {
+                               if (!BMO_elem_flag_test(source, e, DUPE_DONE)) {
                                        copy_edge(op, source, e, target,  vhash,  ehash);
-                                       BMO_elem_flag_enable(source, (BMHeader *)e, DUPE_DONE);
+                                       BMO_elem_flag_enable(source, e, DUPE_DONE);
                                }
                        }
 
@@ -282,7 +282,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
                        BLI_array_growitems(edar, f->len);
 
                        copy_face(op, source, f, target, vtar, edar, vhash, ehash);
-                       BMO_elem_flag_enable(source, (BMHeader *)f, DUPE_DONE);
+                       BMO_elem_flag_enable(source, f, DUPE_DONE);
                }
        }
        
index 553d42a8854a182b616aaaadc2ca3e2e0074576c..6f4b4fff369416467d9d37fe97df176ddac1fbd4 100644 (file)
@@ -1221,7 +1221,7 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B
        BM_mesh_elem_index_ensure(em->bm, BM_VERT /* | BM_EDGE */);
 
        BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-               e->head.flags[0].f = 0;
+               e->oflags[0].f = 0; /* XXX, whats this for, BMESH_TODO, double check if this is needed */
                if (BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
                        BLI_smallhash_insert(&visithash, (uintptr_t)e, NULL);
                }
@@ -2012,7 +2012,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h
        BMO_push(bm, NULL);
        BM_ITER(h, &iter, bm, itertype, NULL) {
                if (BM_elem_flag_test(h, BM_ELEM_SELECT)) {
-                       BMO_elem_flag_enable(bm, h, BM_ELEM_SELECT);
+                       BMO_elem_flag_enable(bm, (BMElemF *)h, BM_ELEM_SELECT);
                }
        }