fix [#33029] Applying modifier leaks memory
authorCampbell Barton <ideasman42@gmail.com>
Thu, 29 Nov 2012 16:26:39 +0000 (16:26 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 29 Nov 2012 16:26:39 +0000 (16:26 +0000)
Thanks for Sergey for finding the bug & patching, This fix works a bit differently.
Theres no need to allocate the customdata in the first place - since its written into. So add a flag for vert/edge/face/loop creation functions so they can skip customdata creation.

20 files changed:
source/blender/blenkernel/intern/modifiers_bmesh.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_construct.h
source/blender/bmesh/intern/bmesh_core.c
source/blender/bmesh/intern/bmesh_core.h
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/operators/bmo_create.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/bmesh/operators/bmo_extrude.c
source/blender/bmesh/operators/bmo_hull.c
source/blender/bmesh/operators/bmo_inset.c
source/blender/bmesh/operators/bmo_primitive.c
source/blender/bmesh/operators/bmo_removedoubles.c
source/blender/bmesh/operators/bmo_symmetrize.c
source/blender/bmesh/operators/bmo_utils.c
source/blender/bmesh/operators/bmo_wireframe.c
source/blender/bmesh/tools/bmesh_bevel.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/modifiers/intern/MOD_skin.c
source/blender/python/bmesh/bmesh_py_types.c

index 98eac9b95af3041d544ea8a93a3a711b5995751f..381e4350391b62c717e71433f8c4faa0449d0d5e 100644 (file)
@@ -79,7 +79,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
        /*do verts*/
        mv = mvert = dm->dupVertArray(dm);
        for (i = 0; i < totvert; i++, mv++) {
-               v = BM_vert_create(bm, mv->co, NULL);
+               v = BM_vert_create(bm, mv->co, NULL, BM_CREATE_SKIP_CD);
                normal_short_to_float_v3(v->no, mv->no);
                v->head.hflag = BM_vert_flag_from_mflag(mv->flag);
                BM_elem_index_set(v, i); /* set_inline */
@@ -97,7 +97,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
        me = medge = dm->dupEdgeArray(dm);
        for (i = 0; i < totedge; i++, me++) {
                //BLI_assert(BM_edge_exists(vtable[me->v1], vtable[me->v2]) == NULL);
-               e = BM_edge_create(bm, vtable[me->v1], vtable[me->v2], NULL, FALSE);
+               e = BM_edge_create(bm, vtable[me->v1], vtable[me->v2], NULL, BM_CREATE_SKIP_CD);
 
                e->head.hflag = BM_edge_flag_from_mflag(me->flag);
                BM_elem_index_set(e, i); /* set_inline */
@@ -134,7 +134,7 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
                        edges[j] = etable[ml->e];
                }
 
-               f = BM_face_create_ngon(bm, verts[0], verts[1], edges, mp->totloop, FALSE);
+               f = BM_face_create_ngon(bm, verts[0], verts[1], edges, mp->totloop, BM_CREATE_SKIP_CD);
 
                if (UNLIKELY(f == NULL)) {
                        continue;
index 770196108f0156c1d663d6eb20b3b84ad1e67ab1..8b7fac1eacd145b777e929eee5675d3897faef18 100644 (file)
@@ -105,17 +105,17 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa
        /* make new face */
        if ((f == NULL) && (!is_overlap)) {
                BMEdge *edar[4] = {NULL};
-               edar[0] = BM_edge_create(bm, verts[0], verts[1], NULL, TRUE);
-               edar[1] = BM_edge_create(bm, verts[1], verts[2], NULL, TRUE);
+               edar[0] = BM_edge_create(bm, verts[0], verts[1], NULL, BM_CREATE_NO_DOUBLE);
+               edar[1] = BM_edge_create(bm, verts[1], verts[2], NULL, BM_CREATE_NO_DOUBLE);
                if (len == 4) {
-                       edar[2] = BM_edge_create(bm, verts[2], verts[3], NULL, TRUE);
-                       edar[3] = BM_edge_create(bm, verts[3], verts[0], NULL, TRUE);
+                       edar[2] = BM_edge_create(bm, verts[2], verts[3], NULL, BM_CREATE_NO_DOUBLE);
+                       edar[3] = BM_edge_create(bm, verts[3], verts[0], NULL, BM_CREATE_NO_DOUBLE);
                }
                else {
-                       edar[2] = BM_edge_create(bm, verts[2], verts[0], NULL, TRUE);
+                       edar[2] = BM_edge_create(bm, verts[2], verts[0], NULL, BM_CREATE_NO_DOUBLE);
                }
 
-               f = BM_face_create(bm, verts, edar, len, FALSE);
+               f = BM_face_create(bm, verts, edar, len, 0);
 
                if (example && f) {
                        BM_elem_attrs_copy(bm, bm, example, f);
@@ -171,7 +171,7 @@ void BM_face_copy_shared(BMesh *bm, BMFace *f)
  * #BM_face_create should be considered over this function as it
  * avoids some unnecessary work.
  */
-BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, int nodouble)
+BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, const int create_flag)
 {
        BMEdge **edges2 = NULL;
        BLI_array_staticdeclare(edges2, BM_DEFAULT_NGON_STACK_SIZE);
@@ -282,7 +282,7 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i
                BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV);
        }
 
-       f = BM_face_create(bm, verts, edges2, len, nodouble);
+       f = BM_face_create(bm, verts, edges2, len, create_flag);
 
        /* clean up flags */
        for (i = 0; i < len; i++) {
@@ -338,7 +338,7 @@ static int angle_index_pair_cmp(const void *e1, const void *e2)
  *
  * \note Since this is a vcloud there is no direction.
  */
-BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int nodouble)
+BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, const int create_flag)
 {
        BMFace *f;
 
@@ -464,7 +464,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n
 
        i_prev = totv - 1;
        for (i = 0; i < totv; i++) {
-               edge_arr[i] = BM_edge_create(bm, vert_arr_map[i_prev], vert_arr_map[i], NULL, TRUE);
+               edge_arr[i] = BM_edge_create(bm, vert_arr_map[i_prev], vert_arr_map[i], NULL, BM_CREATE_NO_DOUBLE);
 
                /* the edge may exist already and be attached to a face
                 * in this case we can find the best winding to use for the new face */
@@ -493,7 +493,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n
        /* --- */
 
        /* create the face */
-       f = BM_face_create_ngon(bm, vert_arr_map[winding[0]], vert_arr_map[winding[1]], edge_arr, totv, nodouble);
+       f = BM_face_create_ngon(bm, vert_arr_map[winding[0]], vert_arr_map[winding[1]], edge_arr, totv, create_flag);
 
        MEM_freeN(edge_arr);
        MEM_freeN(vert_arr_map);
@@ -856,7 +856,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
 
        v = BM_iter_new(&iter, bm_old, BM_VERTS_OF_MESH, NULL);
        for (i = 0; v; v = BM_iter_step(&iter), i++) {
-               v2 = BM_vert_create(bm_new, v->co, NULL); /* copy between meshes so cant use 'example' argument */
+               v2 = BM_vert_create(bm_new, v->co, NULL, BM_CREATE_SKIP_CD); /* copy between meshes so cant use 'example' argument */
                BM_elem_attrs_copy(bm_old, bm_new, v, v2);
                vtable[i] = v2;
                BM_elem_index_set(v, i); /* set_inline */
@@ -873,7 +873,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
                e2 = BM_edge_create(bm_new,
                                    vtable[BM_elem_index_get(e->v1)],
                                    vtable[BM_elem_index_get(e->v2)],
-                                   e, FALSE);
+                                   e, BM_CREATE_SKIP_CD);
 
                BM_elem_attrs_copy(bm_old, bm_new, e, e2);
                etable[i] = e2;
@@ -909,7 +909,7 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
                        v2 = vtable[BM_elem_index_get(loops[0]->v)];
                }
 
-               f2 = BM_face_create_ngon(bm_new, v, v2, edges, f->len, FALSE);
+               f2 = BM_face_create_ngon(bm_new, v, v2, edges, f->len, BM_CREATE_SKIP_CD);
                if (UNLIKELY(f2 == NULL)) {
                        continue;
                }
index 29b8404688499d2b99e9e2dbc766229d887f76c3..60c465e5f5a210497f1d3d57eeef89dbf512fbc4 100644 (file)
@@ -36,9 +36,9 @@ BMFace *BM_face_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, B
 
 void BM_face_copy_shared(BMesh *bm, BMFace *f);
 
-BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, int nodouble);
+BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, const int create_flag);
 
-BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int len, int nodouble);
+BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int len, const int create_flag);
 
 void BMO_remove_tagged_faces(BMesh *bm, const short oflag);
 void BMO_remove_tagged_edges(BMesh *bm, const short oflag);
index 541ac28bf1a4ed9ce6ba8f27282d7b4f788e0c5d..059f9de5a42fd67a6e42a12f1b7131c050f62b8f 100644 (file)
@@ -54,7 +54,7 @@
 /**
  * \brief Main function for creating a new vertex.
  */
-BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
+BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example, const eBMCreateFlag create_flag)
 {
        BMVert *v = BLI_mempool_calloc(bm->vpool);
 
@@ -64,6 +64,9 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
        BM_elem_index_set(v, -1); /* set_ok_invalid */
 #endif
 
+       /* disallow this flag for verts - its meaningless */
+       BLI_assert((create_flag & BM_CREATE_NO_DOUBLE) == 0);
+
        bm->elem_index_dirty |= BM_VERT; /* may add to middle of the pool */
 
        bm->totvert++;
@@ -80,17 +83,20 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
                v->oflags = BLI_mempool_calloc(bm->toolflagpool);
        }
 
-       CustomData_bmesh_set_default(&bm->vdata, &v->head.data);
-       
-       if (example) {
-               int *keyi;
+       if (!(create_flag & BM_CREATE_SKIP_CD)) {
+               if (example) {
+                       int *keyi;
 
-               BM_elem_attrs_copy(bm, bm, example, v);
+                       BM_elem_attrs_copy(bm, bm, example, v);
 
-               /* exception: don't copy the original shapekey index */
-               keyi = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_SHAPE_KEYINDEX);
-               if (keyi) {
-                       *keyi = ORIGINDEX_NONE;
+                       /* exception: don't copy the original shapekey index */
+                       keyi = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_SHAPE_KEYINDEX);
+                       if (keyi) {
+                               *keyi = ORIGINDEX_NONE;
+                       }
+               }
+               else {
+                       CustomData_bmesh_set_default(&bm->vdata, &v->head.data);
                }
        }
 
@@ -105,11 +111,11 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
  * \note Duplicate edges are supported by the API however users should _never_ see them.
  * so unless you need a unique edge or know the edge won't exist, you should call with \a nodouble = TRUE
  */
-BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, int nodouble)
+BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, const eBMCreateFlag create_flag)
 {
        BMEdge *e;
        
-       if (nodouble && (e = BM_edge_exists(v1, v2)))
+       if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2)))
                return e;
        
        e = BLI_mempool_calloc(bm->epool);
@@ -136,20 +142,26 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example,
        
        BM_elem_flag_enable(e, BM_ELEM_SMOOTH | BM_ELEM_DRAW);
        
-       CustomData_bmesh_set_default(&bm->edata, &e->head.data);
-       
        bmesh_disk_edge_append(e, e->v1);
        bmesh_disk_edge_append(e, e->v2);
        
-       if (example)
-               BM_elem_attrs_copy(bm, bm, example, e);
+       if (!(create_flag & BM_CREATE_SKIP_CD)) {
+               if (example) {
+                       BM_elem_attrs_copy(bm, bm, example, e);
+               }
+               else {
+                       CustomData_bmesh_set_default(&bm->edata, &e->head.data);
+               }
+       }
+
        
        BM_CHECK_ELEMENT(e);
 
        return e;
 }
 
-static BMLoop *bm_loop_create(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, const BMLoop *example)
+static BMLoop *bm_loop_create(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f,
+                              const BMLoop *example, const eBMCreateFlag create_flag)
 {
        BMLoop *l = NULL;
 
@@ -164,22 +176,24 @@ static BMLoop *bm_loop_create(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, const
 
        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);
+       if (!(create_flag & BM_CREATE_SKIP_CD)) {
+               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;
 }
 
-static BMLoop *bm_face_boundary_add(BMesh *bm, BMFace *f, BMVert *startv, BMEdge *starte)
+static BMLoop *bm_face_boundary_add(BMesh *bm, BMFace *f, BMVert *startv, BMEdge *starte, const int create_flag)
 {
 #ifdef USE_BMESH_HOLES
        BMLoopList *lst = BLI_mempool_calloc(bm->looplistpool);
 #endif
-       BMLoop *l = bm_loop_create(bm, startv, starte, f, NULL);
+       BMLoop *l = bm_loop_create(bm, startv, starte, f, starte->l, create_flag);
        
        bmesh_radial_append(starte, l);
 
@@ -211,7 +225,7 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short co
        i = 0;
        do {
                if (copyverts) {
-                       verts[i] = BM_vert_create(bm, l_iter->v->co, l_iter->v);
+                       verts[i] = BM_vert_create(bm, l_iter->v->co, l_iter->v, 0);
                }
                else {
                        verts[i] = l_iter->v;
@@ -234,7 +248,7 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short co
                                v1 = verts[(i + 1) % f->len];
                        }
                        
-                       edges[i] = BM_edge_create(bm,  v1, v2, l_iter->e, FALSE);
+                       edges[i] = BM_edge_create(bm,  v1, v2, l_iter->e, 0);
                }
                else {
                        edges[i] = l_iter->e;
@@ -242,7 +256,7 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short co
                i++;
        } while ((l_iter = l_iter->next) != l_first);
        
-       f_copy = BM_face_create(bm, verts, edges, f->len, FALSE);
+       f_copy = BM_face_create(bm, verts, edges, f->len, BM_CREATE_SKIP_CD);
        
        BM_elem_attrs_copy(bm, bm, f, f_copy);
        
@@ -263,7 +277,7 @@ BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short co
  * only create the face, since this calloc's the length is initialized to 0,
  * leave adding loops to the caller.
  */
-BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm)
+BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm, const eBMCreateFlag create_flag)
 {
        BMFace *f;
 
@@ -286,7 +300,9 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm)
                f->oflags = BLI_mempool_calloc(bm->toolflagpool);
        }
 
-       CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
+       if (!(create_flag & BM_CREATE_SKIP_CD)) {
+               CustomData_bmesh_set_default(&bm->pdata, &f->head.data);
+       }
 
 #ifdef USE_BMESH_HOLES
        f->totbounds = 0;
@@ -298,7 +314,7 @@ BLI_INLINE BMFace *bm_face_create__internal(BMesh *bm)
 /**
  * \brief Main face creation function
  */
-BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, int nodouble)
+BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, const eBMCreateFlag create_flag)
 {
        BMFace *f = NULL;
        BMLoop *l, *startl, *lastl;
@@ -309,7 +325,7 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
                return NULL;
        }
 
-       if (nodouble) {
+       if (create_flag & BM_CREATE_NO_DOUBLE) {
                /* Check if face already exists */
                overlap = BM_face_exists(verts, len, &f);
                if (overlap) {
@@ -320,14 +336,14 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
                }
        }
 
-       f = bm_face_create__internal(bm);
+       f = bm_face_create__internal(bm, create_flag);
 
-       startl = lastl = bm_face_boundary_add(bm, f, verts[0], edges[0]);
+       startl = lastl = bm_face_boundary_add(bm, f, verts[0], edges[0], create_flag);
        
        startl->v = verts[0];
        startl->e = edges[0];
        for (i = 1; i < len; i++) {
-               l = bm_loop_create(bm, verts[i], edges[i], f, edges[i]->l);
+               l = bm_loop_create(bm, verts[i], edges[i], f, edges[i]->l, create_flag);
                
                l->f = f;
                bmesh_radial_append(edges[i], l);
@@ -1033,7 +1049,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
        }
 
        /* create region face */
-       newf = BM_face_create_ngon(bm, v1, v2, edges, tote, FALSE);
+       newf = BM_face_create_ngon(bm, v1, v2, edges, tote, 0);
        if (UNLIKELY(!newf || BMO_error_occurred(bm))) {
                if (!BMO_error_occurred(bm))
                        err = N_("Invalid boundary region to join faces");
@@ -1139,7 +1155,7 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *UNUSED(example))
        BMLoopList *lst;
 #endif
 
-       f = bm_face_create__internal(bm);
+       f = bm_face_create__internal(bm, 0);
 
 #ifdef USE_BMESH_HOLES
        lst = BLI_mempool_calloc(bm->looplistpool);
@@ -1226,8 +1242,8 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
        e = BM_edge_create(bm, v1, v2, example, nodouble);
 
        f2 = bm_face_create__sfme(bm, f);
-       f1loop = bm_loop_create(bm, v2, e, f, v2loop);
-       f2loop = bm_loop_create(bm, v1, e, f2, v1loop);
+       f1loop = bm_loop_create(bm, v2, e, f, v2loop, 0);
+       f2loop = bm_loop_create(bm, v1, e, f2, v1loop, 0);
 
        f1loop->prev = v2loop->prev;
        f2loop->prev = v1loop->prev;
@@ -1359,8 +1375,8 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
 
        valence2 = bmesh_disk_count(tv);
 
-       nv = BM_vert_create(bm, tv->co, tv);
-       ne = BM_edge_create(bm, nv, tv, e, FALSE);
+       nv = BM_vert_create(bm, tv->co, tv, 0);
+       ne = BM_edge_create(bm, nv, tv, e, 0);
 
        bmesh_disk_edge_remove(ne, tv);
        bmesh_disk_edge_remove(ne, nv);
@@ -1403,7 +1419,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
                        nextl = nextl != nextl->radial_next ? nextl->radial_next : NULL;
                        bmesh_radial_loop_remove(l, NULL);
 
-                       nl = bm_loop_create(bm, NULL, NULL, l->f, l);
+                       nl = bm_loop_create(bm, NULL, NULL, l->f, l, 0);
                        nl->prev = l;
                        nl->next = (l->next);
                        nl->prev->next = nl;
@@ -1919,7 +1935,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
        verts = MEM_callocN(sizeof(BMVert *) * maxindex, __func__);
        verts[0] = v;
        for (i = 1; i < maxindex; i++) {
-               verts[i] = BM_vert_create(bm, v->co, v);
+               verts[i] = BM_vert_create(bm, v->co, v, 0);
        }
 
        /* Replace v with the new verts in each group */
@@ -2085,7 +2101,7 @@ int bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep)
                e->l = l_sep->radial_next;
        }
 
-       ne = BM_edge_create(bm, e->v1, e->v2, e, FALSE);
+       ne = BM_edge_create(bm, e->v1, e->v2, e, 0);
        bmesh_radial_loop_remove(l_sep, e);
        bmesh_radial_append(ne, l_sep);
        l_sep->e = ne;
index 0667ed9ea1cc3b7adbf788b06451cda3f2a8283d..5fd4a6ec7df6b51952aad855b38ac2fe75668437 100644 (file)
 
 BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short copyedges);
 
-BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example);
-BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, int nodouble);
-BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, int nodouble);
+typedef enum eBMCreateFlag {
+       /* faces and edges only */
+       BM_CREATE_NO_DOUBLE = (1 << 1),
+       /* Skip CustomData - for all element types data,
+        * use if we immediately write customdata into the element so this skips copying from 'example'
+        * args or setting defaults, speeds up conversion when data is converted all at once. */
+       BM_CREATE_SKIP_CD   = (1 << 2),
+} eBMCreateFlag;
+
+BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example, const eBMCreateFlag create_flag);
+BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, const eBMCreateFlag create_flag);
+BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, const eBMCreateFlag create_flag);
 
 void    BM_face_edges_kill(BMesh *bm, BMFace *f);
 void    BM_face_verts_kill(BMesh *bm, BMFace *f);
index 62abf43829b7c406e5b5e4418b9b9c3378b95aa9..6617cc806c782b3900ad2a6888b81fae435564a9 100644 (file)
@@ -206,7 +206,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
        CustomData_bmesh_init_pool(&bm->pdata, me->totpoly, BM_FACE);
 
        for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
-               v = BM_vert_create(bm, keyco && set_key ? keyco[i] : mvert->co, NULL);
+               v = BM_vert_create(bm, keyco && set_key ? keyco[i] : mvert->co, NULL, BM_CREATE_SKIP_CD);
                BM_elem_index_set(v, i); /* set_ok */
                vt[i] = v;
 
@@ -254,7 +254,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
 
        medge = me->medge;
        for (i = 0; i < me->totedge; i++, medge++) {
-               e = BM_edge_create(bm, vt[medge->v1], vt[medge->v2], NULL, FALSE);
+               e = BM_edge_create(bm, vt[medge->v1], vt[medge->v2], NULL, BM_CREATE_SKIP_CD);
                BM_elem_index_set(e, i); /* set_ok */
                et[i] = e;
 
@@ -312,7 +312,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
                }
 #endif
 
-               f = BM_face_create(bm, verts, fedges, mpoly->totloop, FALSE);
+               f = BM_face_create(bm, verts, fedges, mpoly->totloop, BM_CREATE_SKIP_CD);
 
                if (UNLIKELY(f == NULL)) {
                        printf("%s: Warning! Bad face in mesh"
index a6bbd0927608534995db0a710c0cbc0419a5e207..aa69806fb37fe8d0eb912814a66fbcb8adf5e226 100644 (file)
@@ -274,7 +274,7 @@ static int UNUSED_FUNCTION(rotsys_fill_faces)(BMesh *bm, EdgeData *edata, VertDa
                        if (!ok || BLI_array_count(edges) < 3)
                                continue;
                        
-                       f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), TRUE);
+                       f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), BM_CREATE_NO_DOUBLE);
                        if (UNLIKELY(f == NULL)) {
                                continue;
                        }
@@ -611,11 +611,11 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
                        
                        v2 = BM_vert_create(bm, co, NULL);
                        BM_elem_index_set(v2, -1); /* set_dirty! */
-                       //BM_edge_create(bm, cv, v2, NULL, FALSE);
+                       //BM_edge_create(bm, cv, v2, NULL, 0);
                        
                        BM_vert_select_set(bm, v2, TRUE);
                        if (lastv) {
-                               e2 = BM_edge_create(bm, lastv, v2, NULL, FALSE);
+                               e2 = BM_edge_create(bm, lastv, v2, NULL, 0);
                                BM_edge_select_set(bm, e2, TRUE);
                        }
                        
@@ -1051,7 +1051,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
                            /* fairly expensive check - see if there are already faces filling this area */
                            (BM_face_exists_multi_edge(edges, i) == FALSE))
                        {
-                               f = BM_face_create_ngon(bm, v1, v2, edges, i, TRUE);
+                               f = BM_face_create_ngon(bm, v1, v2, edges, i, BM_CREATE_NO_DOUBLE);
                                if (f && !BMO_elem_flag_test(bm, f, ELE_ORIG)) {
                                        BMO_elem_flag_enable(bm, f, FACE_NEW);
                                        f->mat_nr = mat_nr;
@@ -1249,9 +1249,9 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op)
                        SWAP(BMVert *, v3, v4);
                }
 
-               e = BM_edge_create(bm, v1, v3, NULL, TRUE);
+               e = BM_edge_create(bm, v1, v3, NULL, BM_CREATE_NO_DOUBLE);
                BMO_elem_flag_enable(bm, e, ELE_NEW);
-               e = BM_edge_create(bm, v2, v4, NULL, TRUE);
+               e = BM_edge_create(bm, v2, v4, NULL, BM_CREATE_NO_DOUBLE);
                BMO_elem_flag_enable(bm, e, ELE_NEW);
        }
        else if (edges1) {
@@ -1261,7 +1261,7 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op)
                        v1 = BM_vert_in_edge(edges1[1], edges1[0]->v1) ? edges1[0]->v2 : edges1[0]->v1;
                        i  = BLI_array_count(edges1) - 1;
                        v2 = BM_vert_in_edge(edges1[i - 1], edges1[i]->v1) ? edges1[i]->v2 : edges1[i]->v1;
-                       e  = BM_edge_create(bm, v1, v2, NULL, TRUE);
+                       e  = BM_edge_create(bm, v1, v2, NULL, BM_CREATE_NO_DOUBLE);
                        BMO_elem_flag_enable(bm, e, ELE_NEW);
                }
        }
@@ -1359,10 +1359,10 @@ void bmo_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);
+                       e = BM_edge_create(bm, v_free, v_a, NULL, BM_CREATE_NO_DOUBLE);
                        BMO_elem_flag_enable(bm, e, ELE_NEW);
 
-                       e = BM_edge_create(bm, v_free, v_b, NULL, TRUE);
+                       e = BM_edge_create(bm, v_free, v_b, NULL, BM_CREATE_NO_DOUBLE);
                        BMO_elem_flag_enable(bm, e, ELE_NEW);
                }
        }
@@ -1420,7 +1420,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
 
        if (amount == 2) {
                /* create edge */
-               e = BM_edge_create(bm, verts[0], verts[1], NULL, TRUE);
+               e = BM_edge_create(bm, verts[0], verts[1], NULL, BM_CREATE_NO_DOUBLE);
                BMO_elem_flag_enable(bm, e, ELE_OUT);
                BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "edges.out", BM_EDGE, ELE_OUT);
        }
@@ -1461,7 +1461,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
                                if (ese->htype == BM_VERT) {
                                        v = (BMVert *)ese->ele;
                                        if (v_prev) {
-                                               e = BM_edge_create(bm, v, v_prev, NULL, TRUE);
+                                               e = BM_edge_create(bm, v, v_prev, NULL, BM_CREATE_NO_DOUBLE);
                                                BMO_elem_flag_enable(bm, e, ELE_OUT);
                                        }
                                        v_prev = v;
@@ -1483,7 +1483,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
                        i++;
                }
 
-               f = BM_face_create_ngon_vcloud(bm, vert_arr, totv, TRUE);
+               f = BM_face_create_ngon_vcloud(bm, vert_arr, totv, BM_CREATE_NO_DOUBLE);
 
                if (f) {
                        BMO_elem_flag_enable(bm, f, ELE_OUT);
index 67460a0298efc6c3baa1611bf5bf28063387297e..9a58d7acfb94637e3f5f3b9cec33bea21c6c425d 100644 (file)
@@ -49,7 +49,7 @@ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *tar
        BMVert *target_vertex = NULL;
 
        /* Create a new vertex */
-       target_vertex = BM_vert_create(target_mesh, source_vertex->co, NULL);
+       target_vertex = BM_vert_create(target_mesh, source_vertex->co, NULL, BM_CREATE_SKIP_CD);
        
        /* Insert new vertex into the vert hash */
        BLI_ghash_insert(vhash, source_vertex, target_vertex);
@@ -98,7 +98,7 @@ static BMEdge *copy_edge(BMOperator *op,
        target_vert2 = BLI_ghash_lookup(vhash, source_edge->v2);
        
        /* Create a new edge */
-       target_edge = BM_edge_create(target_mesh, target_vert1, target_vert2, NULL, FALSE);
+       target_edge = BM_edge_create(target_mesh, target_vert1, target_vert2, NULL, BM_CREATE_SKIP_CD);
        
        /* add to new/old edge map if necassary */
        if (rlen < 2) {
@@ -156,7 +156,7 @@ static BMFace *copy_face(BMOperator *op,
        }
 
        /* create new face */
-       target_face = BM_face_create(target_mesh, vtar, edar, source_face->len, FALSE);
+       target_face = BM_face_create(target_mesh, vtar, edar, source_face->len, BM_CREATE_SKIP_CD);
        BMO_slot_map_elem_insert(op, slot_facemap_out, source_face, target_face);
        BMO_slot_map_elem_insert(op, slot_facemap_out, target_face, source_face);
 
index 1ab640ba6a5aeb7a0d6f8e4ca737753108792983..065a1b57737cd2c3fc8aa9036e13f1ea46fa1cba 100644 (file)
@@ -67,11 +67,11 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
                i = 0;
                firstv = lastv = NULL;
                BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
-                       v = BM_vert_create(bm, l->v->co, l->v);
+                       v = BM_vert_create(bm, l->v->co, l->v, 0);
 
                        /* skip on the first iteration */
                        if (lastv) {
-                               e = BM_edge_create(bm, lastv, v, l->e, FALSE);
+                               e = BM_edge_create(bm, lastv, v, l->e, 0);
                                edges[i++] = e;
                        }
 
@@ -81,12 +81,12 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
                }
 
                /* this fits in the array because we skip one in the loop above */
-               e = BM_edge_create(bm, v, firstv, laste, FALSE);
+               e = BM_edge_create(bm, v, firstv, laste, 0);
                edges[i++] = e;
 
                BMO_elem_flag_enable(bm, f, EXT_DEL);
 
-               f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, FALSE);
+               f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, 0);
                if (UNLIKELY(f2 == NULL)) {
                        BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed: could not create face");
                        BLI_array_free(edges);
@@ -241,11 +241,11 @@ void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op)
        const int has_vskin = CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN);
 
        for (v = BMO_iter_new(&siter, op->slots_in, "verts", BM_VERT); v; v = BMO_iter_step(&siter)) {
-               dupev = BM_vert_create(bm, v->co, v);
+               dupev = BM_vert_create(bm, v->co, v, 0);
                if (has_vskin)
                        bm_extrude_disable_skin_root(bm, v);
 
-               e = BM_edge_create(bm, v, dupev, NULL, FALSE);
+               e = BM_edge_create(bm, v, dupev, NULL, 0);
 
                BMO_elem_flag_enable(bm, e, EXT_KEEP);
                BMO_elem_flag_enable(bm, dupev, EXT_KEEP);
@@ -430,7 +430,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
        /* link isolated vert */
        for (v = BMO_iter_new(&siter, dupeop.slots_out, "isovert_map.out", 0); v; v = BMO_iter_step(&siter)) {
                v2 = *((void **)BMO_iter_map_value(&siter));
-               BM_edge_create(bm, v, v2, v->e, TRUE);
+               BM_edge_create(bm, v, v2, v->e, BM_CREATE_NO_DOUBLE);
        }
 
        /* cleanup */
index 08fc97ea262341eb234a84388978e90604dc4d9c..e2da4f4f89c2ba3a5bf7ff1c619ab6b49e318b7b 100644 (file)
@@ -113,9 +113,9 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles)
 
                if (!t->skip) {
                        BMEdge *edges[3] = {
-                               BM_edge_create(bm, t->v[0], t->v[1], NULL, TRUE),
-                               BM_edge_create(bm, t->v[1], t->v[2], NULL, TRUE),
-                               BM_edge_create(bm, t->v[2], t->v[0], NULL, TRUE)
+                               BM_edge_create(bm, t->v[0], t->v[1], NULL, BM_CREATE_NO_DOUBLE),
+                               BM_edge_create(bm, t->v[1], t->v[2], NULL, BM_CREATE_NO_DOUBLE),
+                               BM_edge_create(bm, t->v[2], t->v[0], NULL, BM_CREATE_NO_DOUBLE)
                        };
                        BMFace *f, *example = NULL;
 
index 9abf129a5295a3b0cd3dbc6ac20bdb10beb75d75..cef1181f63b90a2f8a7e0f31df76427b8ae0a57f 100644 (file)
@@ -181,7 +181,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
 
                if (es->e_new == es->e_old) { /* happens on boundary edges */
                        /* take care here, we're creating this double edge which _must_ have its verts replaced later on */
-                       es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, FALSE);
+                       es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, 0);
                }
 
                /* store index back to original in 'edge_info' */
@@ -205,7 +205,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
                v1 = BM_vert_create(bm, tvec, NULL);
                v2 = BM_vert_create(bm, tvec, NULL);
                madd_v3_v3fl(v2->co, es->no, 0.1f);
-               BM_edge_create(bm, v1, v2, NULL, FALSE);
+               BM_edge_create(bm, v1, v2, NULL, 0);
        }
 #endif
 
index b8f154350ea48cf2eca98e6106733a9e2002cdce..c582f710f43ff159508d63f21f5d214c09728456 100644 (file)
@@ -248,11 +248,11 @@ void bmo_create_grid_exec(BMesh *bm, BMOperator *op)
                vec[2] = 0.0f;
                mul_m4_v3(mat, vec);
 
-               eve = BM_vert_create(bm, vec, NULL);
+               eve = BM_vert_create(bm, vec, NULL, 0);
                BMO_elem_flag_enable(bm, eve, VERT_MARK);
 
                if (a != 0) {
-                       e = BM_edge_create(bm, preveve, eve, NULL, TRUE);
+                       e = BM_edge_create(bm, preveve, eve, NULL, BM_CREATE_NO_DOUBLE);
                        BMO_elem_flag_enable(bm, e, EDGE_ORIG);
                }
 
@@ -317,11 +317,11 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
                vec[0] = -dia * sinf(phi);
                vec[1] = 0.0;
                vec[2] = dia * cosf(phi);
-               eve = BM_vert_create(bm, vec, NULL);
+               eve = BM_vert_create(bm, vec, NULL, 0);
                BMO_elem_flag_enable(bm, eve, VERT_MARK);
 
                if (a != 0) {
-                       e = BM_edge_create(bm, preveve, eve, NULL, FALSE);
+                       e = BM_edge_create(bm, preveve, eve, NULL, 0);
                        BMO_elem_flag_enable(bm, e, EDGE_ORIG);
                }
 
@@ -407,7 +407,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
                vec[0] = dia_div * icovert[a][0];
                vec[1] = dia_div * icovert[a][1];
                vec[2] = dia_div * icovert[a][2];
-               eva[a] = BM_vert_create(bm, vec, NULL);
+               eva[a] = BM_vert_create(bm, vec, NULL, 0);
 
                BMO_elem_flag_enable(bm, eva[a], VERT_MARK);
        }
@@ -470,12 +470,12 @@ void bmo_create_monkey_exec(BMesh *bm, BMOperator *op)
 
                v[0] = (monkeyv[i][0] + 127) / 128.0, v[1] = monkeyv[i][1] / 128.0, v[2] = monkeyv[i][2] / 128.0;
 
-               tv[i] = BM_vert_create(bm, v, NULL);
+               tv[i] = BM_vert_create(bm, v, NULL, 0);
                BMO_elem_flag_enable(bm, tv[i], VERT_MARK);
 
                tv[monkeynv + i] = (fabsf(v[0] = -v[0]) < 0.001f) ?
                                   tv[i] :
-                                  (eve = BM_vert_create(bm, v, NULL), mul_m4_v3(mat, eve->co), eve);
+                                  (eve = BM_vert_create(bm, v, NULL, 0), mul_m4_v3(mat, eve->co), eve);
 
                BMO_elem_flag_enable(bm, tv[monkeynv + i], VERT_MARK);
 
@@ -527,7 +527,7 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
                zero_v3(vec);
                mul_m4_v3(mat, vec);
                
-               cent1 = BM_vert_create(bm, vec, NULL);
+               cent1 = BM_vert_create(bm, vec, NULL, 0);
                BMO_elem_flag_enable(bm, cent1, VERT_MARK);
        }
 
@@ -537,12 +537,12 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
                vec[1] = dia * cosf(phi);
                vec[2] = 0.0f;
                mul_m4_v3(mat, vec);
-               v1 = BM_vert_create(bm, vec, NULL);
+               v1 = BM_vert_create(bm, vec, NULL, 0);
 
                BMO_elem_flag_enable(bm, v1, VERT_MARK);
                
                if (lastv1)
-                       BM_edge_create(bm, v1, lastv1, NULL, FALSE);
+                       BM_edge_create(bm, v1, lastv1, NULL, 0);
                
                if (a && cap_ends) {
                        BMFace *f;
@@ -560,7 +560,7 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op)
        if (!a)
                return;
 
-       BM_edge_create(bm, firstv1, lastv1, NULL, FALSE);
+       BM_edge_create(bm, firstv1, lastv1, NULL, 0);
 
        if (cap_ends) {
                BMFace *f;
@@ -602,13 +602,13 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
                vec[2] = -depth;
                mul_m4_v3(mat, vec);
                
-               cent1 = BM_vert_create(bm, vec, NULL);
+               cent1 = BM_vert_create(bm, vec, NULL, 0);
 
                vec[0] = vec[1] = 0.0f;
                vec[2] = depth;
                mul_m4_v3(mat, vec);
                
-               cent2 = BM_vert_create(bm, vec, NULL);
+               cent2 = BM_vert_create(bm, vec, NULL, 0);
 
                BMO_elem_flag_enable(bm, cent1, VERT_MARK);
                BMO_elem_flag_enable(bm, cent2, VERT_MARK);
@@ -619,13 +619,13 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op)
                vec[1] = dia1 * cosf(phi);
                vec[2] = -depth;
                mul_m4_v3(mat, vec);
-               v1 = BM_vert_create(bm, vec, NULL);
+               v1 = BM_vert_create(bm, vec, NULL, 0);
 
                vec[0] = dia2 * sinf(phi);
                vec[1] = dia2 * cosf(phi);
                vec[2] = depth;
                mul_m4_v3(mat, vec);
-               v2 = BM_vert_create(bm, vec, NULL);
+               v2 = BM_vert_create(bm, vec, NULL, 0);
 
                BMO_elem_flag_enable(bm, v1, VERT_MARK);
                BMO_elem_flag_enable(bm, v2, VERT_MARK);
@@ -685,56 +685,56 @@ void bmo_create_cube_exec(BMesh *bm, BMOperator *op)
        vec[1] = -off;
        vec[2] = -off;
        mul_m4_v3(mat, vec);
-       v1 = BM_vert_create(bm, vec, NULL);
+       v1 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v1, VERT_MARK);
 
        vec[0] = -off;
        vec[1] = off;
        vec[2] = -off;
        mul_m4_v3(mat, vec);
-       v2 = BM_vert_create(bm, vec, NULL);
+       v2 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v2, VERT_MARK);
 
        vec[0] = off;
        vec[1] = off;
        vec[2] = -off;
        mul_m4_v3(mat, vec);
-       v3 = BM_vert_create(bm, vec, NULL);
+       v3 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v3, VERT_MARK);
 
        vec[0] = off;
        vec[1] = -off;
        vec[2] = -off;
        mul_m4_v3(mat, vec);
-       v4 = BM_vert_create(bm, vec, NULL);
+       v4 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v4, VERT_MARK);
 
        vec[0] = -off;
        vec[1] = -off;
        vec[2] = off;
        mul_m4_v3(mat, vec);
-       v5 = BM_vert_create(bm, vec, NULL);
+       v5 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v5, VERT_MARK);
 
        vec[0] = -off;
        vec[1] = off;
        vec[2] = off;
        mul_m4_v3(mat, vec);
-       v6 = BM_vert_create(bm, vec, NULL);
+       v6 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v6, VERT_MARK);
 
        vec[0] = off;
        vec[1] = off;
        vec[2] = off;
        mul_m4_v3(mat, vec);
-       v7 = BM_vert_create(bm, vec, NULL);
+       v7 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v7, VERT_MARK);
 
        vec[0] = off;
        vec[1] = -off;
        vec[2] = off;
        mul_m4_v3(mat, vec);
-       v8 = BM_vert_create(bm, vec, NULL);
+       v8 = BM_vert_create(bm, vec, NULL, 0);
        BMO_elem_flag_enable(bm, v8, VERT_MARK);
 
        /* the four sides */
index d27a90f0366f2da272433238e8aab1ab5e5046e7..87e26f11d4b1084c4bf3d9b8b834a6168dd71c07 100644 (file)
@@ -136,7 +136,7 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
                                BMO_elem_flag_enable(bm, e, EDGE_COL);
                        }
                        else if (!BM_edge_exists(v, v2)) {
-                               BM_edge_create(bm, v, v2, e, TRUE);
+                               BM_edge_create(bm, v, v2, e, BM_CREATE_NO_DOUBLE);
                        }
 
                        BMO_elem_flag_enable(bm, e, ELE_DEL);
@@ -214,7 +214,7 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op)
                        v2 = BMO_slot_map_elem_get(slot_targetmap, v2);
                }
                
-               f2 = BM_face_create_ngon(bm, v, v2, edges, a, TRUE);
+               f2 = BM_face_create_ngon(bm, v, v2, edges, a, BM_CREATE_NO_DOUBLE);
                if (f2 && (f2 != f)) {
                        BM_elem_attrs_copy(bm, bm, f, f2);
 
index a58db1e69611f122ca9604047de58403b12681d9..248c7268ac69ec83a3fbeb62c8d1d9deb5f875b4 100644 (file)
@@ -106,7 +106,7 @@ static void symm_verts_mirror(Symm *symm)
                                copy_v3_v3(co, src_v->co);
                                co[symm->axis] = -co[symm->axis];
 
-                               dst_v = BM_vert_create(symm->bm, co, src_v);
+                               dst_v = BM_vert_create(symm->bm, co, src_v, 0);
                                BMO_elem_flag_enable(symm->bm, dst_v, SYMM_OUTPUT_GEOM);
                                BLI_ghash_insert(symm->vert_symm_map, src_v, dst_v);
                                break;
@@ -183,7 +183,7 @@ static void symm_split_asymmetric_edges(Symm *symm)
                        co[symm->axis] = 0;
 
                        /* Edge is asymmetric, split it with a new vertex */
-                       v = BM_vert_create(symm->bm, co, e->v1);
+                       v = BM_vert_create(symm->bm, co, e->v1, 0);
                        BMO_elem_flag_enable(symm->bm, v, SYMM_OUTPUT_GEOM);
                        BLI_ghash_insert(symm->edge_split_map, e, v);
                }
@@ -203,7 +203,7 @@ static void symm_mirror_edges(Symm *symm)
                v2 = BLI_ghash_lookup(symm->vert_symm_map, e->v2);
 
                if (v1 && v2) {
-                       e_new = BM_edge_create(symm->bm, v1, v2, e, TRUE);
+                       e_new = BM_edge_create(symm->bm, v1, v2, e, BM_CREATE_NO_DOUBLE);
                        BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
                }
                else if (v1 || v2) {
@@ -212,18 +212,18 @@ static void symm_mirror_edges(Symm *symm)
 
                                /* Output the keep side of the split edge */
                                if (!v1) {
-                                       e_new = BM_edge_create(symm->bm, v_split, e->v2, e, TRUE);
+                                       e_new = BM_edge_create(symm->bm, v_split, e->v2, e, BM_CREATE_NO_DOUBLE);
                                        BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
                                        v1 = v_split;
                                }
                                else {
-                                       e_new = BM_edge_create(symm->bm, e->v1, v_split, e, TRUE);
+                                       e_new = BM_edge_create(symm->bm, e->v1, v_split, e, BM_CREATE_NO_DOUBLE);
                                        BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
                                        v2 = v_split;
                                }
 
                                /* Output the kill side of the split edge */
-                               e_new = BM_edge_create(symm->bm, v1, v2, e, TRUE);
+                               e_new = BM_edge_create(symm->bm, v1, v2, e, BM_CREATE_NO_DOUBLE);
                                BMO_elem_flag_enable(symm->bm, e_new, SYMM_OUTPUT_GEOM);
                        }
                }
@@ -356,7 +356,7 @@ static int symm_poly_next_crossing(const Symm *symm,
 }
 
 static BMFace *symm_face_create_v(BMesh *bm, BMFace *example,
-                                                                 BMVert **fv, BMEdge **fe, int len)
+                                  BMVert **fv, BMEdge **fe, int len)
 {
        BMFace *f_new;
        int i;
@@ -365,11 +365,11 @@ static BMFace *symm_face_create_v(BMesh *bm, BMFace *example,
                int j = (i + 1) % len;
                fe[i] = BM_edge_exists(fv[i], fv[j]);
                if (!fe[i]) {
-                       fe[i] = BM_edge_create(bm, fv[i], fv[j], NULL, FALSE);
+                       fe[i] = BM_edge_create(bm, fv[i], fv[j], NULL, 0);
                        BMO_elem_flag_enable(bm, fe[i], SYMM_OUTPUT_GEOM);
                }
        }
-       f_new = BM_face_create(bm, fv, fe, len, TRUE);
+       f_new = BM_face_create(bm, fv, fe, len, BM_CREATE_NO_DOUBLE);
        if (example)
                BM_elem_attrs_copy(bm, bm, example, f_new);
        BM_face_select_set(bm, f_new, TRUE);
index b88bc51f58696c526be9a5a24443f2c1a9709dd0..64dbf0cc0e7f258256e041379e5a242ea527179d 100644 (file)
@@ -47,7 +47,7 @@ void bmo_create_vert_exec(BMesh *bm, BMOperator *op)
 
        BMO_slot_vec_get(op->slots_in, "co", vec);
 
-       BMO_elem_flag_enable(bm, BM_vert_create(bm, vec, NULL), 1);
+       BMO_elem_flag_enable(bm, BM_vert_create(bm, vec, NULL, 0), 1);
        BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "vert.out", BM_VERT, 1);
 }
 
index 532145ab1298231ff3f50f753bf51e0eb2276325..7401704310f46b40d6cdc9eec146abf997f3da1a 100644 (file)
@@ -227,9 +227,9 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
                        }
 
                        madd_v3_v3v3fl(tvec, v_src->co, v_src->no, -fac);
-                       verts_neg[i] = BM_vert_create(bm, tvec, v_src);
+                       verts_neg[i] = BM_vert_create(bm, tvec, v_src, 0);
                        madd_v3_v3v3fl(tvec, v_src->co, v_src->no,  fac);
-                       verts_pos[i] = BM_vert_create(bm, tvec, v_src);
+                       verts_pos[i] = BM_vert_create(bm, tvec, v_src, 0);
                }
                else {
                        /* could skip this */
@@ -267,7 +267,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
                        }
 
                        madd_v3_v3v3fl(tvec, l->v->co, tvec, fac);
-                       verts_loop[verts_loop_tot] = BM_vert_create(bm, tvec, l->v);
+                       verts_loop[verts_loop_tot] = BM_vert_create(bm, tvec, l->v, 0);
 
 
                        if (use_boundary) {
@@ -301,7 +301,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op)
                                                                fac *= verts_relfac[BM_elem_index_get(l_pair[i]->v)];
                                                        }
                                                        madd_v3_v3v3fl(tvec, l_pair[i]->v->co, tvec, fac);
-                                                       verts_boundary[BM_elem_index_get(l_pair[i]->v)] = BM_vert_create(bm, tvec, l_pair[i]->v);
+                                                       verts_boundary[BM_elem_index_get(l_pair[i]->v)] = BM_vert_create(bm, tvec, l_pair[i]->v, 0);
                                                }
                                        }
                                }
index 62465ea98494f2125bb7783329ec4e79e6b3398f..cb35616a1f7234ee3e10ba83d47f28cf30958da3 100644 (file)
@@ -164,7 +164,7 @@ static NewVert *mesh_vert(VMesh *vm, int i, int j, int k)
 static void create_mesh_bmvert(BMesh *bm, VMesh *vm, int i, int j, int k, BMVert *eg)
 {
        NewVert *nv = mesh_vert(vm, i, j, k);
-       nv->v = BM_vert_create(bm, nv->co, eg);
+       nv->v = BM_vert_create(bm, nv->co, eg, 0);
 }
 
 static void copy_mesh_vert(VMesh *vm, int ito, int jto, int kto,
@@ -267,9 +267,9 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv, BMF
                BLI_array_fixedstack_declare(ee, BM_DEFAULT_NGON_STACK_SIZE, totv, __func__);
 
                for (i = 0; i < totv; i++) {
-                       ee[i] = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, TRUE);
+                       ee[i] = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, BM_CREATE_NO_DOUBLE);
                }
-               f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, FALSE);
+               f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, 0);
                BLI_array_fixedstack_free(ee);
        }
        if (facerep && f) {
@@ -1064,7 +1064,7 @@ static void bevel_build_rings(BMesh *bm, BevVert *bv)
                        }
                } while ((v = v->next) != vm->boundstart);
                mul_v3_fl(midco, 1.0f / nn);
-               bmv = BM_vert_create(bm, midco, NULL);
+               bmv = BM_vert_create(bm, midco, NULL, 0);
                v = vm->boundstart;
                do {
                        i = v->index;
index 47add7afb56cc00cbee3fb271e4c7daf6e48c2e1..9dc68848c69953325f691a5034f8061923ef3a10 100644 (file)
@@ -1965,7 +1965,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd)
                        kfe->e = NULL;
                }
 
-               kfe->e = BM_edge_create(bm, kfe->v1->v, kfe->v2->v, NULL, TRUE);
+               kfe->e = BM_edge_create(bm, kfe->v1->v, kfe->v2->v, NULL, BM_CREATE_NO_DOUBLE);
                BMO_elem_flag_enable(bm, kfe->e, BOUNDARY);
 
                for (ref = kfe->faces.first; ref; ref = ref->next) {
index a37835e11dc9d77caf055ec8a351190e755f9e2f..a73d52a0a63e6fddb35cc7af99210570a10597c4 100644 (file)
@@ -941,18 +941,18 @@ static void add_poly(SkinOutput *so,
        BLI_assert(v3 != v4);
        BLI_assert(v1 && v2 && v3);
 
-       edges[0] = BM_edge_create(so->bm, v1, v2, NULL, TRUE);
-       edges[1] = BM_edge_create(so->bm, v2, v3, NULL, TRUE);
+       edges[0] = BM_edge_create(so->bm, v1, v2, NULL, BM_CREATE_NO_DOUBLE);
+       edges[1] = BM_edge_create(so->bm, v2, v3, NULL, BM_CREATE_NO_DOUBLE);
        if (v4) {
-               edges[2] = BM_edge_create(so->bm, v3, v4, NULL, TRUE);
-               edges[3] = BM_edge_create(so->bm, v4, v1, NULL, TRUE);
+               edges[2] = BM_edge_create(so->bm, v3, v4, NULL, BM_CREATE_NO_DOUBLE);
+               edges[3] = BM_edge_create(so->bm, v4, v1, NULL, BM_CREATE_NO_DOUBLE);
        }
        else {
-               edges[2] = BM_edge_create(so->bm, v3, v1, NULL, TRUE);
+               edges[2] = BM_edge_create(so->bm, v3, v1, NULL, BM_CREATE_NO_DOUBLE);
                edges[3] = NULL;
        }
 
-       f = BM_face_create(so->bm, verts, edges, v4 ? 4 : 3, TRUE);
+       f = BM_face_create(so->bm, verts, edges, v4 ? 4 : 3, BM_CREATE_NO_DOUBLE);
        if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING)
                BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
        f->mat_nr = so->mat_nr;
@@ -996,7 +996,7 @@ static void output_frames(BMesh *bm,
                f = &sn->frames[i];
                for (j = 0; j < 4; j++) {
                        if (!f->merge[j].frame) {
-                               BMVert *v = f->verts[j] = BM_vert_create(bm, f->co[j], NULL);
+                               BMVert *v = f->verts[j] = BM_vert_create(bm, f->co[j], NULL, 0);
 
                                if (input_dvert) {
                                        MDeformVert *dv;
@@ -1309,7 +1309,7 @@ static void skin_hole_detach_partially_attached_frame(BMesh *bm, Frame *frame)
        /* Detach everything */
        for (i = 0; i < totattached; i++) {
                BMVert **av = &frame->verts[attached[i]];
-               (*av) = BM_vert_create(bm, (*av)->co, *av);
+               (*av) = BM_vert_create(bm, (*av)->co, *av, 0);
        }
 }
 
index f302f6ac38d9c011d36d0936704d685a10246e2b..5db9962e690cc9c83fc544ad632d21d1fed009f0 100644 (file)
@@ -728,7 +728,7 @@ static PyGetSetDef bpy_bmloop_getseters[] = {
 
 static PyGetSetDef bpy_bmvertseq_getseters[] = {
        {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_VERT},
-               {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+       {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
 };
 static PyGetSetDef bpy_bmedgeseq_getseters[] = {
        {(char *)"layers",    (getter)bpy_bmelemseq_layers_get, (setter)NULL, (char *)bpy_bmelemseq_layers_doc, (void *)BM_EDGE},
@@ -1746,7 +1746,7 @@ static PyObject *bpy_bmvertseq_new(BPy_BMElemSeq *self, PyObject *args)
                        return NULL;
                }
 
-               v = BM_vert_create(bm, co, NULL);
+               v = BM_vert_create(bm, co, NULL, 0);
 
                if (v == NULL) {
                        PyErr_SetString(PyExc_ValueError,
@@ -1815,7 +1815,7 @@ static PyObject *bpy_bmedgeseq_new(BPy_BMElemSeq *self, PyObject *args)
                        goto cleanup;
                }
 
-               e = BM_edge_create(bm, vert_array[0], vert_array[1], NULL, FALSE);
+               e = BM_edge_create(bm, vert_array[0], vert_array[1], NULL, 0);
 
                if (e == NULL) {
                        PyErr_SetString(PyExc_ValueError,
@@ -1901,10 +1901,10 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
 
                /* ensure edges */
                for (i = vert_seq_len - 1, i_next = 0; i_next < vert_seq_len; (i = i_next++)) {
-                       edge_array[i] = BM_edge_create(bm, vert_array[i], vert_array[i_next], NULL, TRUE);
+                       edge_array[i] = BM_edge_create(bm, vert_array[i], vert_array[i_next], NULL, BM_CREATE_NO_DOUBLE);
                }
 
-               f_new = BM_face_create(bm, vert_array, edge_array, vert_seq_len, FALSE);
+               f_new = BM_face_create(bm, vert_array, edge_array, vert_seq_len, 0);
 
                if (UNLIKELY(f_new == NULL)) {
                        PyErr_SetString(PyExc_ValueError,