Merging r45748 through r45791 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 19 Apr 2012 19:03:35 +0000 (19:03 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 19 Apr 2012 19:03:35 +0000 (19:03 +0000)
92 files changed:
intern/cycles/render/film.cpp
intern/opennl/CMakeLists.txt
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/bvhutils.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/text.c
source/blender/blenlib/BLI_scanfill.h
source/blender/blenlib/intern/rand.c
source/blender/blenlib/intern/scanfill.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_core.c
source/blender/bmesh/intern/bmesh_interp.c
source/blender/bmesh/intern/bmesh_iterators.c
source/blender/bmesh/intern/bmesh_iterators.h
source/blender/bmesh/intern/bmesh_marking.c
source/blender/bmesh/intern/bmesh_marking.h
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_mesh.h
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_validate.c
source/blender/bmesh/intern/bmesh_mods.c
source/blender/bmesh/intern/bmesh_mods.h
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_operators_private.h
source/blender/bmesh/intern/bmesh_polygon.c
source/blender/bmesh/intern/bmesh_polygon.h
source/blender/bmesh/intern/bmesh_private.h
source/blender/bmesh/intern/bmesh_queries.c
source/blender/bmesh/intern/bmesh_queries.h
source/blender/bmesh/intern/bmesh_walkers_impl.c
source/blender/bmesh/operators/bmo_bevel.c
source/blender/bmesh/operators/bmo_connect.c
source/blender/bmesh/operators/bmo_create.c
source/blender/bmesh/operators/bmo_dissolve.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/bmesh/operators/bmo_edgesplit.c
source/blender/bmesh/operators/bmo_extrude.c
source/blender/bmesh/operators/bmo_inset.c
source/blender/bmesh/operators/bmo_join_triangles.c
source/blender/bmesh/operators/bmo_mirror.c
source/blender/bmesh/operators/bmo_primitive.c
source/blender/bmesh/operators/bmo_removedoubles.c
source/blender/bmesh/operators/bmo_slide.c
source/blender/bmesh/operators/bmo_subdivide.c
source/blender/bmesh/operators/bmo_triangulate.c
source/blender/bmesh/operators/bmo_utils.c
source/blender/bmesh/tools/BME_bevel.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/interface/interface_ops.c
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/editmesh_bvh.c
source/blender/editors/mesh/editmesh_bvh.h
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/editmesh_rip.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_slide.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/mesh/mesh_navmesh.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_transform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/render/render_shading.c
source/blender/editors/sculpt_paint/sculpt_uv.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/util/crazyspace.c
source/blender/editors/uvedit/uvedit_buttons.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/editors/uvedit/uvedit_smart_stitch.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/modifiers/intern/MOD_array.c
source/blender/modifiers/intern/MOD_bevel.c
source/blender/modifiers/intern/MOD_edgesplit.c
source/blender/python/bmesh/bmesh_py_types.c
source/blender/python/bmesh/bmesh_py_types.h
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index ed4d0b2dcde6881a02aadfd68aa637ac64524ada..cc17f86fcb67860479cae6a55ddc498828cf88d4 100644 (file)
@@ -125,7 +125,6 @@ void Pass::add(PassType type, vector<Pass>& passes)
                        break;
                case PASS_AO:
                        pass.components = 4;
-                       pass.exposure = true;
                        break;
                case PASS_SHADOW:
                        pass.components = 4;
index 231802b31f2f1c99e5fe99156ebace091c4cad0a..322428386b1fd1960f8bc3e4d4fe5cbf61d2a379 100644 (file)
@@ -28,7 +28,7 @@ remove_strict_flags()
 
 # remove debug flag here since this is not a blender maintained library
 # and debug gives a lot of prints on UV unwrapping. developers can enable if they need to.
-remove_cc_flag("-DDEBUG")
+add_definitions(-UDEBUG)
 
 
 # quiet compiler warnings about undefined defines
index 296461e61c8f369f093b1db27d383787b5a330d3..e0fac79359d0e32e9b85bee387e5943a695ebf1e 100644 (file)
@@ -51,7 +51,7 @@ extern "C" {
                /* can be left blank, otherwise a,b,c... etc with no quotes */
 #define BLENDER_VERSION_CHAR   
                /* alpha/beta/rc/release, docs use this */
-#define BLENDER_VERSION_CYCLE  beta
+#define BLENDER_VERSION_CYCLE  rc
 
 extern char versionstr[]; /* from blender.c */
 
index d7c7a9a569b803ec53670f5f7949dbe963d7c22a..009b7ca7f990ce14087bbcd6333479de55d01dcc 100644 (file)
@@ -572,7 +572,7 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float
                                                        insert = 0;
                                                }
                                                else {
-                                                       BM_ITER(v, &iter, em->bm, BM_VERTS_OF_FACE, f) {
+                                                       BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) {
                                                                if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
                                                                        /* Don't insert triangles tessellated from faces that have
                                                                         * any selected verts.*/
index ed561a58cceb71e2d5c7a9df5d391d9c5ff04537..2d764142d269679c99704942283151c505036f42 100644 (file)
@@ -1929,7 +1929,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis
                mp->loopstart = j;
                mp->mat_nr = efa->mat_nr;
                
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, efa) {
+               BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
                        mloop->v = BM_elem_index_get(l->v);
                        mloop->e = BM_elem_index_get(l->e);
                        CustomData_from_bmesh_block(&bm->ldata, &dm->loopData, l->head.data, j);
index 2450f3ca83ed65ef3ddb068dd4c23984548047a3..536d4d9c823ababe40fcd9781836e732c9eea9e2 100644 (file)
@@ -2191,7 +2191,7 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
 
        if (t != BM_LOOPS_OF_FACE) {
                /*ensure all current elements follow new customdata layout*/
-               BM_ITER(h, &iter, bm, t, NULL) {
+               BM_ITER_MESH (h, &iter, bm, t) {
                        tmp = NULL;
                        CustomData_bmesh_copy_data(&destold, dest, h->data, &tmp);
                        CustomData_bmesh_free_block(&destold, &h->data);
@@ -2204,8 +2204,8 @@ void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
                BMIter liter;
 
                /*ensure all current elements follow new customdata layout*/
-               BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+                       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                                tmp = NULL;
                                CustomData_bmesh_copy_data(&destold, dest, l->head.data, &tmp);
                                CustomData_bmesh_free_block(&destold, &l->head.data);
index 3556b1ff5be47f7ec4bb18af7634f450ea470d91..b6aebcddd4c22ab6bd8d1a3bee84396bb4e57862 100644 (file)
@@ -493,7 +493,7 @@ static void emDM_drawUVEdges(DerivedMesh *dm)
        BMIter iter;
 
        glBegin(GL_LINES);
-       BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                BMIter liter;
                BMLoop *l;
                MLoopUV *lastluv = NULL, *firstluv = NULL;
@@ -501,7 +501,7 @@ static void emDM_drawUVEdges(DerivedMesh *dm)
                if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
                        continue;
 
-               BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
+               BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
                        MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
 
                        if (luv) {
@@ -1468,8 +1468,8 @@ static void emDM_copyLoopArray(DerivedMesh *dm, MLoop *loop_r)
 
        BM_mesh_elem_index_ensure(bm, BM_VERT | BM_EDGE);
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        loop_r->v = BM_elem_index_get(l->v);
                        loop_r->e = BM_elem_index_get(l->e);
                        loop_r++;
@@ -1486,7 +1486,7 @@ static void emDM_copyPolyArray(DerivedMesh *dm, MPoly *poly_r)
        int i;
 
        i = 0;
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                poly_r->flag = BM_face_flag_to_mflag(f);
                poly_r->loopstart = i;
                poly_r->totloop = f->len;
@@ -1559,7 +1559,7 @@ static void emDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3])
        int i;
 
        i= 0;
-       BM_ITER(eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH) {
                if (emdm->vertexCos) {
                        copy_v3_v3(cos_r[i], emdm->vertexCos[i]);
                }
@@ -1709,7 +1709,7 @@ DerivedMesh *getEditDerivedBMesh(
                bmdm->polyNos = MEM_mallocN(sizeof(*bmdm->polyNos)*bm->totface, "bmdm_pno");
 
                i = 0;
-               BM_ITER(efa, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (efa, &fiter, bm, BM_FACES_OF_MESH) {
                        BM_elem_index_set(efa, i); /* set_inline */
                        BM_face_normal_update_vcos(bm, efa, bmdm->polyNos[i], (float const (*)[3])vertexCos);
                        i++;
@@ -1719,7 +1719,7 @@ DerivedMesh *getEditDerivedBMesh(
                eve=BM_iter_new(&viter, bm, BM_VERTS_OF_MESH, NULL);
                for (i=0; eve; eve=BM_iter_step(&viter), i++) {
                        float *no = bmdm->vertexNos[i];
-                       BM_ITER(efa, &fiter, bm, BM_FACES_OF_VERT, eve) {
+                       BM_ITER_ELEM (efa, &fiter, eve, BM_FACES_OF_VERT) {
                                add_v3_v3(no, bmdm->polyNos[BM_elem_index_get(efa)]);
                        }
 
index 8c754a726f4fc2fe65c593b0d1514fdcd231c9f4..0a1c04672448cdc7d9940c9e13f80a478a0a7c65 100644 (file)
@@ -520,7 +520,7 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char **
                                a = 0;
                                co = MEM_callocN(sizeof(float) * 3 * me->edit_btmesh->bm->totvert, "key_block_get_data");
 
-                               BM_ITER(eve, &iter, me->edit_btmesh->bm, BM_VERTS_OF_MESH, NULL) {
+                               BM_ITER_MESH (eve, &iter, me->edit_btmesh->bm, BM_VERTS_OF_MESH) {
                                        copy_v3_v3(co[a], eve->co);
                                        a++;
                                }
index 4d8d6e937a9272d050c61543983fc2bad929f955..3271a623584ee1a13db367e9fda91d758287f705 100644 (file)
@@ -1770,7 +1770,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
                        BMVert *eve;
                        BMIter iter;
 
-                       BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
                                int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
                                
                                if (keyindex && *keyindex==nr) {
index 4ce159b8aaf4ac721dbb2336cda2f78df939e845..a7e49dd7fc877fecdfd046f8c6b5ed7771737ecc 100644 (file)
@@ -2560,6 +2560,8 @@ void txt_delete_char(Text *text)
                        txt_combine_lines(text, text->curl, text->curl->next);
                        txt_pop_sel(text);
                }
+               else
+                       return;
        }
        else { /* Just deleting a char */
                size_t c_len = 0;
index 5a5e55cc90abe863a1f54b386e0d0c931ac52a62..26bcd50ef3e8454fcc6a5dc64852ab75e4b92dcb 100644 (file)
@@ -51,7 +51,7 @@ typedef struct ScanFillContext
         * only to be used within loops, and not by one function at a time
         * free in the end, with argument '-1'
         */
-       #define MEM_ELEM_BLOCKSIZE 16384
+#define MEM_ELEM_BLOCKSIZE 16384
        struct mem_elements *melem__cur;
        int melem__offs;                   /* the current free address */
        ListBase melem__lb;
@@ -66,8 +66,8 @@ typedef struct ScanFillVert
        struct ScanFillVert *next, *prev;
        union {
                struct ScanFillVert *v;
-               void            *p;
-               intptr_t         l;
+               void                *p;
+               intptr_t             l;
        } tmp;
        float co[3]; /* vertex location */
        float xy[2]; /* 2D copy of vertex location (using dominant axis) */
@@ -94,10 +94,6 @@ typedef struct ScanFillFace
 struct ScanFillVert *BLI_addfillvert(ScanFillContext *sf_ctx, const float vec[3]);
 struct ScanFillEdge *BLI_addfilledge(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2);
 
-/* Optionally set ScanFillEdge f to this to mark original boundary edges.
- * Only needed if there are internal diagonal edges passed to BLI_edgefill. */
-#define FILLBOUNDARY 1
-
 int BLI_begin_edgefill(ScanFillContext *sf_ctx);
 int BLI_edgefill(ScanFillContext *sf_ctx, const short do_quad_tri_speedup);
 int BLI_edgefill_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup,
index 20f0a11f75f1b8449269535ed14780f1a25e3fbf..2e722c2a135a48d6431d794d6d19efcff8091d7d 100644 (file)
@@ -119,6 +119,8 @@ void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems)
 
        temp = malloc(elemSize);
 
+       /* XXX Shouldn’t it rather be "while (i--) {" ?
+        *     Else we have no guaranty first (0) element has a chance to be shuffled... --mont29 */
        while (--i) {
                int j = rng_getInt(rng)%numElems;
                if (i!=j) {
index 6d7c3b0a19cc01ea4b13a383681323e4dec3c1cc..20dbf29f6bc08e55552fe5e9724e733d93d3b941 100644 (file)
@@ -93,7 +93,17 @@ typedef struct ScanFillVertLink {
 
 /* local funcs */
 
-#define COMPLIMIT   0.00003f
+#define SF_EPSILON   0.00003f
+
+#define SF_VERT_UNKNOWN  1    /* TODO, what is this for exactly? - need to document it! */
+#define SF_VERT_ZERO_LEN 255
+
+/* Optionally set ScanFillEdge f to this to mark original boundary edges.
+ * Only needed if there are internal diagonal edges passed to BLI_edgefill. */
+#define SF_EDGE_BOUNDARY 1
+#define SF_EDGE_UNKNOWN  2    /* TODO, what is this for exactly? - need to document it! */
+
+
 
 /* ****  FUNCTIONS FOR QSORT *************************** */
 
@@ -199,9 +209,7 @@ ScanFillVert *BLI_addfillvert(ScanFillContext *sf_ctx, const float vec[3])
        eve = mem_element_new(sf_ctx, sizeof(ScanFillVert));
        BLI_addtail(&sf_ctx->fillvertbase, eve);
        
-       eve->co[0] = vec[0];
-       eve->co[1] = vec[1];
-       eve->co[2] = vec[2];
+       copy_v3_v3(eve->co, vec);
 
        return eve;     
 }
@@ -319,10 +327,11 @@ static short addedgetoscanvert(ScanFillVertLink *sc, ScanFillEdge *eed)
        }
        else fac1 = (x - eed->v2->xy[0]) / fac1;
 
-       ed = sc->first;
-       while (ed) {
+       for (ed = sc->first; ed; ed = ed->next) {
 
-               if (ed->v2 == eed->v2) return 0;
+               if (ed->v2 == eed->v2) {
+                       return 0;
+               }
 
                fac = ed->v2->xy[1] - y;
                if (fac == 0.0f) {
@@ -332,9 +341,9 @@ static short addedgetoscanvert(ScanFillVertLink *sc, ScanFillEdge *eed)
                        fac = (x - ed->v2->xy[0]) / fac;
                }
 
-               if (fac > fac1) break;
-
-               ed = ed->next;
+               if (fac > fac1) {
+                       break;
+               }
        }
        if (ed) BLI_insertlinkbefore((ListBase *)&(sc->first), ed, eed);
        else BLI_addtail((ListBase *)&(sc->first), eed);
@@ -396,7 +405,9 @@ static short boundinsideEV(ScanFillEdge *eed, ScanFillVert *eve)
                        miny = eed->v2->xy[1];
                        maxy = eed->v1->xy[1];
                }
-               if (eve->xy[1] >= miny && eve->xy[1] <= maxy) return 1;
+               if (eve->xy[1] >= miny && eve->xy[1] <= maxy) {
+                       return 1;
+               }
        }
        return 0;
 }
@@ -409,13 +420,9 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
 
        ScanFillVert *eve;
        ScanFillEdge *eed, *ed1;
-       float dist, vec1[2], vec2[2], vec3[2];
 
-       eve = sf_ctx->fillvertbase.first;
-       while (eve) {
+       for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
                if (eve->h == 1) {
-                       vec3[0] = eve->xy[0];
-                       vec3[1] = eve->xy[1];
                        /* find the edge which has vertex eve */
                        ed1 = sf_ctx->filledgebase.first;
                        while (ed1) {
@@ -426,29 +433,25 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
                                ed1->v1 = ed1->v2;
                                ed1->v2 = eve;
                        }
-                       eed = sf_ctx->filledgebase.first;
-                       while (eed) {
+
+                       for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
                                if (eve != eed->v1 && eve != eed->v2 && eve->poly_nr == eed->poly_nr) {
-                                       if (compare_v3v3(eve->co, eed->v1->co, COMPLIMIT)) {
+                                       if (compare_v3v3(eve->co, eed->v1->co, SF_EPSILON)) {
                                                ed1->v2 = eed->v1;
                                                eed->v1->h++;
                                                eve->h = 0;
                                                break;
                                        }
-                                       else if (compare_v3v3(eve->co, eed->v2->co, COMPLIMIT)) {
+                                       else if (compare_v3v3(eve->co, eed->v2->co, SF_EPSILON)) {
                                                ed1->v2 = eed->v2;
                                                eed->v2->h++;
                                                eve->h = 0;
                                                break;
                                        }
                                        else {
-                                               vec1[0] = eed->v1->xy[0];
-                                               vec1[1] = eed->v1->xy[1];
-                                               vec2[0] = eed->v2->xy[0];
-                                               vec2[1] = eed->v2->xy[1];
                                                if (boundinsideEV(eed, eve)) {
-                                                       dist = dist_to_line_v2(vec1, vec2, vec3);
-                                                       if (dist < COMPLIMIT) {
+                                                       const float dist = dist_to_line_v2(eed->v1->xy, eed->v2->xy, eve->xy);
+                                                       if (dist < SF_EPSILON) {
                                                                /* new edge */
                                                                ed1 = BLI_addfilledge(sf_ctx, eed->v1, eve);
                                                                
@@ -462,10 +465,8 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
                                                }
                                        }
                                }
-                               eed = eed->next;
                        }
                }
-               eve = eve->next;
        }
 }
 
@@ -504,7 +505,6 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
        ScanFillVertLink *sc = NULL, *sc1;
        ScanFillVert *eve, *v1, *v2, *v3;
        ScanFillEdge *eed, *nexted, *ed1, *ed2, *ed3;
-       float miny = 0.0;
        int a, b, verts, maxface, totface;
        short nr, test, twoconnected = 0;
 
@@ -528,23 +528,21 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
        /* STEP 0: remove zero sized edges */
        eed = sf_ctx->filledgebase.first;
        while (eed) {
-               if (eed->v1->xy[0] == eed->v2->xy[0]) {
-                       if (eed->v1->xy[1] == eed->v2->xy[1]) {
-                               if (eed->v1->f == 255 && eed->v2->f != 255) {
-                                       eed->v2->f = 255;
-                                       eed->v2->tmp.v = eed->v1->tmp.v;
-                               }
-                               else if (eed->v2->f == 255 && eed->v1->f != 255) {
-                                       eed->v1->f = 255;
-                                       eed->v1->tmp.v = eed->v2->tmp.v;
-                               }
-                               else if (eed->v2->f == 255 && eed->v1->f == 255) {
-                                       eed->v1->tmp.v = eed->v2->tmp.v;
-                               }
-                               else {
-                                       eed->v2->f = 255;
-                                       eed->v2->tmp.v = eed->v1;
-                               }
+               if (equals_v2v2(eed->v1->xy, eed->v2->xy)) {
+                       if (eed->v1->f == SF_VERT_ZERO_LEN && eed->v2->f != SF_VERT_ZERO_LEN) {
+                               eed->v2->f = SF_VERT_ZERO_LEN;
+                               eed->v2->tmp.v = eed->v1->tmp.v;
+                       }
+                       else if (eed->v2->f == SF_VERT_ZERO_LEN && eed->v1->f != SF_VERT_ZERO_LEN) {
+                               eed->v1->f = SF_VERT_ZERO_LEN;
+                               eed->v1->tmp.v = eed->v2->tmp.v;
+                       }
+                       else if (eed->v2->f == SF_VERT_ZERO_LEN && eed->v1->f == SF_VERT_ZERO_LEN) {
+                               eed->v1->tmp.v = eed->v2->tmp.v;
+                       }
+                       else {
+                               eed->v2->f = SF_VERT_ZERO_LEN;
+                               eed->v2->tmp.v = eed->v1;
                        }
                }
                eed = eed->next;
@@ -558,7 +556,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
        verts = 0;
        while (eve) {
                if (eve->poly_nr == nr) {
-                       if (eve->f != 255) {
+                       if (eve->f != SF_VERT_ZERO_LEN) {
                                verts++;
                                eve->f = 0;  /* flag for connectedges later on */
                                sc->v1 = eve;
@@ -579,14 +577,14 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
                 * fix trunk bug #4544, so if that comes back, this code
                 * may need some work, or there will have to be a better
                 * fix to #4544. */
-               if (eed->v1->f == 255) {
+               if (eed->v1->f == SF_VERT_ZERO_LEN) {
                        v1 = eed->v1;
-                       while ((eed->v1->f == 255) && (eed->v1->tmp.v != v1) && (eed->v1 != eed->v1->tmp.v))
+                       while ((eed->v1->f == SF_VERT_ZERO_LEN) && (eed->v1->tmp.v != v1) && (eed->v1 != eed->v1->tmp.v))
                                eed->v1 = eed->v1->tmp.v;
                }
-               if (eed->v2->f == 255) {
+               if (eed->v2->f == SF_VERT_ZERO_LEN) {
                        v2 = eed->v2;
-                       while ((eed->v2->f == 255) && (eed->v2->tmp.v != v2) && (eed->v2 != eed->v2->tmp.v))
+                       while ((eed->v2->f == SF_VERT_ZERO_LEN) && (eed->v2->tmp.v != v2) && (eed->v2 != eed->v2->tmp.v))
                                eed->v2 = eed->v2->tmp.v;
                }
                if (eed->v1 != eed->v2) addedgetoscanlist(sf_ctx, eed, verts);
@@ -627,7 +625,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
                                if (ed1->v1->h > 1) ed1->v1->h--;
                                if (ed1->v2->h > 1) ed1->v2->h--;
                        }
-                       else ed1->v2->f = 1;
+                       else ed1->v2->f = SF_VERT_UNKNOWN;
 
                        ed1 = nexted;
                }
@@ -652,13 +650,14 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
                        }
                        else {
                                /* test rest of vertices */
+                               float miny;
                                v1 = ed1->v2;
                                v2 = ed1->v1;
                                v3 = ed2->v2;
                                /* this happens with a serial of overlapping edges */
                                if (v1 == v2 || v2 == v3) break;
                                /* printf("test verts %x %x %x\n",v1,v2,v3); */
-                               miny = ( (v1->xy[1]) < (v3->xy[1]) ? (v1->xy[1]) : (v3->xy[1]) );
+                               miny = minf(v1->xy[1], v3->xy[1]);
                                /*  miny= MIN2(v1->xy[1],v3->xy[1]); */
                                sc1 = sc + 1;
                                test = 0;
@@ -685,8 +684,8 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
                                        ed3 = BLI_addfilledge(sf_ctx, v2, sc1->v1);
                                        BLI_remlink(&sf_ctx->filledgebase, ed3);
                                        BLI_insertlinkbefore((ListBase *)&(sc->first), ed2, ed3);
-                                       ed3->v2->f = 1;
-                                       ed3->f = 2;
+                                       ed3->v2->f = SF_VERT_UNKNOWN;
+                                       ed3->f = SF_EDGE_UNKNOWN;
                                        ed3->v1->h++; 
                                        ed3->v2->h++;
                                }
@@ -701,7 +700,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
                                        ed1->v1->h--; 
                                        ed1->v2->h--;
                                        /* ed2 can be removed when it's a boundary edge */
-                                       if ((ed2->f == 0 && twoconnected) || (ed2->f == FILLBOUNDARY)) {
+                                       if ((ed2->f == 0 && twoconnected) || (ed2->f == SF_EDGE_BOUNDARY)) {
                                                BLI_remlink((ListBase *)&(sc->first), ed2);
                                                BLI_addtail(&sf_ctx->filledgebase, ed2);
                                                ed2->v2->f = 0;
@@ -712,7 +711,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
                                        /* new edge */
                                        ed3 = BLI_addfilledge(sf_ctx, v1, v3);
                                        BLI_remlink(&sf_ctx->filledgebase, ed3);
-                                       ed3->f = 2;
+                                       ed3->f = SF_EDGE_UNKNOWN;
                                        ed3->v1->h++; 
                                        ed3->v2->h++;
                                        
@@ -727,7 +726,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf)
                                                ed3 = sc1->first;
                                                while (ed3) {
                                                        if ( (ed3->v1 == v1 && ed3->v2 == v3) || (ed3->v1 == v3 && ed3->v2 == v1) ) {
-                                                               if (twoconnected || ed3->f == FILLBOUNDARY) {
+                                                               if (twoconnected || ed3->f == SF_EDGE_BOUNDARY) {
                                                                        BLI_remlink((ListBase *)&(sc1->first), ed3);
                                                                        BLI_addtail(&sf_ctx->filledgebase, ed3);
                                                                        ed3->v1->h--; 
@@ -838,15 +837,15 @@ int BLI_edgefill_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, co
        eed = sf_ctx->filledgebase.first;
        while (eed) {
                eed->poly_nr = 0;
-               eed->v1->f = 1;
-               eed->v2->f = 1;
+               eed->v1->f = SF_VERT_UNKNOWN;
+               eed->v2->f = SF_VERT_UNKNOWN;
 
                eed = eed->next;
        }
 
        eve = sf_ctx->fillvertbase.first;
        while (eve) {
-               if (eve->f & 1) {
+               if (eve->f & SF_VERT_UNKNOWN) {
                        ok = 1;
                        break;
                }
@@ -874,7 +873,7 @@ int BLI_edgefill_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, co
                        v_prev = eve->co;
 
                        for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
-                               if (LIKELY(!compare_v3v3(v_prev, eve->co, COMPLIMIT))) {
+                               if (LIKELY(!compare_v3v3(v_prev, eve->co, SF_EPSILON))) {
                                        add_newell_cross_v3_v3v3(n, v_prev, eve->co);
                                        v_prev = eve->co;
                                }
index ec2b9ac006fb4491e8fb746adeec51edd64386c1..dee18e629306682915a2199bac70ceaa5bd5eb58 100644 (file)
@@ -495,7 +495,7 @@ void BMO_remove_tagged_faces(BMesh *bm, const short oflag)
        BMFace *f;
        BMIter iter;
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                if (BMO_elem_flag_test(bm, f, oflag)) {
                        BM_face_kill(bm, f);
                }
@@ -507,7 +507,7 @@ void BMO_remove_tagged_edges(BMesh *bm, const short oflag)
        BMEdge *e;
        BMIter iter;
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(bm, e, oflag)) {
                        BM_edge_kill(bm, e);
                }
@@ -519,7 +519,7 @@ void BMO_remove_tagged_verts(BMesh *bm, const short oflag)
        BMVert *v;
        BMIter iter;
 
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(bm, v, oflag)) {
                        BM_vert_kill(bm, v);
                }
@@ -545,14 +545,14 @@ static void bmo_remove_tagged_context_verts(BMesh *bm, const short oflag)
        BMIter iter;
        BMIter itersub;
 
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(bm, v, oflag)) {
                        /* Visit edge */
-                       BM_ITER(e, &itersub, bm, BM_EDGES_OF_VERT, v) {
+                       BM_ITER_ELEM (e, &itersub, v, BM_EDGES_OF_VERT) {
                                BMO_elem_flag_enable(bm, e, oflag);
                        }
                        /* Visit face */
-                       BM_ITER(f, &itersub, bm, BM_FACES_OF_VERT, v) {
+                       BM_ITER_ELEM (f, &itersub, v, BM_FACES_OF_VERT) {
                                BMO_elem_flag_enable(bm, f, oflag);
                        }
                }
@@ -571,9 +571,9 @@ static void bmo_remove_tagged_context_edges(BMesh *bm, const short oflag)
        BMIter iter;
        BMIter itersub;
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(bm, e, oflag)) {
-                       BM_ITER(f, &itersub, bm, BM_FACES_OF_EDGE, e) {
+                       BM_ITER_ELEM (f, &itersub, e, BM_FACES_OF_EDGE) {
                                BMO_elem_flag_enable(bm, f, oflag);
                        }
                }
@@ -610,7 +610,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                case DEL_EDGES:
                {
                        /* flush down to vert */
-                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+                       BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
                                if (BMO_elem_flag_test(bm, e, oflag)) {
                                        BMO_elem_flag_enable(bm, e->v1, oflag);
                                        BMO_elem_flag_enable(bm, e->v2, oflag);
@@ -618,7 +618,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                        }
                        bmo_remove_tagged_context_edges(bm, oflag);
                        /* remove loose vertice */
-                       BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                                if (BMO_elem_flag_test(bm, v, oflag) && (!(v->e)))
                                        BMO_elem_flag_enable(bm, v, DEL_WIREVERT);
                        }
@@ -649,7 +649,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                case DEL_FACES:
                {
                        /* go through and mark all edges and all verts of all faces for delet */
-                       BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                                if (BMO_elem_flag_test(bm, f, oflag)) {
                                        for (e = BM_iter_new(&eiter, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&eiter))
                                                BMO_elem_flag_enable(bm, e, oflag);
@@ -658,7 +658,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                                }
                        }
                        /* now go through and mark all remaining faces all edges for keeping */
-                       BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                                if (!BMO_elem_flag_test(bm, f, oflag)) {
                                        for (e = BM_iter_new(&eiter, bm, BM_EDGES_OF_FACE, f); e; e = BM_iter_step(&eiter)) {
                                                BMO_elem_flag_disable(bm, e, oflag);
@@ -669,7 +669,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                                }
                        }
                        /* also mark all the vertices of remaining edges for keeping */
-                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+                       BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
                                if (!BMO_elem_flag_test(bm, e, oflag)) {
                                        BMO_elem_flag_disable(bm, e->v1, oflag);
                                        BMO_elem_flag_disable(bm, e->v2, oflag);
@@ -687,13 +687,13 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type)
                case DEL_ALL:
                {
                        /* does this option even belong in here? */
-                       BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                                BMO_elem_flag_enable(bm, f, oflag);
                        }
-                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+                       BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
                                BMO_elem_flag_enable(bm, e, oflag);
                        }
-                       BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                                BMO_elem_flag_enable(bm, v, oflag);
                        }
 
index 8b1fee3b33f05461d0ed96d98e8b0ee42e73643e..76095728d5a770cfff56d7469c1e904940f15617 100644 (file)
@@ -80,7 +80,7 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
                BM_elem_attrs_copy(bm, bm, example, v);
        }
 
-       BM_CHECK_ELEMENT(bm, v);
+       BM_CHECK_ELEMENT(v);
 
        return v;
 }
@@ -122,7 +122,7 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example,
        if (example)
                BM_elem_attrs_copy(bm, bm, example, e);
        
-       BM_CHECK_ELEMENT(bm, e);
+       BM_CHECK_ELEMENT(e);
 
        return e;
 }
@@ -314,12 +314,12 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
        
        f->len = len;
        
-       BM_CHECK_ELEMENT(bm, f);
+       BM_CHECK_ELEMENT(f);
 
        return f;
 }
 
-int bmesh_elem_check(BMesh *UNUSED(bm), void *element, const char htype)
+int bmesh_elem_check(void *element, const char htype)
 {
        BMHeader *head = element;
        int err = 0;
@@ -555,7 +555,7 @@ void BM_face_kill(BMesh *bm, BMFace *f)
        BMLoopList *ls, *ls_next;
 #endif
 
-       BM_CHECK_ELEMENT(bm, f);
+       BM_CHECK_ELEMENT(f);
 
 #ifdef USE_BMESH_HOLES
        for (ls = f->loops.first; ls; ls = ls_next)
@@ -733,15 +733,15 @@ static int bm_loop_reverse_loop(BMesh *bm, BMFace *f
 
        /* validate radia */
        for (i = 0, l_iter = l_first; i < len; i++, l_iter = l_iter->next) {
-               BM_CHECK_ELEMENT(bm, l_iter);
-               BM_CHECK_ELEMENT(bm, l_iter->e);
-               BM_CHECK_ELEMENT(bm, l_iter->v);
-               BM_CHECK_ELEMENT(bm, l_iter->f);
+               BM_CHECK_ELEMENT(l_iter);
+               BM_CHECK_ELEMENT(l_iter->e);
+               BM_CHECK_ELEMENT(l_iter->v);
+               BM_CHECK_ELEMENT(l_iter->f);
        }
 
        BLI_array_free(edar);
 
-       BM_CHECK_ELEMENT(bm, f);
+       BM_CHECK_ELEMENT(f);
 
        return 1;
 }
@@ -755,7 +755,7 @@ int bmesh_loop_reverse(BMesh *bm, BMFace *f)
 #endif
 }
 
-static void bm_elements_systag_enable(BMesh *UNUSED(bm), void *veles, int tot, int flag)
+static void bm_elements_systag_enable(void *veles, int tot, int flag)
 {
        BMHeader **eles = veles;
        int i;
@@ -765,7 +765,7 @@ static void bm_elements_systag_enable(BMesh *UNUSED(bm), void *veles, int tot, i
        }
 }
 
-static void bm_elements_systag_disable(BMesh *UNUSED(bm), void *veles, int tot, int flag)
+static void bm_elements_systag_disable(void *veles, int tot, int flag)
 {
        BMHeader **eles = veles;
        int i;
@@ -893,7 +893,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
        if (totface == 1)
                return faces[0];
 
-       bm_elements_systag_enable(bm, faces, totface, _FLAG_JF);
+       bm_elements_systag_enable(faces, totface, _FLAG_JF);
 
        for (i = 0; i < totface; i++) {
                f = faces[i];
@@ -1012,7 +1012,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
                } while ((l_iter = l_iter->next) != l_first);
        }
 
-       bm_elements_systag_disable(bm, faces, totface, _FLAG_JF);
+       bm_elements_systag_disable(faces, totface, _FLAG_JF);
        BM_ELEM_API_FLAG_DISABLE(newf, _FLAG_JF);
 
        /* handle multi-res data */
@@ -1046,11 +1046,11 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
        BLI_array_free(deledges);
        BLI_array_free(delverts);
 
-       BM_CHECK_ELEMENT(bm, newf);
+       BM_CHECK_ELEMENT(newf);
        return newf;
 
 error:
-       bm_elements_systag_disable(bm, faces, totface, _FLAG_JF);
+       bm_elements_systag_disable(faces, totface, _FLAG_JF);
        BLI_array_free(edges);
        BLI_array_free(deledges);
        BLI_array_free(delverts);
@@ -1092,13 +1092,13 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *UNUSED(example))
  * \par Examples:
  *
  *     Before:               After:
- *      ----------           ----------
+ *      +--------+           +--------+
  *      |        |           |        |
  *      |        |           |   f1   |
  *     v1   f1   v2          v1======v2
  *      |        |           |   f2   |
  *      |        |           |        |
- *      ----------           ----------
+ *      +--------+           +--------+
  *
  * \note the input vertices can be part of the same edge. This will
  * result in a two edged face. This is desirable for advanced construction
@@ -1243,9 +1243,9 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2,
        }
 #endif
 
-       BM_CHECK_ELEMENT(bm, e);
-       BM_CHECK_ELEMENT(bm, f);
-       BM_CHECK_ELEMENT(bm, f2);
+       BM_CHECK_ELEMENT(e);
+       BM_CHECK_ELEMENT(f);
+       BM_CHECK_ELEMENT(f2);
        
        return f2;
 }
@@ -1391,10 +1391,10 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
                        BMESH_ASSERT(l->e != l->next->e);
 
                        /* verify loop cycle for kloop-> */
-                       BM_CHECK_ELEMENT(bm, l);
-                       BM_CHECK_ELEMENT(bm, l->v);
-                       BM_CHECK_ELEMENT(bm, l->e);
-                       BM_CHECK_ELEMENT(bm, l->f);
+                       BM_CHECK_ELEMENT(l);
+                       BM_CHECK_ELEMENT(l->v);
+                       BM_CHECK_ELEMENT(l->e);
+                       BM_CHECK_ELEMENT(l->f);
                }
                /* verify loop->v and loop->next->v pointers for ne */
                for (i = 0, l = ne->l; i < radlen; i++, l = l->radial_next) {
@@ -1406,18 +1406,18 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e)
                        BMESH_ASSERT(l->v != l->next->v);
                        BMESH_ASSERT(l->e != l->next->e);
 
-                       BM_CHECK_ELEMENT(bm, l);
-                       BM_CHECK_ELEMENT(bm, l->v);
-                       BM_CHECK_ELEMENT(bm, l->e);
-                       BM_CHECK_ELEMENT(bm, l->f);
+                       BM_CHECK_ELEMENT(l);
+                       BM_CHECK_ELEMENT(l->v);
+                       BM_CHECK_ELEMENT(l->e);
+                       BM_CHECK_ELEMENT(l->f);
                }
        }
 
-       BM_CHECK_ELEMENT(bm, ne);
-       BM_CHECK_ELEMENT(bm, nv);
-       BM_CHECK_ELEMENT(bm, ov);
-       BM_CHECK_ELEMENT(bm, e);
-       BM_CHECK_ELEMENT(bm, tv);
+       BM_CHECK_ELEMENT(ne);
+       BM_CHECK_ELEMENT(nv);
+       BM_CHECK_ELEMENT(ov);
+       BM_CHECK_ELEMENT(e);
+       BM_CHECK_ELEMENT(tv);
 
        if (r_e) *r_e = ne;
        return nv;
@@ -1561,10 +1561,10 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_dou
                                edok = bmesh_loop_validate(l->f);
                                BMESH_ASSERT(edok != FALSE);
 
-                               BM_CHECK_ELEMENT(bm, l);
-                               BM_CHECK_ELEMENT(bm, l->v);
-                               BM_CHECK_ELEMENT(bm, l->e);
-                               BM_CHECK_ELEMENT(bm, l->f);
+                               BM_CHECK_ELEMENT(l);
+                               BM_CHECK_ELEMENT(l->v);
+                               BM_CHECK_ELEMENT(l->e);
+                               BM_CHECK_ELEMENT(l->f);
                        }
 
                        if (check_edge_double) {
@@ -1574,9 +1574,9 @@ BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_dou
                                }
                        }
 
-                       BM_CHECK_ELEMENT(bm, ov);
-                       BM_CHECK_ELEMENT(bm, tv);
-                       BM_CHECK_ELEMENT(bm, oe);
+                       BM_CHECK_ELEMENT(ov);
+                       BM_CHECK_ELEMENT(tv);
+                       BM_CHECK_ELEMENT(oe);
 
                        return oe;
                }
@@ -1718,7 +1718,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
        /* account for both above */
        bm->elem_index_dirty |= BM_EDGE | BM_FACE;
 
-       BM_CHECK_ELEMENT(bm, f1);
+       BM_CHECK_ELEMENT(f1);
 
        /* validate the new loop cycle */
        edok = bmesh_loop_validate(f1);
@@ -1746,7 +1746,7 @@ int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget)
        }
 
        /* retarget all the loops of v to vtarget */
-       BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) {
+       BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
                l->v = vtarget;
        }
 
@@ -1757,8 +1757,8 @@ int BM_vert_splice(BMesh *bm, BMVert *v, BMVert *vtarget)
                bmesh_disk_edge_append(e, vtarget);
        }
 
-       BM_CHECK_ELEMENT(bm, v);
-       BM_CHECK_ELEMENT(bm, vtarget);
+       BM_CHECK_ELEMENT(v);
+       BM_CHECK_ELEMENT(vtarget);
 
        /* v is unused now, and can be killed */
        BM_vert_kill(bm, v);
@@ -1792,7 +1792,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
        visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
 
        maxindex = 0;
-       BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+       BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                if (BLI_ghash_haskey(visithash, e)) {
                        continue;
                }
@@ -1805,7 +1805,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
                while ((e = BLI_array_pop(stack))) {
                        BLI_ghash_insert(visithash, e, SET_INT_IN_POINTER(maxindex));
 
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_EDGE, e) {
+                       BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
                                nl = (l->v == v) ? l->prev : l->next;
                                if (!BLI_ghash_haskey(visithash, nl->e)) {
                                        BLI_array_append(stack, nl->e);
@@ -1825,7 +1825,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
 
        /* Replace v with the new verts in each group */
 #if 0
-       BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) {
+       BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
                /* call first since its faster then a hash lookup */
                if (l->v != v) {
                        continue;
@@ -1851,7 +1851,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
         * bad practice but save alloc'ing a new array - note, the comment above is useful, keep it
         * if you are tidying up code - campbell */
        BLI_array_empty(stack);
-       BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) {
+       BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
                if (l->v == v) {
                        BLI_array_append(stack, (BMEdge *)l);
                }
@@ -1865,7 +1865,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
 
        BLI_array_free(stack);
 
-       BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+       BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                i = GET_INT_FROM_POINTER(BLI_ghash_lookup(visithash, e));
                if (i == 0) {
                        continue;
@@ -1880,7 +1880,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
        BLI_ghash_free(visithash, NULL, NULL);
 
        for (i = 0; i < maxindex; i++) {
-               BM_CHECK_ELEMENT(bm, verts[i]);
+               BM_CHECK_ELEMENT(verts[i]);
        }
 
        if (r_vout_len != NULL) {
@@ -1943,8 +1943,8 @@ int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget)
 
        BLI_assert(bmesh_radial_length(e->l) == 0);
 
-       BM_CHECK_ELEMENT(bm, e);
-       BM_CHECK_ELEMENT(bm, etarget);
+       BM_CHECK_ELEMENT(e);
+       BM_CHECK_ELEMENT(etarget);
 
        /* removes from disks too */
        BM_edge_kill(bm, e);
@@ -1989,8 +1989,8 @@ int bmesh_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep)
        BLI_assert(bmesh_radial_length(e->l) == radlen - 1);
        BLI_assert(bmesh_radial_length(ne->l) == 1);
 
-       BM_CHECK_ELEMENT(bm, ne);
-       BM_CHECK_ELEMENT(bm, e);
+       BM_CHECK_ELEMENT(ne);
+       BM_CHECK_ELEMENT(e);
 
        return TRUE;
 }
index 2a3242d87c106ec9636c85159d68f7cc121525af..5149a5436a2ae3d835535848c3462d7fb748c04e 100644 (file)
@@ -327,16 +327,16 @@ static void mdisp_axis_from_quad(float v1[3], float v2[3], float UNUSED(v3[3]),
 
 /* tl is loop to project onto, l is loop whose internal displacement, co, is being
  * projected.  x and y are location in loop's mdisps grid of point co. */
-static int mdisp_in_mdispquad(BMesh *bm, BMLoop *l, BMLoop *tl, float p[3], float *x, float *y,
+static int mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float p[3], float *x, float *y,
                               int res, float axis_x[3], float axis_y[3])
 {
        float v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3];
        float eps = FLT_EPSILON * 4000;
        
        if (len_v3(l->v->no) == 0.0f)
-               BM_vert_normal_update_all(bm, l->v);
+               BM_vert_normal_update_all(l->v);
        if (len_v3(tl->v->no) == 0.0f)
-               BM_vert_normal_update_all(bm, tl->v);
+               BM_vert_normal_update_all(tl->v);
 
        compute_mdisp_quad(tl, v1, v2, v3, v4, e1, e2);
 
@@ -466,7 +466,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
                                md1 = CustomData_bmesh_get(&bm->ldata, target->head.data, CD_MDISPS);
                                md2 = CustomData_bmesh_get(&bm->ldata, l_iter->head.data, CD_MDISPS);
                                
-                               if (mdisp_in_mdispquad(bm, target, l_iter, co, &x2, &y2, res, src_axis_x, src_axis_y)) {
+                               if (mdisp_in_mdispquad(target, l_iter, co, &x2, &y2, res, src_axis_x, src_axis_y)) {
                                        old_mdisps_bilinear(md1->disps[iy * res + ix], md2->disps, res, (float)x2, (float)y2);
                                        bm_loop_flip_disp(src_axis_x, src_axis_y, axis_x, axis_y, md1->disps[iy * res + ix]);
 
@@ -489,7 +489,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
        if (!CustomData_has_layer(&bm->ldata, CD_MDISPS))
                return;
        
-       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                MDisps *mdp = CustomData_bmesh_get(&bm->ldata, l->prev->head.data, CD_MDISPS);
                MDisps *mdl = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
                MDisps *mdn = CustomData_bmesh_get(&bm->ldata, l->next->head.data, CD_MDISPS);
@@ -521,7 +521,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
                }
        }
        
-       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                MDisps *mdl1 = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
                MDisps *mdl2;
                float co1[3], co2[3], co[3];
@@ -726,7 +726,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data)
 
                CustomData_bmesh_init_pool(data, bm->totvert, BM_VERT);
 
-               BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
                        block = NULL;
                        CustomData_bmesh_set_default(data, &block);
                        CustomData_bmesh_copy_data(olddata, data, eve->head.data, &block);
@@ -739,7 +739,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data)
 
                CustomData_bmesh_init_pool(data, bm->totedge, BM_EDGE);
 
-               BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+               BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
                        block = NULL;
                        CustomData_bmesh_set_default(data, &block);
                        CustomData_bmesh_copy_data(olddata, data, eed->head.data, &block);
@@ -753,8 +753,8 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data)
                BMLoop *l;
 
                CustomData_bmesh_init_pool(data, bm->totloop, BM_LOOP);
-               BM_ITER(efa, &iter, bm, BM_FACES_OF_MESH, NULL) {
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, efa) {
+               BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
+                       BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
                                block = NULL;
                                CustomData_bmesh_set_default(data, &block);
                                CustomData_bmesh_copy_data(olddata, data, l->head.data, &block);
@@ -768,7 +768,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data)
 
                CustomData_bmesh_init_pool(data, bm->totface, BM_FACE);
 
-               BM_ITER(efa, &iter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
                        block = NULL;
                        CustomData_bmesh_set_default(data, &block);
                        CustomData_bmesh_copy_data(olddata, data, efa->head.data, &block);
index b53896ae72269145f75172c808becb5905a8ff75..384715d74f7489c2a4473ebc8a52b747df674d6d 100644 (file)
@@ -83,18 +83,17 @@ void *BM_iter_at_index(BMesh *bm, const char itype, void *data, int index)
  * Sometimes its convenient to get the iterator as an array
  * to avoid multiple calls to #BM_iter_at_index.
  */
-int BM_iter_as_array(BMesh *bm, const char type, void *data, void **array, const int len)
+int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, const int len)
 {
        int i = 0;
 
        /* sanity check */
        if (len > 0) {
-
                BMIter iter;
-               void *val;
+               void *ele;
 
-               BM_ITER(val, &iter, bm, type, data) {
-                       array[i] = val;
+               for (ele = BM_iter_new(&iter, bm, itype, data); ele; ele = BM_iter_step(&iter)) {
+                       array[i] = ele;
                        i++;
                        if (i == len) {
                                return len;
index d3566d8aead81519b3a4939646c3f87d2e9ede09..c687e4b4e7a0b84fe834bf9a6eeae468b45857b9 100644 (file)
@@ -82,14 +82,17 @@ typedef enum BMIterType {
 /* the iterator htype for each iterator */
 extern const char bm_iter_itype_htype_map[BM_ITYPE_MAX];
 
+#define BM_ITER_MESH(ele, iter, bm, itype) \
+       for (ele = BM_iter_new(iter, bm, itype, NULL); ele; ele = BM_iter_step(iter))
 
-#define BM_ITER(ele, iter, bm, itype, data)                                   \
-       ele = BM_iter_new(iter, bm, itype, data);                                 \
-       for ( ; ele; ele = BM_iter_step(iter))
+#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar) \
+       for (ele = BM_iter_new(iter, bm, itype, NULL), indexvar = 0; ele; ele = BM_iter_step(iter), (indexvar)++)
 
-#define BM_ITER_INDEX(ele, iter, bm, itype, data, indexvar)                   \
-       ele = BM_iter_new(iter, bm, itype, data);                                 \
-       for (indexvar = 0; ele; indexvar++, ele = BM_iter_step(iter))
+#define BM_ITER_ELEM(ele, iter, data, itype) \
+       for (ele = BM_iter_new(iter, NULL, itype, data); ele; ele = BM_iter_step(iter))
+
+#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar) \
+       for (ele = BM_iter_new(iter, NULL, itype, data), indexvar = 0; ele; ele = BM_iter_step(iter), (indexvar)++)
 
 /* Iterator Structure */
 typedef struct BMIter {
index 3492b4257cbb2e11bad0da198e28cbca57443e18..7cf29031765e54c8d7a8e3de699a02a05a3496a0 100644 (file)
@@ -84,7 +84,7 @@ void BM_mesh_select_mode_flush(BMesh *bm)
        int ok;
 
        if (bm->selectmode & SCE_SELECT_VERTEX) {
-               BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+               BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
                        if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
                            BM_elem_flag_test(e->v2, BM_ELEM_SELECT) &&
                            !BM_elem_flag_test(e, BM_ELEM_HIDDEN))
@@ -95,7 +95,7 @@ void BM_mesh_select_mode_flush(BMesh *bm)
                                BM_elem_flag_disable(e, BM_ELEM_SELECT);
                        }
                }
-               BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                        ok = TRUE;
                        if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
                                l_iter = l_first = BM_FACE_FIRST_LOOP(f);
@@ -114,7 +114,7 @@ void BM_mesh_select_mode_flush(BMesh *bm)
                }
        }
        else if (bm->selectmode & SCE_SELECT_EDGE) {
-               BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                        ok = TRUE;
                        if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
                                l_iter = l_first = BM_FACE_FIRST_LOOP(f);
@@ -154,7 +154,7 @@ void BM_mesh_deselect_flush(BMesh *bm)
 
        int ok;
 
-       BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
                if (!(BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
                      BM_elem_flag_test(e->v2, BM_ELEM_SELECT) &&
                      !BM_elem_flag_test(e, BM_ELEM_HIDDEN)))
@@ -163,7 +163,7 @@ void BM_mesh_deselect_flush(BMesh *bm)
                }
        }
 
-       BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                ok = TRUE;
                if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
                        l_iter = l_first = BM_FACE_FIRST_LOOP(f);
@@ -205,7 +205,7 @@ void BM_mesh_select_flush(BMesh *bm)
 
        int ok;
 
-       BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
                if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
                    BM_elem_flag_test(e->v2, BM_ELEM_SELECT) &&
                    !BM_elem_flag_test(e, BM_ELEM_HIDDEN))
@@ -214,7 +214,7 @@ void BM_mesh_select_flush(BMesh *bm)
                }
        }
 
-       BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                ok = TRUE;
                if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
                        l_iter = l_first = BM_FACE_FIRST_LOOP(f);
@@ -360,10 +360,10 @@ void BM_face_select_set(BMesh *bm, BMFace *f, int select)
                BM_elem_flag_disable(f, BM_ELEM_SELECT);
 
                /* flush down to edges */
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        BMIter fiter;
                        BMFace *f2;
-                       BM_ITER(f2, &fiter, bm, BM_FACES_OF_EDGE, l->e) {
+                       BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) {
                                if (BM_elem_flag_test(f2, BM_ELEM_SELECT))
                                        break;
                        }
@@ -374,10 +374,10 @@ void BM_face_select_set(BMesh *bm, BMFace *f, int select)
                }
 
                /* flush down to verts */
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        BMIter eiter;
                        BMEdge *e;
-                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, l->v) {
+                       BM_ITER_ELEM (e, &eiter, l->v, BM_EDGES_OF_VERT) {
                                if (BM_elem_flag_test(e, BM_ELEM_SELECT))
                                        break;
                        }
@@ -405,10 +405,10 @@ void BM_mesh_select_mode_set(BMesh *bm, int selectmode)
        if (bm->selectmode & SCE_SELECT_VERTEX) {
                /* disabled because selection flushing handles these */
 #if 0
-               BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+               BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
                        BM_elem_flag_disable(ele, BM_ELEM_SELECT);
                }
-               BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
                        BM_elem_flag_disable(ele, BM_ELEM_SELECT);
                }
 #endif
@@ -417,12 +417,12 @@ void BM_mesh_select_mode_set(BMesh *bm, int selectmode)
        else if (bm->selectmode & SCE_SELECT_EDGE) {
                /* disabled because selection flushing handles these */
 #if 0
-               BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
                        BM_elem_flag_disable(ele, BM_ELEM_SELECT);
                }
 #endif
 
-               BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+               BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
                        if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
                                BM_edge_select_set(bm, (BMEdge *)ele, TRUE);
                        }
@@ -432,11 +432,11 @@ void BM_mesh_select_mode_set(BMesh *bm, int selectmode)
        else if (bm->selectmode & SCE_SELECT_FACE) {
                /* disabled because selection flushing handles these */
 #if 0
-               BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+               BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
                        BM_elem_flag_disable(ele, BM_ELEM_SELECT);
                }
 #endif
-               BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
                        if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
                                BM_face_select_set(bm, (BMFace *)ele, TRUE);
                        }
@@ -543,7 +543,7 @@ BMFace *BM_active_face_get(BMesh *bm, int sloppy)
                }
                /* Last attempt: try to find any selected face */
                if (f == NULL) {
-                       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                                if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
                                        break;
                                }
@@ -563,7 +563,7 @@ BMFace *BM_active_face_get(BMesh *bm, int sloppy)
  * - #EM_editselection_normal
  * - #EM_editselection_plane
  */
-void BM_editselection_center(BMesh *bm, float r_center[3], BMEditSelection *ese)
+void BM_editselection_center(float r_center[3], BMEditSelection *ese)
 {
        if (ese->htype == BM_VERT) {
                BMVert *eve = (BMVert *)ese->ele;
@@ -576,7 +576,7 @@ void BM_editselection_center(BMesh *bm, float r_center[3], BMEditSelection *ese)
        }
        else if (ese->htype == BM_FACE) {
                BMFace *efa = (BMFace *)ese->ele;
-               BM_face_center_bounds_calc(bm, efa, r_center);
+               BM_face_center_bounds_calc(efa, r_center);
        }
 }
 
@@ -621,7 +621,7 @@ void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese)
                float vec[3] = {0.0f, 0.0f, 0.0f};
                
                if (ese->prev) { /* use previously selected data to make a useful vertex plane */
-                       BM_editselection_center(bm, vec, ese->prev);
+                       BM_editselection_center(vec, ese->prev);
                        sub_v3_v3v3(r_plane, vec, eve->co);
                }
                else {
@@ -890,33 +890,33 @@ void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag
 
 /***************** Mesh Hiding stuff *********** */
 
-static void vert_flush_hide_set(BMesh *bm, BMVert *v)
+static void vert_flush_hide_set(BMVert *v)
 {
        BMIter iter;
        BMEdge *e;
        int hide = TRUE;
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) {
+       BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
                hide = hide && BM_elem_flag_test(e, BM_ELEM_HIDDEN);
        }
 
        BM_elem_flag_set(v, BM_ELEM_HIDDEN, hide);
 }
 
-static void edge_flush_hide(BMesh *bm, BMEdge *e)
+static void edge_flush_hide(BMEdge *e)
 {
        BMIter iter;
        BMFace *f;
        int hide = TRUE;
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_EDGE, e) {
+       BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
                hide = hide && BM_elem_flag_test(f, BM_ELEM_HIDDEN);
        }
 
        BM_elem_flag_set(e, BM_ELEM_HIDDEN, hide);
 }
 
-void BM_vert_hide_set(BMesh *bm, BMVert *v, int hide)
+void BM_vert_hide_set(BMVert *v, int hide)
 {
        /* vert hiding: vert + surrounding edges and faces */
        BMIter iter, fiter;
@@ -925,46 +925,46 @@ void BM_vert_hide_set(BMesh *bm, BMVert *v, int hide)
 
        BM_elem_flag_set(v, BM_ELEM_HIDDEN, hide);
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) {
+       BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
                BM_elem_flag_set(e, BM_ELEM_HIDDEN, hide);
 
-               BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) {
+               BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) {
                        BM_elem_flag_set(f, BM_ELEM_HIDDEN, hide);
                }
        }
 }
 
-void BM_edge_hide_set(BMesh *bm, BMEdge *e, int hide)
+void BM_edge_hide_set(BMEdge *e, int hide)
 {
        BMIter iter;
        BMFace *f;
        /* BMVert *v; */
 
        /* edge hiding: faces around the edge */
-       BM_ITER(f, &iter, bm, BM_FACES_OF_EDGE, e) {
+       BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
                BM_elem_flag_set(f, BM_ELEM_HIDDEN, hide);
        }
        
        BM_elem_flag_set(e, BM_ELEM_HIDDEN, hide);
 
        /* hide vertices if necessary */
-       vert_flush_hide_set(bm, e->v1);
-       vert_flush_hide_set(bm, e->v2);
+       vert_flush_hide_set(e->v1);
+       vert_flush_hide_set(e->v2);
 }
 
-void BM_face_hide_set(BMesh *bm, BMFace *f, int hide)
+void BM_face_hide_set(BMFace *f, int hide)
 {
        BMIter iter;
        BMLoop *l;
 
        BM_elem_flag_set(f, BM_ELEM_HIDDEN, hide);
 
-       BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) {
-               edge_flush_hide(bm, l->e);
+       BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+               edge_flush_hide(l->e);
        }
 
-       BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) {
-               vert_flush_hide_set(bm, l->v);
+       BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) {
+               vert_flush_hide_set(l->v);
        }
 }
 
@@ -975,15 +975,15 @@ void _bm_elem_hide_set(BMesh *bm, BMHeader *head, int hide)
        switch (head->htype) {
                case BM_VERT:
                        if (hide) BM_vert_select_set(bm, (BMVert *)head, FALSE);
-                       BM_vert_hide_set(bm, (BMVert *)head, hide);
+                       BM_vert_hide_set((BMVert *)head, hide);
                        break;
                case BM_EDGE:
                        if (hide) BM_edge_select_set(bm, (BMEdge *)head, FALSE);
-                       BM_edge_hide_set(bm, (BMEdge *)head, hide);
+                       BM_edge_hide_set((BMEdge *)head, hide);
                        break;
                case BM_FACE:
                        if (hide) BM_face_select_set(bm, (BMFace *)head, FALSE);
-                       BM_face_hide_set(bm, (BMFace *)head, hide);
+                       BM_face_hide_set((BMFace *)head, hide);
                        break;
                default:
                        BMESH_ASSERT(0);
index 73423bc181de2ad782cd13b7e9c34e0a5c32b035..a3e97ea9677d641ad14e777165badc821257e166 100644 (file)
@@ -37,9 +37,9 @@ typedef struct BMEditSelection
 /* geometry hiding code */
 #define BM_elem_hide_set(bm, ele, hide) _bm_elem_hide_set(bm, &(ele)->head, hide)
 void _bm_elem_hide_set(BMesh *bm, BMHeader *ele, int hide);
-void BM_vert_hide_set(BMesh *bm, BMVert *v, int hide);
-void BM_edge_hide_set(BMesh *bm, BMEdge *e, int hide);
-void BM_face_hide_set(BMesh *bm, BMFace *f, int hide);
+void BM_vert_hide_set(BMVert *v, int hide);
+void BM_edge_hide_set(BMEdge *e, int hide);
+void BM_face_hide_set(BMFace *f, int hide);
 
 /* Selection code */
 #define BM_elem_select_set(bm, ele, hide) _bm_elem_select_set(bm, &(ele)->head, hide)
@@ -71,9 +71,9 @@ int BM_mesh_elem_hflag_count_enabled(BMesh *bm, const char htype, const char hfl
 int BM_mesh_elem_hflag_count_disabled(BMesh *bm, const char htype, const char hflag, int respecthide);
 
 /* edit selection stuff */
-void    BM_active_face_set(BMesh *em, BMFace *f);
+void    BM_active_face_set(BMesh *bm, BMFace *f);
 BMFace *BM_active_face_get(BMesh *bm, int sloppy);
-void BM_editselection_center(BMesh *bm, float r_center[3], BMEditSelection *ese);
+void BM_editselection_center(float r_center[3], BMEditSelection *ese);
 void BM_editselection_normal(float r_normal[3], BMEditSelection *ese);
 void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese);
 
index c15937abf1deeaf7d85b9788b0c8b01453b7bdd7..454ab58d720ded6c8a2e00527f485ff4eb430386 100644 (file)
@@ -104,15 +104,15 @@ void BM_mesh_data_free(BMesh *bm)
        BMIter iter;
        BMIter itersub;
        
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                CustomData_bmesh_free_block(&(bm->vdata), &(v->head.data));
        }
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                CustomData_bmesh_free_block(&(bm->edata), &(e->head.data));
        }
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                CustomData_bmesh_free_block(&(bm->pdata), &(f->head.data));
-               BM_ITER(l, &itersub, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &itersub, f, BM_LOOPS_OF_FACE) {
                        CustomData_bmesh_free_block(&(bm->ldata), &(l->head.data));
                }
        }
@@ -211,19 +211,19 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
        float (*edgevec)[3];
        
        /* calculate all face normals */
-       BM_ITER(f, &faces, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &faces, bm, BM_FACES_OF_MESH) {
                if (skip_hidden && BM_elem_flag_test(f, BM_ELEM_HIDDEN))
                        continue;
-#if 0  /* UNUSED */
+#if 0   /* UNUSED */
                if (f->head.flag & BM_NONORMCALC)
                        continue;
 #endif
 
-               BM_face_normal_update(bm, f);
+               BM_face_normal_update(f);
        }
        
        /* Zero out vertex normals */
-       BM_ITER(v, &verts, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &verts, bm, BM_VERTS_OF_MESH) {
                if (skip_hidden && BM_elem_flag_test(v, BM_ELEM_HIDDEN))
                        continue;
 
@@ -235,7 +235,7 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
         * normals */
        index = 0;
        edgevec = MEM_callocN(sizeof(float) * 3 * bm->totedge, "BM normal computation array");
-       BM_ITER(e, &edges, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &edges, bm, BM_EDGES_OF_MESH) {
                BM_elem_index_set(e, index); /* set_inline */
 
                if (e->l) {
@@ -251,12 +251,12 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
        bm->elem_index_dirty &= ~BM_EDGE;
 
        /* add weighted face normals to vertices */
-       BM_ITER(f, &faces, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &faces, bm, BM_FACES_OF_MESH) {
 
                if (skip_hidden && BM_elem_flag_test(f, BM_ELEM_HIDDEN))
                        continue;
 
-               BM_ITER(l, &loops, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &loops, f, BM_LOOPS_OF_FACE) {
                        float *e1diff, *e2diff;
                        float dotprod;
                        float fac;
@@ -282,7 +282,7 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
        }
        
        /* normalize the accumulated vertex normals */
-       BM_ITER(v, &verts, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &verts, bm, BM_VERTS_OF_MESH) {
                if (skip_hidden && BM_elem_flag_test(v, BM_ELEM_HIDDEN))
                        continue;
 
@@ -304,7 +304,7 @@ void BM_mesh_normals_update(BMesh *bm, const short skip_hidden)
  */
 
 //keep in sycn with utils.c!
-#define FACE_FLIP      8
+#define FACE_FLIP   8
 static void bm_rationalize_normals(BMesh *bm, int undo)
 {
        BMOperator bmop;
@@ -312,7 +312,7 @@ static void bm_rationalize_normals(BMesh *bm, int undo)
        BMIter iter;
        
        if (undo) {
-               BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                        if (BM_elem_flag_test(f, BM_ELEM_TAG)) {
                                BM_face_normal_flip(bm, f);
                        }
@@ -327,7 +327,7 @@ static void bm_rationalize_normals(BMesh *bm, int undo)
        BMO_push(bm, &bmop);
        bmo_righthandfaces_exec(bm, &bmop);
        
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                BM_elem_flag_set(f, BM_ELEM_TAG, BMO_elem_flag_test(bm, f, FACE_FLIP));
        }
 
@@ -350,10 +350,10 @@ static void UNUSED_FUNCTION(bm_mdisps_space_set)(Object *ob, BMesh *bm, int from
                
                mdisps = CustomData_get_layer(&dm->loopData, CD_MDISPS);
                
-               BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                        BMLoop *l;
                        BMIter liter;
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+                       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                                MDisps *lmd = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_MDISPS);
                                
                                if (!lmd->disps) {
@@ -463,7 +463,7 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag)
        if (hflag & BM_VERT) {
                if (bm->elem_index_dirty & BM_VERT) {
                        int index = 0;
-                       BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
                                BM_elem_index_set(ele, index); /* set_ok */
                                index++;
                        }
@@ -478,7 +478,7 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag)
        if (hflag & BM_EDGE) {
                if (bm->elem_index_dirty & BM_EDGE) {
                        int index = 0;
-                       BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
                                BM_elem_index_set(ele, index); /* set_ok */
                                index++;
                        }
@@ -493,7 +493,7 @@ void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag)
        if (hflag & BM_FACE) {
                if (bm->elem_index_dirty & BM_FACE) {
                        int index = 0;
-                       BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
                                BM_elem_index_set(ele, index); /* set_ok */
                                index++;
                        }
@@ -540,7 +540,7 @@ void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *fu
                int err_val = 0;
                int err_idx = 0;
 
-               BM_ITER(ele, &iter, bm, iter_types[i], NULL) {
+               BM_ITER_MESH (ele, &iter, bm, iter_types[i]) {
                        if (!is_dirty) {
                                if (BM_elem_index_get(ele) != index) {
                                        err_val = BM_elem_index_get(ele);
@@ -561,7 +561,7 @@ void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *fu
                }
                else if ((is_error == FALSE) && (is_dirty == TRUE)) {
 
-#if 0          /* mostly annoying */
+#if 0       /* mostly annoying */
 
                        /* dirty may have been incorrectly set */
                        fprintf(stderr,
@@ -584,6 +584,176 @@ void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *fu
 
 }
 
+/**
+ * Remaps the vertices, edges and/or faces of the bmesh as indicated by vert/edge/face_idx arrays
+ * (xxx_idx[org_index] = new_index).
+ *
+ * A NULL array means no changes.
+ *
+ * Note: - Does not mess with indices, just sets elem_index_dirty flag.
+ *       - For verts/edges/faces only (as loops must remain "ordered" and "aligned"
+ *         on a per-face basis...).
+ *
+ * WARNING: Be careful if you keep pointers to affected BM elements, or arrays, when using this func!
+ */
+void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx)
+{
+       /* Mapping old to new pointers. */
+       GHash *vptr_map = NULL, *eptr_map = NULL, *fptr_map = NULL;
+       BMIter iter, iterl;
+       BMVert *ve;
+       BMEdge *ed;
+       BMFace *fa;
+       BMLoop *lo;
+
+       if (!(vert_idx || edge_idx || face_idx))
+               return;
+
+       /* Remap vertices */
+       if (vert_idx) {
+               BMVert **verts_pool, *verts_copy, **vep;
+               int i, totvert = bm->totvert;
+               int *new_idx = NULL;
+
+               /* Init the old-to-new vert pointers mapping */
+               vptr_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BM_mesh_remap vert pointers mapping");
+
+               /* Make a copy of all vertices. */
+               verts_pool = MEM_callocN(sizeof(BMVert *) * totvert, "BM_mesh_remap verts pool");
+               BM_iter_as_array(bm, BM_VERTS_OF_MESH, NULL, (void **)verts_pool, totvert);
+               verts_copy = MEM_mallocN(sizeof(BMVert) * totvert, "BM_mesh_remap verts copy");
+               for (i = totvert, ve = verts_copy + totvert - 1, vep = verts_pool + totvert - 1; i--; ve--, vep--) {
+                       *ve = **vep;
+/*                     printf("*vep: %p, verts_pool[%d]: %p\n", *vep, i, verts_pool[i]);*/
+               }
+
+               /* Copy back verts to their new place, and update old2new pointers mapping. */
+               new_idx = vert_idx + totvert - 1;
+               ve = verts_copy + totvert - 1;
+               vep = verts_pool + totvert - 1; /* old, org pointer */
+               for (i = totvert; i--; new_idx--, ve--, vep--) {
+                       BMVert *new_vep = verts_pool[*new_idx];
+                       *new_vep = *ve;
+/*                     printf("mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);*/
+                       BLI_ghash_insert(vptr_map, (void *)*vep, (void *)new_vep);
+               }
+               bm->elem_index_dirty |= BM_VERT;
+
+               MEM_freeN(verts_pool);
+               MEM_freeN(verts_copy);
+       }
+
+       /* XXX Code not tested yet (though I don't why it would fail)! */
+       if (edge_idx) {
+               BMEdge **edges_pool, *edges_copy, **edp;
+               int i, totedge = bm->totedge;
+               int *new_idx = NULL;
+
+               /* Init the old-to-new vert pointers mapping */
+               eptr_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BM_mesh_remap edge pointers mapping");
+
+               /* Make a copy of all vertices. */
+               edges_pool = MEM_callocN(sizeof(BMEdge *) * totedge, "BM_mesh_remap edges pool");
+               BM_iter_as_array(bm, BM_EDGES_OF_MESH, NULL, (void **)edges_pool, totedge);
+               edges_copy = MEM_mallocN(sizeof(BMEdge) * totedge, "BM_mesh_remap edges copy");
+               for (i = totedge, ed = edges_copy + totedge - 1, edp = edges_pool + totedge - 1; i--; ed--, edp--) {
+                       *ed = **edp;
+               }
+
+               /* Copy back verts to their new place, and update old2new pointers mapping. */
+               new_idx = edge_idx + totedge - 1;
+               ed = edges_copy + totedge - 1;
+               edp = edges_pool + totedge - 1; /* old, org pointer */
+               for (i = totedge; i--; new_idx--, ed--, edp--) {
+                       BMEdge *new_edp = edges_pool[*new_idx];
+                       *new_edp = *ed;
+                       BLI_ghash_insert(eptr_map, (void *)*edp, (void *)new_edp);
+               }
+
+               bm->elem_index_dirty |= BM_EDGE;
+
+               MEM_freeN(edges_pool);
+               MEM_freeN(edges_copy);
+       }
+
+       /* XXX Code not tested yet (though I don't why it would fail)! */
+       if (face_idx) {
+               BMFace **faces_pool, *faces_copy, **fap;
+               int i, totface = bm->totface;
+               int *new_idx = NULL;
+
+               /* Init the old-to-new vert pointers mapping */
+               fptr_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BM_mesh_remap face pointers mapping");
+
+               /* Make a copy of all vertices. */
+               faces_pool = MEM_callocN(sizeof(BMFace *) * totface, "BM_mesh_remap faces pool");
+               BM_iter_as_array(bm, BM_FACES_OF_MESH, NULL, (void **)faces_pool, totface);
+               faces_copy = MEM_mallocN(sizeof(BMFace) * totface, "BM_mesh_remap faces copy");
+               for (i = totface, fa = faces_copy + totface - 1, fap = faces_pool + totface - 1; i--; fa--, fap--) {
+                       *fa = **fap;
+               }
+
+               /* Copy back verts to their new place, and update old2new pointers mapping. */
+               new_idx = face_idx + totface - 1;
+               fa = faces_copy + totface - 1;
+               fap = faces_pool + totface - 1; /* old, org pointer */
+               for (i = totface; i--; new_idx--, fa--, fap--) {
+                       BMFace *new_fap = faces_pool[*new_idx];
+                       *new_fap = *fa;
+                       BLI_ghash_insert(fptr_map, (void *)*fap, (void *)new_fap);
+               }
+
+               bm->elem_index_dirty |= BM_FACE;
+
+               MEM_freeN(faces_pool);
+               MEM_freeN(faces_copy);
+       }
+
+       /* And now, fix all vertices/edges/faces/loops pointers! */
+       /* Verts' pointers, only edge pointers... */
+       if (eptr_map) {
+               BM_ITER_MESH (ve, &iter, bm, BM_VERTS_OF_MESH) {
+/*                     printf("Vert e: %p -> %p\n", ve->e, BLI_ghash_lookup(eptr_map, (const void*)ve->e));*/
+                       ve->e = BLI_ghash_lookup(eptr_map, (const void *)ve->e);
+               }
+       }
+
+       /* Edges' pointers, only vert pointers (as we don’t mess with loops!)... */
+       if (vptr_map) {
+               BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) {
+/*                     printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, (const void*)ed->v1));*/
+/*                     printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, (const void*)ed->v2));*/
+                       ed->v1 = BLI_ghash_lookup(vptr_map, (const void *)ed->v1);
+                       ed->v2 = BLI_ghash_lookup(vptr_map, (const void *)ed->v2);
+               }
+       }
+
+       /* Faces' pointers (loops, in fact), always needed... */
+       BM_ITER_MESH (fa, &iter, bm, BM_FACES_OF_MESH) {
+               BM_ITER_ELEM (lo, &iterl, fa, BM_LOOPS_OF_FACE) {
+                       if (vptr_map) {
+/*                             printf("Loop v: %p -> %p\n", lo->v, BLI_ghash_lookup(vptr_map, (const void*)lo->v));*/
+                               lo->v = BLI_ghash_lookup(vptr_map, (const void *)lo->v);
+                       }
+                       if (eptr_map) {
+/*                             printf("Loop e: %p -> %p\n", lo->e, BLI_ghash_lookup(eptr_map, (const void*)lo->e));*/
+                               lo->e = BLI_ghash_lookup(eptr_map, (const void *)lo->e);
+                       }
+                       if (fptr_map) {
+/*                             printf("Loop f: %p -> %p\n", lo->f, BLI_ghash_lookup(fptr_map, (const void*)lo->f));*/
+                               lo->f = BLI_ghash_lookup(fptr_map, (const void *)lo->f);
+                       }
+               }
+       }
+
+       if (vptr_map)
+               BLI_ghash_free(vptr_map, NULL, NULL);
+       if (eptr_map)
+               BLI_ghash_free(eptr_map, NULL, NULL);
+       if (fptr_map)
+               BLI_ghash_free(fptr_map, NULL, NULL);
+}
+
 BMVert *BM_vert_at_index(BMesh *bm, const int index)
 {
        return BLI_mempool_findelem(bm->vpool, index);
index f48cc09af3bd51d17335dc2ff2a57aaa90e31ab9..970db6339c3a178d18cd66c02e79efdff29cf67b 100644 (file)
@@ -43,6 +43,7 @@ void bmesh_edit_end(BMesh *bm, int flag);
 void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag);
 void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func,
                                  const char *msg_a, const char *msg_b);
+void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx);
 
 BMVert *BM_vert_at_index(BMesh *bm, const int index);
 BMEdge *BM_edge_at_index(BMesh *bm, const int index);
index c8876e554315c80a82b82fd2f8c51dae3d864011..574fb62b70300aae091b3b354cd3ccbacacb0883 100644 (file)
@@ -336,7 +336,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
                if (i == me->act_face) bm->act_face = f;
 
                j = 0;
-               BM_ITER_INDEX(l, &iter, bm, BM_LOOPS_OF_FACE, f, j) {
+               BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, j) {
                        /* Save index of correspsonding MLoop */
                        BM_elem_index_set(l, mpoly->loopstart + j); /* set_loop */
                }
@@ -355,8 +355,8 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
                 * but is an optimization, to avoid copying a bunch of interpolated customdata
                 * for each BMLoop (from previous BMLoops using the same edge), always followed
                 * by freeing the interpolated data and overwriting it with data from the Mesh. */
-               BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
+                       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                                int li = BM_elem_index_get(l);
                                CustomData_to_bmesh_block(&me->ldata, &bm->ldata, li, &l->head.data);
                                BM_elem_index_set(l, 0); /* set_loop */
@@ -379,9 +379,9 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
                BMFace  *face;
                MSelect *msel;
 
-               BM_ITER_INDEX(vert, &iter, bm, BM_VERTS_OF_MESH, NULL, i) { vert_array[i] = vert; }
-               BM_ITER_INDEX(edge, &iter, bm, BM_EDGES_OF_MESH, NULL, i) { edge_array[i] = edge; }
-               BM_ITER_INDEX(face, &iter, bm, BM_FACES_OF_MESH, NULL, i) { face_array[i] = face; }
+               BM_ITER_MESH_INDEX (vert, &iter, bm, BM_VERTS_OF_MESH, i) { vert_array[i] = vert; }
+               BM_ITER_MESH_INDEX (edge, &iter, bm, BM_EDGES_OF_MESH, i) { edge_array[i] = edge; }
+               BM_ITER_MESH_INDEX (face, &iter, bm, BM_FACES_OF_MESH, i) { face_array[i] = face; }
 
                for (i = 0, msel = me->mselect; i < me->totselect; i++, msel++) {
                        switch (msel->type) {
@@ -432,7 +432,7 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert)
        vertMap = MEM_callocN(sizeof(*vertMap) * ototvert, "vertMap");
        if (CustomData_has_layer(&bm->vdata, CD_SHAPE_KEYINDEX)) {
                int *keyi;
-               BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
                        keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
                        if (keyi) {
                                if (((index = *keyi) != ORIGINDEX_NONE) && (index < ototvert)) {
@@ -448,7 +448,7 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert)
                }
        }
        else {
-               BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
                        if (i < ototvert) {
                                vertMap[i] = eve;
                        }
@@ -564,7 +564,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
        mesh_update_customdata_pointers(me, 0);
 
        i = 0;
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                float *bweight = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BWEIGHT);
 
                mvert->bweight = bweight ? (char)((*bweight) * 255) : 0;
@@ -582,13 +582,13 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
                i++;
                mvert++;
 
-               BM_CHECK_ELEMENT(bm, v);
+               BM_CHECK_ELEMENT(v);
        }
        bm->elem_index_dirty &= ~BM_VERT;
 
        med = medge;
        i = 0;
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                float *crease = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE);
                float *bweight = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BWEIGHT);
 
@@ -608,13 +608,13 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
 
                i++;
                med++;
-               BM_CHECK_ELEMENT(bm, e);
+               BM_CHECK_ELEMENT(e);
        }
        bm->elem_index_dirty &= ~BM_EDGE;
 
        i = 0;
        j = 0;
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                mpoly->loopstart = j;
                mpoly->totloop = f->len;
                mpoly->mat_nr = f->mat_nr;
@@ -627,9 +627,9 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
 
                        /* copy over customdat */
                        CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l->head.data, j);
-                       BM_CHECK_ELEMENT(bm, l);
-                       BM_CHECK_ELEMENT(bm, l->e);
-                       BM_CHECK_ELEMENT(bm, l->v);
+                       BM_CHECK_ELEMENT(l);
+                       BM_CHECK_ELEMENT(l->e);
+                       BM_CHECK_ELEMENT(l->v);
                }
 
                if (f == bm->act_face) me->act_face = i;
@@ -639,7 +639,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
 
                i++;
                mpoly++;
-               BM_CHECK_ELEMENT(bm, f);
+               BM_CHECK_ELEMENT(f);
        }
 
        /* patch hook indices and vertex parents */
@@ -783,7 +783,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
 
                                ofs = MEM_callocN(sizeof(float) * 3 * bm->totvert,  "currkey->data");
                                mvert = me->mvert;
-                               BM_ITER_INDEX(eve, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
+                               BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
                                        keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX);
                                        if (keyi && *keyi != ORIGINDEX_NONE) {
                                                sub_v3_v3v3(ofs[i], mvert->co, fp[*keyi]);
@@ -806,7 +806,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
                        oldkey = currkey->data;
 
                        mvert = me->mvert;
-                       BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
 
                                if (currkey == actkey) {
                                        copy_v3_v3(fp, eve->co);
index f91e9d828799c8f36f5b281c404ae470e61a9649..3ec3b84c1200391936c9213ea8348a683da4ef37 100644 (file)
@@ -70,7 +70,7 @@ int BM_mesh_validate(BMesh *bm)
        bm->elem_index_dirty |= BM_ALL;
        BM_mesh_elem_index_ensure(bm, BM_ALL);
 
-       BM_ITER_INDEX(v, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
                if (BM_elem_flag_test(v, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) {
                        ERRMSG("vert %d: is hidden and selected", i);
                }
@@ -83,13 +83,13 @@ int BM_mesh_validate(BMesh *bm)
        }
 
        /* check edges */
-       BM_ITER_INDEX(e, &iter, bm, BM_EDGES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
                if (e->v1 == e->v2)
                ERRMSG("edge %d: duplicate index: %d", i, BM_elem_index_get(e->v1));
        }
 
        /* edge radial structure */
-       BM_ITER_INDEX(e, &iter, bm, BM_EDGES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
                if (BM_elem_flag_test(e, BM_ELEM_SELECT | BM_ELEM_HIDDEN) == (BM_ELEM_SELECT | BM_ELEM_HIDDEN)) {
                        ERRMSG("edge %d: is hidden and selected", i);
                }
@@ -117,7 +117,7 @@ int BM_mesh_validate(BMesh *bm)
        }
 
        /* face structure */
-       BM_ITER_INDEX(f, &iter, bm, BM_FACES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) {
                BMLoop *l_iter;
                BMLoop *l_first;
 
index 20306d3bd4a0183e93e3563241bb5723cb65c537..21654097219ea043c325bd9751ac88843fb7a11c 100644 (file)
@@ -286,8 +286,8 @@ BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f)
        BMFace *f_iter;
 
        /* be warned: this can do weird things in some ngon situation, see BM_face_legal_splits */
-       BM_ITER(f_iter, &fiter, bm, BM_FACES_OF_VERT, v1) {
-               BM_ITER(v_iter, &viter, bm, BM_FACES_OF_VERT, f_iter) {
+       BM_ITER_ELEM (f_iter, &fiter, v1, BM_FACES_OF_VERT) {
+               BM_ITER_ELEM (v_iter, &viter, f_iter, BM_FACES_OF_VERT) {
                        if (v_iter == v2) {
                                BMLoop *nl;
 
@@ -521,7 +521,7 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac,
                BMFace *f;
                BLI_array_staticdeclare(faces, 8);
 
-               BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, kv) {
+               BM_ITER_ELEM (f, &iter, kv, BM_FACES_OF_VERT) {
                        BLI_array_append(faces, f);
                }
 
@@ -556,7 +556,7 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac,
                        for (i = 0; i < 2; i++) {
                                /* cant kill data we loop on, build a list and remove those */
                                BLI_array_empty(bad_faces);
-                               BM_ITER(f, &fiter, bm, BM_FACES_OF_VERT, verts[i]) {
+                               BM_ITER_ELEM (f, &fiter, verts[i], BM_FACES_OF_VERT) {
                                        if (f->len < 3) {
                                                BLI_array_append(bad_faces, f);
                                        }
@@ -817,14 +817,14 @@ int BM_face_validate(BMesh *bm, BMFace *face, FILE *err)
  *
  * \note #BM_edge_rotate_check must have already run.
  */
-void BM_edge_rotate_calc(BMesh *bm, BMEdge *e, int ccw,
+void BM_edge_rotate_calc(BMEdge *e, int ccw,
                          BMLoop **r_l1, BMLoop **r_l2)
 {
        BMVert *v1, *v2;
        BMFace *fa, *fb;
 
        /* this should have already run */
-       BLI_assert(BM_edge_rotate_check(bm, e) == TRUE);
+       BLI_assert(BM_edge_rotate_check(e) == TRUE);
 
        /* we know this will work */
        BM_edge_face_pair(e, &fa, &fb);
@@ -842,9 +842,6 @@ void BM_edge_rotate_calc(BMesh *bm, BMEdge *e, int ccw,
 
        *r_l1 = BM_face_other_vert_loop(fb, v2, v1);
        *r_l2 = BM_face_other_vert_loop(fa, v1, v2);
-
-       /* when assert isn't used */
-       (void)bm;
 }
 
 /**
@@ -853,7 +850,7 @@ void BM_edge_rotate_calc(BMesh *bm, BMEdge *e, int ccw,
  * Quick check to see if we could rotate the edge,
  * use this to avoid calling exceptions on common cases.
  */
-int BM_edge_rotate_check(BMesh *UNUSED(bm), BMEdge *e)
+int BM_edge_rotate_check(BMEdge *e)
 {
        BMFace *fa, *fb;
        if (BM_edge_face_pair(e, &fa, &fb)) {
@@ -894,8 +891,7 @@ int BM_edge_rotate_check(BMesh *UNUSED(bm), BMEdge *e)
  * \param l1,l2 are the loops of the proposed verts to rotate too and should
  * be the result of calling #BM_edge_rotate_calc
  */
-int BM_edge_rotate_check_degenerate(BMesh *bm, BMEdge *e,
-                                    BMLoop *l1, BMLoop *l2)
+int BM_edge_rotate_check_degenerate(BMEdge *e, BMLoop *l1, BMLoop *l2)
 {
        /* note: for these vars 'old' just means initial edge state. */
 
@@ -922,7 +918,7 @@ int BM_edge_rotate_check_degenerate(BMesh *bm, BMEdge *e,
        BMVert *v1_alt, *v2_alt;
 
        /* this should have already run */
-       BLI_assert(BM_edge_rotate_check(bm, e) == TRUE);
+       BLI_assert(BM_edge_rotate_check(e) == TRUE);
 
        BM_edge_ordered_verts(e, &v1_old, &v2_old);
 
@@ -981,12 +977,9 @@ int BM_edge_rotate_check_degenerate(BMesh *bm, BMEdge *e,
        }
 
        return TRUE;
-
-       /* when assert isn't used */
-       (void)bm;
 }
 
-int BM_edge_rotate_check_beauty(BMesh *UNUSED(bm), BMEdge *e,
+int BM_edge_rotate_check_beauty(BMEdge *e,
                                 BMLoop *l1, BMLoop *l2)
 {
        /* Stupid check for now:
@@ -1019,11 +1012,11 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_
        char f_hflag_prev_1;
        char f_hflag_prev_2;
 
-       if (!BM_edge_rotate_check(bm, e)) {
+       if (!BM_edge_rotate_check(e)) {
                return NULL;
        }
 
-       BM_edge_rotate_calc(bm, e, ccw, &l1, &l2);
+       BM_edge_rotate_calc(e, ccw, &l1, &l2);
 
        /* the loops will be freed so assign verts */
        v1 = l1->v;
@@ -1033,7 +1026,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_
        /* Checking Code - make sure we can rotate */
 
        if (check_flag & BM_EDGEROT_CHECK_BEAUTY) {
-               if (!BM_edge_rotate_check_beauty(bm, e, l1, l2)) {
+               if (!BM_edge_rotate_check_beauty(e, l1, l2)) {
                        return NULL;
                }
        }
@@ -1047,7 +1040,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_
 
        /* slowest, check last */
        if (check_flag & BM_EDGEROT_CHECK_DEGENERATE) {
-               if (!BM_edge_rotate_check_degenerate(bm, e, l1, l2)) {
+               if (!BM_edge_rotate_check_degenerate(e, l1, l2)) {
                        return NULL;
                }
        }
index ba601eb64dc2e4a6c09a27cc5564129405a184c3..ba6acac1a2759224bcf849ae3a2dc16a23d43d24 100644 (file)
@@ -43,9 +43,9 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f,
                       BMEdge *example, const short nodouble);
 
 BMFace *BM_face_split_n(BMesh *bm, BMFace *f,
-                      BMVert *v1, BMVert *v2,
-                      float cos[][3], int n,
-                      BMLoop **r_l, BMEdge *example);
+                        BMVert *v1, BMVert *v2,
+                        float cos[][3], int n,
+                        BMLoop **r_l, BMEdge *example);
 
 BMEdge* BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac,
                                const short join_faces, const short kill_degenerate_faces);
@@ -59,12 +59,12 @@ BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts);
 
 int     BM_face_validate(BMesh *bm, BMFace *face, FILE *err);
 
-void    BM_edge_rotate_calc(BMesh *bm, BMEdge *e, int ccw,
-                                   BMLoop **r_l1, BMLoop **r_l2);
-int     BM_edge_rotate_check(BMesh *UNUSED(bm), BMEdge *e);
-int     BM_edge_rotate_check_degenerate(BMesh *bm, BMEdge *e,
+void    BM_edge_rotate_calc(BMEdge *e, int ccw,
+                            BMLoop **r_l1, BMLoop **r_l2);
+int     BM_edge_rotate_check(BMEdge *e);
+int     BM_edge_rotate_check_degenerate(BMEdge *e,
                                         BMLoop *l1, BMLoop *l2);
-int     BM_edge_rotate_check_beauty(BMesh *bm, BMEdge *e,
+int     BM_edge_rotate_check_beauty(BMEdge *e,
                                     BMLoop *l1, BMLoop *l2);
 BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_flag);
 
index a1cdcc65f1c0e19d370eb087df7f9253c4278151..dce491efe72a4aab3487953bf54af6f535578248 100644 (file)
@@ -473,7 +473,7 @@ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag,
 
        for (i = 0; i < 3; i++) {
                if (htype & flag_types[i]) {
-                       BM_ITER(ele_f, &iter, bm, iter_types[i], NULL) {
+                       BM_ITER_MESH (ele_f, &iter, bm, iter_types[i]) {
                                if (BMO_elem_flag_test_bool(bm, ele_f, oflag) == test_for_enabled)
                                        count++;
                        }
@@ -508,7 +508,7 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty
 
        for (i = 0; i < 3; i++) {
                if (htype & flag_types[i]) {
-                       BM_ITER(ele, &iter, bm, iter_types[i], NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, iter_types[i]) {
                                BMO_elem_flag_disable(bm, ele, oflag);
                        }
                }
@@ -663,21 +663,21 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot
                /* TODO - collapse these loops into one */
 
                if (htype & BM_VERT) {
-                       BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
                                ((BMHeader **)output->data.p)[i] = ele;
                                i++;
                        }
                }
 
                if (htype & BM_EDGE) {
-                       BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
                                ((BMHeader **)output->data.p)[i] = ele;
                                i++;
                        }
                }
 
                if (htype & BM_FACE) {
-                       BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
                                ((BMHeader **)output->data.p)[i] = ele;
                                i++;
                        }
@@ -714,7 +714,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
                /* TODO - collapse these loops into one */
 
                if (htype & BM_VERT) {
-                       BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
                                if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) &&
                                    BM_elem_flag_test_bool(ele, hflag) == test_for_enabled)
                                {
@@ -725,7 +725,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
                }
 
                if (htype & BM_EDGE) {
-                       BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
                                if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) &&
                                    BM_elem_flag_test_bool(ele, hflag) == test_for_enabled)
                                {
@@ -736,7 +736,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl
                }
 
                if (htype & BM_FACE) {
-                       BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
                                if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN) &&
                                    BM_elem_flag_test_bool(ele, hflag) == test_for_enabled)
                                {
@@ -828,7 +828,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo
                /* TODO - collapse these loops into one */
 
                if (htype & BM_VERT) {
-                       BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
                                if (BMO_elem_flag_test_bool(bm, (BMElemF *)ele, oflag) == test_for_enabled) {
                                        ele_array[i] = ele;
                                        i++;
@@ -837,7 +837,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo
                }
 
                if (htype & BM_EDGE) {
-                       BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
                                if (BMO_elem_flag_test_bool(bm, (BMElemF *)ele, oflag) == test_for_enabled) {
                                        ele_array[i] = ele;
                                        i++;
@@ -846,7 +846,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo
                }
 
                if (htype & BM_FACE) {
-                       BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) {
+                       BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
                                if (BMO_elem_flag_test_bool(bm, (BMElemF *)ele, oflag) == test_for_enabled) {
                                        ele_array[i] = ele;
                                        i++;
@@ -1035,19 +1035,19 @@ static void bmo_flag_layer_alloc(BMesh *bm)
        bm->toolflagpool = newpool = BLI_mempool_create(sizeof(BMFlagLayer) * bm->totflags, 512, 512, 0);
        
        /* now go through and memcpy all the flags. Loops don't get a flag layer at this time.. */
-       BM_ITER_INDEX(ele, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
                oldflags = ele->oflags;
                ele->oflags = BLI_mempool_calloc(newpool);
                memcpy(ele->oflags, oldflags, old_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
-       BM_ITER_INDEX(ele, &iter, bm, BM_EDGES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
                oldflags = ele->oflags;
                ele->oflags = BLI_mempool_calloc(newpool);
                memcpy(ele->oflags, oldflags, old_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
-       BM_ITER_INDEX(ele, &iter, bm, BM_FACES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
                oldflags = ele->oflags;
                ele->oflags = BLI_mempool_calloc(newpool);
                memcpy(ele->oflags, oldflags, old_totflags_size);
@@ -1080,19 +1080,19 @@ static void bmo_flag_layer_free(BMesh *bm)
        bm->toolflagpool = newpool = BLI_mempool_create(new_totflags_size, 512, 512, BLI_MEMPOOL_SYSMALLOC);
        
        /* now go through and memcpy all the flag */
-       BM_ITER_INDEX(ele, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
                oldflags = ele->oflags;
                ele->oflags = BLI_mempool_calloc(newpool);
                memcpy(ele->oflags, oldflags, new_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
-       BM_ITER_INDEX(ele, &iter, bm, BM_EDGES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
                oldflags = ele->oflags;
                ele->oflags = BLI_mempool_calloc(newpool);
                memcpy(ele->oflags, oldflags, new_totflags_size);
                BM_elem_index_set(ele, i); /* set_inline */
        }
-       BM_ITER_INDEX(ele, &iter, bm, BM_FACES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
                oldflags = ele->oflags;
                ele->oflags = BLI_mempool_calloc(newpool);
                memcpy(ele->oflags, oldflags, new_totflags_size);
@@ -1115,15 +1115,15 @@ static void bmo_flag_layer_clear(BMesh *bm)
        const int totflags_offset = bm->totflags - 1;
 
        /* now go through and memcpy all the flag */
-       BM_ITER_INDEX(ele, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
                memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer));
                BM_elem_index_set(ele, i); /* set_inline */
        }
-       BM_ITER_INDEX(ele, &iter, bm, BM_EDGES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
                memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer));
                BM_elem_index_set(ele, i); /* set_inline */
        }
-       BM_ITER_INDEX(ele, &iter, bm, BM_FACES_OF_MESH, NULL, i) {
+       BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
                memset(ele->oflags + totflags_offset, 0, sizeof(BMFlagLayer));
                BM_elem_index_set(ele, i); /* set_inline */
        }
index 62cabe88b055ff6e264648fe3d75efa3ebf0375f..423b30a503afddf43644567bab0fe645d1fc198a 100644 (file)
@@ -37,11 +37,11 @@ void bmo_split_exec(BMesh *bm, BMOperator *op);
 void bmo_spin_exec(BMesh *bm, BMOperator *op);
 void bmo_dupe_exec(BMesh *bm, BMOperator *op);
 void bmo_del_exec(BMesh *bm, BMOperator *op);
-void bmo_esubd_exec(BMesh *bmesh, BMOperator *op);
-void bmo_triangulate_exec(BMesh *bmesh, BMOperator *op);
-void bmo_dissolve_faces_exec(BMesh *bmesh, BMOperator *op);
-void bmo_dissolve_verts_exec(BMesh *bmesh, BMOperator *op);
-void bmo_dissolve_limit_exec(BMesh *bmesh, BMOperator *op);
+void bmo_esubd_exec(BMesh *bm, BMOperator *op);
+void bmo_triangulate_exec(BMesh *bm, BMOperator *op);
+void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op);
+void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op);
+void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op);
 void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op);
 void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op);
 void bmo_connectverts_exec(BMesh *bm, BMOperator *op);
index 1b480ab03158e4fbb00f12bc6cff676b7a80bc3a..e7ee5cb605d624d1f9a7ed0d35e30bd4d8b606d3 100644 (file)
@@ -153,7 +153,7 @@ static void bm_face_compute_poly_normal_vertex_cos(BMFace *f, float n[3],
 /**
  * get the area of the face
  */
-float BM_face_area_calc(BMesh *bm, BMFace *f)
+float BM_face_area_calc(BMFace *f)
 {
        BMLoop *l;
        BMIter iter;
@@ -164,7 +164,7 @@ float BM_face_area_calc(BMesh *bm, BMFace *f)
 
        BLI_array_fixedstack_declare(verts, BM_NGON_STACK_SIZE, f->len, __func__);
 
-       BM_ITER_INDEX(l, &iter, bm, BM_LOOPS_OF_FACE, f, i) {
+       BM_ITER_ELEM_INDEX (l, &iter, f, BM_LOOPS_OF_FACE, i) {
                copy_v3_v3(verts[i], l->v->co);
        }
 
@@ -187,7 +187,7 @@ float BM_face_area_calc(BMesh *bm, BMFace *f)
 /**
  * compute the perimeter of an ngon
  */
-float BM_face_perimeter_calc(BMesh *UNUSED(bm), BMFace *f)
+float BM_face_perimeter_calc(BMFace *f)
 {
        BMLoop *l_iter, *l_first;
        float perimeter = 0.0f;
@@ -203,7 +203,7 @@ float BM_face_perimeter_calc(BMesh *UNUSED(bm), BMFace *f)
 /**
  * computes center of face in 3d.  uses center of bounding box.
  */
-void BM_face_center_bounds_calc(BMesh *UNUSED(bm), BMFace *f, float r_cent[3])
+void BM_face_center_bounds_calc(BMFace *f, float r_cent[3])
 {
        BMLoop *l_iter;
        BMLoop *l_first;
@@ -222,7 +222,7 @@ void BM_face_center_bounds_calc(BMesh *UNUSED(bm), BMFace *f, float r_cent[3])
 /**
  * computes the center of a face, using the mean average
  */
-void BM_face_center_mean_calc(BMesh *UNUSED(bm), BMFace *f, float r_cent[3])
+void BM_face_center_mean_calc(BMFace *f, float r_cent[3])
 {
        BMLoop *l_iter;
        BMLoop *l_first;
@@ -332,24 +332,23 @@ void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nvert
 /**
  * updates face and vertex normals incident on an edge
  */
-void BM_edge_normals_update(BMesh *bm, BMEdge *e)
+void BM_edge_normals_update(BMEdge *e)
 {
        BMIter iter;
        BMFace *f;
        
-       f = BM_iter_new(&iter, bm, BM_FACES_OF_EDGE, e);
-       for (; f; f = BM_iter_step(&iter)) {
-               BM_face_normal_update(bm, f);
+       BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) {
+               BM_face_normal_update(f);
        }
 
-       BM_vert_normal_update(bm, e->v1);
-       BM_vert_normal_update(bm, e->v2);
+       BM_vert_normal_update(e->v1);
+       BM_vert_normal_update(e->v2);
 }
 
 /**
  * update a vert normal (but not the faces incident on it)
  */
-void BM_vert_normal_update(BMesh *bm, BMVert *v)
+void BM_vert_normal_update(BMVert *v)
 {
        /* TODO, we can normalize each edge only once, then compare with previous edge */
 
@@ -360,7 +359,7 @@ void BM_vert_normal_update(BMesh *bm, BMVert *v)
 
        zero_v3(v->no);
 
-       BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) {
+       BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
                /* Same calculation used in BM_mesh_normals_update */
                sub_v3_v3v3(vec1, l->v->co, l->prev->v->co);
                sub_v3_v3v3(vec2, l->next->v->co, l->v->co);
@@ -379,16 +378,16 @@ void BM_vert_normal_update(BMesh *bm, BMVert *v)
        }
 }
 
-void BM_vert_normal_update_all(BMesh *bm, BMVert *v)
+void BM_vert_normal_update_all(BMVert *v)
 {
        BMIter iter;
        BMFace *f;
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, v) {
-               BM_face_normal_update(bm, f);
+       BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) {
+               BM_face_normal_update(f);
        }
 
-       BM_vert_normal_update(bm, v);
+       BM_vert_normal_update(v);
 }
 
 /**
@@ -401,7 +400,7 @@ void BM_vert_normal_update_all(BMesh *bm, BMVert *v)
  * is passed in as well.
  */
 
-void BM_face_normal_update(BMesh *UNUSED(bm), BMFace *f)
+void BM_face_normal_update(BMFace *f)
 {
        BMLoop *l;
 
@@ -564,7 +563,7 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2],
  * instead of projecting co directly into f's orientation space,
  * so there might be accuracy issues.
  */
-int BM_face_point_inside_test(BMesh *bm, BMFace *f, const float co[3])
+int BM_face_point_inside_test(BMFace *f, const float co[3])
 {
        int ax, ay;
        float co2[2], cent[2] = {0.0f, 0.0f}, out[2] = {FLT_MAX * 0.5f, FLT_MAX * 0.5f};
@@ -574,7 +573,7 @@ int BM_face_point_inside_test(BMesh *bm, BMFace *f, const float co[3])
        float onepluseps = 1.0f + (float)FLT_EPSILON * 150.0f;
        
        if (dot_v3v3(f->no, f->no) <= FLT_EPSILON * 10)
-               BM_face_normal_update(bm, f);
+               BM_face_normal_update(f);
        
        /* find best projection of face XY, XZ or YZ: barycentric weights of
         * the 2d projected coords are the same and faster to compute
@@ -659,7 +658,7 @@ static int goodline(float const (*projectverts)[3], BMFace *f,
  *
  * \param use_beauty Currently only applies to quads, can be extended later on.
  */
-static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], const int nvert, const int use_beauty)
+static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty)
 {
        BMLoop *bestear = NULL;
 
@@ -779,7 +778,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3],
        done = 0;
        while (!done && f->len > 3) {
                done = 1;
-               l_iter = find_ear(bm, f, projectverts, nvert, use_beauty);
+               l_iter = find_ear(f, projectverts, nvert, use_beauty);
                if (l_iter) {
                        done = 0;
                        /* v = l->v; */ /* UNUSED */
index 71387f18ce2b5dee99edd65c9063dbe310627132..117a47d34f20453774815ba476cce7a3b56199c5 100644 (file)
  *  \ingroup bmesh
  */
 
-float BM_face_area_calc(BMesh *bm, BMFace *f);
-float BM_face_perimeter_calc(BMesh *bm, BMFace *f);
-void  BM_face_center_bounds_calc(BMesh *bm, BMFace *f, float center[3]);
-void  BM_face_center_mean_calc(BMesh *bm, BMFace *f, float center[3]);
+float BM_face_area_calc(BMFace *f);
+float BM_face_perimeter_calc(BMFace *f);
+void  BM_face_center_bounds_calc(BMFace *f, float center[3]);
+void  BM_face_center_mean_calc(BMFace *f, float center[3]);
 
-void  BM_face_normal_update(BMesh *bm, BMFace *f);
+void  BM_face_normal_update(BMFace *f);
 void  BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3],
                                  float const (*vertexCos)[3]);
 
-void  BM_edge_normals_update(BMesh *bm, BMEdge *e);
+void  BM_edge_normals_update(BMEdge *e);
 
-void  BM_vert_normal_update(BMesh *bm, BMVert *v);
-void  BM_vert_normal_update_all(BMesh *bm, BMVert *v);
+void  BM_vert_normal_update(BMVert *v);
+void  BM_vert_normal_update_all(BMVert *v);
 
 void  BM_face_normal_flip(BMesh *bm, BMFace *f);
-int   BM_face_point_inside_test(BMesh *bm, BMFace *f, const float co[3]);
+int   BM_face_point_inside_test(BMFace *f, const float co[3]);
 
 void  BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3],
                           const short newedge_oflag, const short newface_oflag, BMFace **newfaces,
index 791c8d68880ae397f6e838bb1f2bc78e377040cf..f963425e1bd4b7baaa9ae1c31e5edc9bfe190bd6 100644 (file)
  */
 
 /* returns positive nonzero on error */
-int bmesh_elem_check(BMesh *bm, void *element, const char htype);
+int bmesh_elem_check(void *element, const char htype);
 
-#define BM_CHECK_ELEMENT(bm, el)                                              \
-    if (bmesh_elem_check(bm, el, ((BMHeader *)el)->htype)) {                  \
+#define BM_CHECK_ELEMENT(el)                                                  \
+    if (bmesh_elem_check(el, ((BMHeader *)el)->htype)) {                      \
         printf("check_element failure, with code %i on line %i in file\n"     \
         "    \"%s\"\n\n",                                                     \
-        bmesh_elem_check(bm, el, ((BMHeader *)el)->htype),                    \
+        bmesh_elem_check(el, ((BMHeader *)el)->htype),                    \
         __LINE__, __FILE__);                                                  \
     }
 
index 5efdd547ba9e80164163ca348b87734ce2cfcd24..af614f78aff14408bb6c97799752dfb757bacb17 100644 (file)
@@ -125,7 +125,7 @@ BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v)
 
        BLI_assert(BM_edge_exists(v_prev, v) != NULL);
 
-       BM_ITER(l_iter, &liter, NULL, BM_LOOPS_OF_VERT, v) {
+       BM_ITER_ELEM (l_iter, &liter, v, BM_LOOPS_OF_VERT) {
                if (l_iter->f == f) {
                        break;
                }
@@ -379,7 +379,7 @@ int BM_vert_edge_count_nonwire(BMVert *v)
        int count = 0;
        BMIter eiter;
        BMEdge *edge;
-       BM_ITER(edge, &eiter, NULL, BM_EDGES_OF_VERT, v) {
+       BM_ITER_ELEM (edge, &eiter, v, BM_EDGES_OF_VERT) {
                if (edge->l) {
                        count++;
                }
@@ -416,7 +416,7 @@ int BM_vert_face_count(BMVert *v)
        BMLoop *l;
        BMIter iter;
 
-       BM_ITER(l, &iter, NULL, BM_LOOPS_OF_VERT, v) {
+       BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
                count++;
        }
 
@@ -812,6 +812,31 @@ float BM_edge_face_angle(BMEdge *e)
        }
 }
 
+/**
+ * \brief BMESH EDGE/FACE TANGENT
+ *
+ * Calculate the tangent at this loop corner or fallback to the face normal on straignt lines.
+ * This vector always points inward into the face.
+ *
+ * \brief BM_edge_face_tangent
+ * \param e
+ * \param e_loop The loop to calculate the tangent at,
+ * used to get the face and winding direction.
+ */
+
+void BM_edge_face_tangent(BMEdge *e, BMLoop *e_loop, float r_tangent[3])
+{
+       float tvec[3];
+       BMVert *v1, *v2;
+       BM_edge_ordered_verts_ex(e, &v1, &v2, e_loop);
+
+       sub_v3_v3v3(tvec, v1->co, v2->co); /* use for temp storage */
+       /* note, we could average the tangents of both loops,
+        * for non flat ngons it will give a better direction */
+       cross_v3_v3v3(r_tangent, tvec, e_loop->f->no);
+       normalize_v3(r_tangent);
+}
+
 /**
  * \brief BMESH VERT/EDGE ANGLE
  *
@@ -852,7 +877,7 @@ BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2)
        BMIter iter;
        BMEdge *e;
 
-       BM_ITER(e, &iter, NULL, BM_EDGES_OF_VERT, v1) {
+       BM_ITER_ELEM (e, &iter, v1, BM_EDGES_OF_VERT) {
                if (e->v1 == v2 || e->v2 == v2)
                        return e;
        }
@@ -877,7 +902,7 @@ int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlap
        int i, amount;
 
        for (i = 0; i < len; i++) {
-               BM_ITER(f, &viter, bm, BM_FACES_OF_VERT, varr[i]) {
+               BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) {
                        amount = BM_verts_in_face(bm, f, varr, len);
                        if (amount >= len) {
                                if (r_overlapface) {
@@ -907,7 +932,7 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface)
        int i, amount;
 
        for (i = 0; i < len; i++) {
-               BM_ITER(f, &viter, bm, BM_FACES_OF_VERT, varr[i]) {
+               BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) {
                        amount = BM_verts_in_face(bm, f, varr, len);
                        if (amount == len && amount == f->len) {
                                if (r_existface) {
@@ -937,7 +962,7 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface)
  *
  * \a earr and \a varr can be in any order, however they _must_ form a closed loop.
  */
-int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len)
+int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len)
 {
        BMFace *f;
        BMEdge *e;
@@ -953,15 +978,15 @@ int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len)
        for (i = 0; i < len; i++) {
                /* save some time by looping over edge faces rather then vert faces
                 * will still loop over some faces twice but not as many */
-               BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, earr[i]) {
+               BM_ITER_ELEM (f, &fiter, earr[i], BM_FACES_OF_EDGE) {
                        BM_elem_flag_disable(f, BM_ELEM_INTERNAL_TAG);
-                       BM_ITER(v, &viter, bm, BM_VERTS_OF_FACE, f) {
+                       BM_ITER_ELEM (v, &viter, f, BM_VERTS_OF_FACE) {
                                BM_elem_flag_disable(v, BM_ELEM_INTERNAL_TAG);
                        }
                }
 
                /* clear all edge tags */
-               BM_ITER(e, &fiter, bm, BM_EDGES_OF_VERT, varr[i]) {
+               BM_ITER_ELEM (e, &fiter, varr[i], BM_EDGES_OF_VERT) {
                        BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG);
                }
        }
@@ -980,10 +1005,10 @@ int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len)
        /* 1) tag all faces connected to edges - if all their verts are boundary */
        tot_tag = 0;
        for (i = 0; i < len; i++) {
-               BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, earr[i]) {
+               BM_ITER_ELEM (f, &fiter, earr[i], BM_FACES_OF_EDGE) {
                        if (!BM_elem_flag_test(f, BM_ELEM_INTERNAL_TAG)) {
                                ok = TRUE;
-                               BM_ITER(v, &viter, bm, BM_VERTS_OF_FACE, f) {
+                               BM_ITER_ELEM (v, &viter, f, BM_VERTS_OF_FACE) {
                                        if (!BM_elem_flag_test(v, BM_ELEM_INTERNAL_TAG)) {
                                                ok = FALSE;
                                                break;
@@ -1011,7 +1036,7 @@ int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len)
         *    check each have 2 tagges faces connected (faces that only use 'varr' verts) */
        ok = TRUE;
        for (i = 0; i < len; i++) {
-               BM_ITER(e, &fiter, bm, BM_EDGES_OF_VERT, varr[i]) {
+               BM_ITER_ELEM (e, &fiter, varr[i], BM_EDGES_OF_VERT) {
 
                        if (/* non-boundary edge */
                            BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG) == FALSE &&
@@ -1020,7 +1045,7 @@ int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len)
                            BM_elem_flag_test(e->v2, BM_ELEM_INTERNAL_TAG) == TRUE)
                        {
                                int tot_face_tag = 0;
-                               BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) {
+                               BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) {
                                        if (BM_elem_flag_test(f, BM_ELEM_INTERNAL_TAG)) {
                                                tot_face_tag++;
                                        }
@@ -1043,7 +1068,7 @@ int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len)
 }
 
 /* same as 'BM_face_exists_multi' but built vert array from edges */
-int BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len)
+int BM_face_exists_multi_edge(BMEdge **earr, int len)
 {
        BMVert **varr;
        BLI_array_fixedstack_declare(varr, BM_NGON_STACK_SIZE, len, __func__);
@@ -1066,7 +1091,7 @@ int BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len)
                return FALSE;
        }
 
-       ok = BM_face_exists_multi(bm, varr, earr, len);
+       ok = BM_face_exists_multi(varr, earr, len);
 
        BLI_array_fixedstack_free(varr);
 
index 567d60eeac6ead5bbdcb7e18f498deaf6470a1af..73d724c7bdd04dc41a3063f53fd1e72db6a5c001 100644 (file)
@@ -62,6 +62,8 @@ void    BM_loop_face_normal(BMLoop *l, float r_normal[3]);
 void    BM_loop_face_tangent(BMLoop *l, float r_tangent[3]);
 
 float   BM_edge_face_angle(BMEdge *e);
+void    BM_edge_face_tangent(BMEdge *e, BMLoop *e_loop, float r_tangent[3]);
+
 float   BM_vert_edge_angle(BMVert *v);
 
 BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2);
@@ -70,8 +72,8 @@ int     BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_exi
 
 int     BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface);
 
-int     BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len);
-int     BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len);
+int     BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len);
+int     BM_face_exists_multi_edge(BMEdge **earr, int len);
 
 int     BM_face_share_edge_count(BMFace *f1, BMFace *f2);
 int     BM_edge_share_face_count(BMEdge *e1, BMEdge *e2);
index cccda674b0fbd0646d022145ad381dc88665b7d8..113e1ddc164971a46458fa02aa31d179e0ae574a 100644 (file)
@@ -115,7 +115,7 @@ static void bmw_ShellWalker_begin(BMWalker *walker, void *data)
                        /* starting the walk at a vert, add all the edges
                         * to the worklist */
                        v = (BMVert *)h;
-                       BM_ITER(e, &eiter, walker->bm, BM_EDGES_OF_VERT, v) {
+                       BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                                bmw_ShellWalker_visitEdge(walker, e);
                        }
                        break;
@@ -151,7 +151,7 @@ static void *bmw_ShellWalker_step(BMWalker *walker)
 
        for (i = 0; i < 2; i++) {
                v = i ? e->v2 : e->v1;
-               BM_ITER(e2, &iter, walker->bm, BM_EDGES_OF_VERT, v) {
+               BM_ITER_ELEM (e2, &iter, v, BM_EDGES_OF_VERT) {
                        bmw_ShellWalker_visitEdge(walker, e2);
                }
        }
@@ -249,7 +249,7 @@ static void *bmw_ConnectedVertexWalker_step(BMWalker *walker)
 
        BMW_state_remove(walker);
 
-       BM_ITER(e, &iter, walker->bm, BM_EDGES_OF_VERT, v) {
+       BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
                v2 = BM_edge_other_vert(e, v);
                if (!BLI_ghash_haskey(walker->visithash, v2)) {
                        bmw_ConnectedVertexWalker_visitVertex(walker, v2);
@@ -450,7 +450,7 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data)
                BMFace *f_iter;
                BMFace *f_best = NULL;
 
-               BM_ITER(f_iter, &iter, walker->bm, BM_FACES_OF_EDGE, e) {
+               BM_ITER_ELEM (f_iter, &iter, e, BM_FACES_OF_EDGE) {
                        if (f_best == NULL || f_best->len < f_iter->len) {
                                f_best = f_iter;
                        }
@@ -606,7 +606,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker)
                for (i = 0; i < 2; i++) {
                        v = i ? e->v2 : e->v1;
 
-                       BM_ITER(nexte, &eiter, walker->bm, BM_EDGES_OF_VERT, v) {
+                       BM_ITER_ELEM (nexte, &eiter, v, BM_EDGES_OF_VERT) {
                                if ((nexte->l == NULL) &&
                                    bmw_mask_check_edge(walker, nexte) &&
                                    !BLI_ghash_haskey(walker->visithash, nexte))
@@ -953,7 +953,7 @@ static void *bmw_UVEdgeWalker_step(BMWalker *walker)
         * mloopuv's coordinates. in addition, push on l->next if necessary */
        for (i = 0; i < 2; i++) {
                cl = i ? nl : l;
-               BM_ITER(l2, &liter, walker->bm, BM_LOOPS_OF_VERT, cl->v) {
+               BM_ITER_ELEM (l2, &liter, cl->v, BM_LOOPS_OF_VERT) {
                        d1 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
                                                          cl->head.data, walker->layer);
                        
index 0165195475a2cd80df7273f4be2c1d53eaeead87..46dd7606940b1534e9a907ec821cda2002eb2a0f 100644 (file)
@@ -53,7 +53,7 @@ typedef struct EdgeTag {
        BMVert *newv1, *newv2;
 } EdgeTag;
 
-static void calc_corner_co(BMesh *bm, BMLoop *l, const float fac, float r_co[3],
+static void calc_corner_co(BMLoop *l, const float fac, float r_co[3],
                            const short do_dist, const short do_even)
 {
        float  no[3], l_vec_prev[3], l_vec_next[3], l_co_prev[3], l_co[3], l_co_next[3], co_ofs[3];
@@ -80,7 +80,7 @@ static void calc_corner_co(BMesh *bm, BMLoop *l, const float fac, float r_co[3],
                copy_v3_v3(l_co_prev, l->prev->v->co);
                copy_v3_v3(l_co, l->v->co);
                
-               BM_ITER(l2, &iter, bm, BM_LOOPS_OF_VERT, l->v) {
+               BM_ITER_ELEM (l2, &iter, l->v, BM_LOOPS_OF_VERT) {
                        if (l2->f != l->f) {
                                copy_v3_v3(l_co_next, BM_edge_other_vert(l2->e, l2->next->v)->co);
                                break;
@@ -207,7 +207,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
        
        BLI_smallhash_init(&hash);
        
-       BMO_ITER(e, &siter, bm, op, "geom", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) {
                BMO_elem_flag_enable(bm, e, BEVEL_FLAG|BEVEL_DEL);
                BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG|BEVEL_DEL);
                BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG|BEVEL_DEL);
@@ -228,14 +228,14 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
 #endif
        }
        
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                BMO_elem_flag_enable(bm, v, VERT_OLD);
        }
 
 #if 0
        //a bit of cleaner code that, alas, doens't work.
        /* build edge tag */
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(bm, e->v1, BEVEL_FLAG) || BMO_elem_flag_test(bm, e->v2, BEVEL_FLAG)) {
                        BMIter liter;
                        BMLoop *l;
@@ -247,14 +247,14 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                                BMO_elem_flag_enable(bm, e, EDGE_OLD);
                        }
                        
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_EDGE, e) {
+                       BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
                                BMLoop *l2;
                                BMIter liter2;
                                
                                if (BMO_elem_flag_test(bm, l->f, BEVEL_FLAG))
                                        continue;
 
-                               BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, l->f) {
+                               BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) {
                                        BM_elem_index_set(l2, BLI_array_count(tags)); /* set_loop */
                                        BLI_array_growone(tags);
 
@@ -277,7 +277,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
 #endif
        
        /* create and assign looptag structure */
-       BMO_ITER(e, &siter, bm, op, "geom", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) {
                BMLoop *l;
                BMIter liter;
 
@@ -299,7 +299,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                
                /* find all faces surrounding e->v1 and, e->v2 */
                for (i = 0; i < 2; i++) {
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, i ? e->v2:e->v1) {
+                       BM_ITER_ELEM (l, &liter, i ? e->v2:e->v1, BM_LOOPS_OF_VERT) {
                                BMLoop *l2;
                                BMIter liter2;
                                
@@ -308,7 +308,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                                        continue;
                                
                                /* create tags for all loops in l-> */
-                               BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, l->f) {
+                               BM_ITER_ELEM (l2, &liter2, l->f, BM_LOOPS_OF_FACE) {
                                        BLI_array_growone(tags);
                                        BM_elem_index_set(l2, BLI_array_count(tags) - 1); /* set_loop */
                                        
@@ -329,13 +329,13 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
 
        bm->elem_index_dirty |= BM_EDGE;
        
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                BMIter eiter;
                
                if (!BMO_elem_flag_test(bm, v, BEVEL_FLAG))
                        continue;
                
-               BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+               BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                        if (!BMO_elem_flag_test(bm, e, BEVEL_FLAG) && !ETAG_GET(e, v)) {
                                BMVert *v2;
                                float co[3];
@@ -364,13 +364,13 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                
                BMO_elem_flag_enable(bm, faces[i], FACE_OLD);
                
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, faces[i]) {
+               BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) {
                        float co[3];
 
                        if (BMO_elem_flag_test(bm, l->e, BEVEL_FLAG)) {
                                if (BMO_elem_flag_test(bm, l->prev->e, BEVEL_FLAG)) {
                                        tag = tags + BM_elem_index_get(l);
-                                       calc_corner_co(bm, l, fac, co, do_dist, do_even);
+                                       calc_corner_co(l, fac, co, do_dist, do_even);
                                        tag->newv = BM_vert_create(bm, co, l->v);
                                }
                                else {
@@ -438,7 +438,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                BLI_array_empty(verts);
                BLI_array_empty(edges);
                
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, faces[i]) {
+               BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) {
                        BMVert *v2;
                        
                        tag = tags + BM_elem_index_get(l);
@@ -489,7 +489,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                int j;
                
                /* create quad spans between split edge */
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, faces[i]) {
+               BM_ITER_ELEM (l, &liter, faces[i], BM_LOOPS_OF_FACE) {
                        BMVert *v1 = NULL, *v2 = NULL, *v3 = NULL, *v4 = NULL;
                        
                        if (!BMO_elem_flag_test(bm, l->e, BEVEL_FLAG))
@@ -516,7 +516,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                                        BMIter eiter;
                                        BMVert *v = j ? v4 : v3;
 
-                                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+                                       BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                                                if (!BM_vert_in_edge(e, v3) || !BM_vert_in_edge(e, v4))
                                                        continue;
                                                
@@ -600,7 +600,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                                BMO_elem_flag_enable(bm, f, FACE_NEW|FACE_SPAN);
                                
                                /* un-tag edges in f for deletio */
-                               BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, f) {
+                               BM_ITER_ELEM (l2, &liter2, f, BM_LOOPS_OF_FACE) {
                                        BMO_elem_flag_disable(bm, l2->e, BEVEL_DEL);
                                }
                        }
@@ -611,7 +611,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
        }
        
        /* fill in holes at vertices */
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                BMIter eiter;
                BMVert *vv, *vstart = NULL, *lastv = NULL;
                SmallHash tmphash;
@@ -625,7 +625,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                BLI_array_empty(verts);
                BLI_array_empty(edges);
                
-               BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+               BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                        BMIter liter;
                        BMVert *v1 = NULL, *v2 = NULL;
                        BMLoop *l;
@@ -637,7 +637,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                                continue;
                        
                        rad = 0;
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_EDGE, e) {
+                       BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
                                if (!BMO_elem_flag_test(bm, l->f, FACE_OLD))
                                        continue;
                                
@@ -685,7 +685,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                vstart = vstart ? vstart : verts[0];
                vv = vstart;
                do {
-                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, vv) {
+                       BM_ITER_ELEM (e, &eiter, vv, BM_EDGES_OF_VERT) {
                                BMVert *vv2 = BM_edge_other_vert(e, vv);
                                
                                if (vv2 != lastv && BLI_smallhash_haskey(&tmphash, (intptr_t)vv2)) {
@@ -730,7 +730,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                        lastv = NULL;
                        BLI_array_empty(edges);
                        do {
-                               BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, vv) {
+                               BM_ITER_ELEM (e, &eiter, vv, BM_EDGES_OF_VERT) {
                                        BMVert *vv2 = BM_edge_other_vert(e, vv);
                                        
                                        if (vv2 != lastv && BLI_smallhash_haskey(&tmphash, (intptr_t)vv2)) {
@@ -787,7 +787,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                BMIter liter;
                BMFace *f = faces[i];
                
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        BMLoop *l2;
                        BMIter liter2;
                        
@@ -795,7 +795,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                        if (!tag->newv)
                                continue;
                        
-                       BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_VERT, tag->newv) {
+                       BM_ITER_ELEM (l2, &liter2, tag->newv, BM_LOOPS_OF_VERT) {
                                if (!BMO_elem_flag_test(bm, l2->f, FACE_NEW) || (l2->v != tag->newv && l2->v != l->v))
                                        continue;
                                
@@ -812,7 +812,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                                        BMLoop *l3;
                                        BMIter liter3;
                                        
-                                       BM_ITER(l3, &liter3, bm, BM_LOOPS_OF_FACE, l2->f) {
+                                       BM_ITER_ELEM (l3, &liter3, l2->f, BM_LOOPS_OF_FACE) {
                                                BM_loop_interp_multires(bm, l3, l->f);
                                        }
                                }
@@ -821,7 +821,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
        }
        
        /* handle vertices along boundary edge */
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(bm, v, VERT_OLD) &&
                    BMO_elem_flag_test(bm, v, BEVEL_FLAG) &&
                    !BMO_elem_flag_test(bm, v, BEVEL_DEL))
@@ -830,7 +830,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                        BMLoop *lorig = NULL;
                        BMIter liter;
                        
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) {
+                       BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
                                // BMIter liter2;
                                // BMLoop *l2 = l->v == v ? l : l->next, *l3;
                                
@@ -843,7 +843,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                        if (!lorig)
                                continue;
                        
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v) {
+                       BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
                                BMLoop *l2 = l->v == v ? l : l->next;
                                
                                BM_elem_attrs_copy(bm, bm, lorig->f, l2->f);
@@ -853,7 +853,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
        }
 #if 0
        /* clean up any remaining 2-edged face */
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                if (f->len == 2) {
                        BMFace *faces[2] = {f, BM_FACE_FIRST_LOOP(f)->radial_next->f};
                        
@@ -868,7 +868,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
        BMO_op_callf(bm, "del geom=%fv context=%i", BEVEL_DEL, DEL_VERTS);
 
        /* clean up any edges that might not get properly delete */
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(bm, e, EDGE_OLD) && !e->l)
                        BMO_elem_flag_enable(bm, e, BEVEL_DEL);
        }
index 69a9b75b258cbca723540d752e6019c596888443..3c1f10be4c40d1643172dc267862a9ce7f1a9e62 100644 (file)
@@ -135,7 +135,7 @@ static BMVert *get_outer_vert(BMesh *bm, BMEdge *e)
        int i;
 
        i = 0;
-       BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, e->v1) {
+       BM_ITER_ELEM (e2, &iter, e->v1, BM_EDGES_OF_VERT) {
                if (BMO_elem_flag_test(bm, e2, EDGE_MARK)) {
                        i++;
                }
@@ -191,7 +191,7 @@ static void bm_vert_loop_pair(BMesh *bm, BMVert *v1, BMVert *v2, BMLoop **l1, BM
        if ((v1->e && v1->e->l) &&
            (v2->e && v2->e->l))
        {
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, v1) {
+               BM_ITER_ELEM (l, &liter, v1, BM_LOOPS_OF_VERT) {
                        if (l->prev->v == v2) {
                                *l1 = l;
                                *l2 = l->prev;
@@ -225,7 +225,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
 
        BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK);
 
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                if (!BMO_elem_flag_test(bm, e, EDGE_DONE)) {
                        BMVert *v, *ov;
                        /* BMEdge *e2, *e3, *oe = e; */ /* UNUSED */
@@ -241,7 +241,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
                        do {
                                v = BM_edge_other_vert(e2, v);
                                nexte = NULL;
-                               BM_ITER(e3, &iter, bm, BM_EDGES_OF_VERT, v) {
+                               BM_ITER_ELEM (e3, &iter, v, BM_EDGES_OF_VERT) {
                                        if (e3 != e2 && BMO_elem_flag_test(bm, e3, EDGE_MARK)) {
                                                if (nexte == NULL) {
                                                        nexte = e3;
@@ -278,7 +278,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
                                BMO_elem_flag_enable(bm, e2, EDGE_DONE);
                                
                                v = BM_edge_other_vert(e2, v);
-                               BM_ITER(e3, &iter, bm, BM_EDGES_OF_VERT, v) {
+                               BM_ITER_ELEM (e3, &iter, v, BM_EDGES_OF_VERT) {
                                        if (e3 != e2 && BMO_elem_flag_test(bm, e3, EDGE_MARK) && !BMO_elem_flag_test(bm, e3, EDGE_DONE)) {
                                                break;
                                        }
index bf34806ee26cdc3a22443ee31dfadc2542c66fd7..d02bb14bebfa0fc202c97d2ca086ee51dbe6c00b 100644 (file)
@@ -225,7 +225,7 @@ static int UNUSED_FUNCTION(rotsys_fill_faces)(BMesh *bm, EdgeData *edata, VertDa
        SmallHash visithash, *hash = &visithash;
        int i;
        
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                BMEdge *e2, *starte;
                BMVert *startv;
                int rad, ok;
@@ -366,7 +366,7 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
        
 #define SIGN(n) ((n)<0.0f)
        
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                BMIter eiter;
                float no[3], cent[3];
                int j, k = 0, totedge = 0;
@@ -376,7 +376,7 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
                
                BLI_array_empty(edges);
                
-               BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+               BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                        if (BMO_elem_flag_test(bm, e, EDGE_MARK)) {
                                BLI_array_append(edges, e);
                                totedge++;
@@ -581,7 +581,7 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata)
 #if 0
        /* create visualizing geometr */
        BMVert *lastv;
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                BMVert *v2;
                BMFace *f;
                int totedge = BM_vert_edge_count(v);
@@ -915,12 +915,12 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
        
        BM_mesh_elem_index_ensure(bm, BM_VERT);
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                BMO_elem_flag_enable(bm, f, ELE_ORIG);
        }
 
        i = 0;
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                BM_elem_index_set(e, i); /* set_inline */
                
                if (!BMO_elem_flag_test(bm, e, EDGE_MARK)) {
@@ -937,7 +937,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
                edge = NULL;
                group = 0;
                
-               BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+               BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                        /* if restrict is on, only start on faces in the restrict map */
                        if (use_restrict && !BMO_slot_map_contains(bm, op, "restrict", e))
                                continue;
@@ -1043,7 +1043,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
 
                        if ((use_fill_check == FALSE) ||
                            /* fairly expensive check - see if there are already faces filling this area */
-                           (BM_face_exists_multi_edge(bm, edges, i) == FALSE))
+                           (BM_face_exists_multi_edge(edges, i) == FALSE))
                        {
                                f = BM_face_create_ngon(bm, v1, v2, edges, i, TRUE);
                                if (f && !BMO_elem_flag_test(bm, f, ELE_ORIG)) {
@@ -1076,7 +1076,7 @@ static BMEdge *edge_next(BMesh *bm, BMEdge *e)
        int i;
 
        for (i = 0; i < 2; i++) {
-               BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, i ? e->v2 : e->v1) {
+               BM_ITER_ELEM (e2, &iter, i ? e->v2 : e->v1, BM_EDGES_OF_VERT) {
                        if ((BMO_elem_flag_test(bm, e2, EDGE_MARK)) &&
                            (!BMO_elem_flag_test(bm, e2, EDGE_VIS)) &&
                            (e2 != e))
@@ -1104,7 +1104,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
        
        /* validate that each edge has at most one other tagged edge in the
         * disk cycle around each of it's vertices */
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                for (i = 0; i < 2; i++) {
                        count = BMO_vert_edge_flags_count(bm, i ? e->v2 : e->v1, EDGE_MARK);
                        if (count > 2) {
@@ -1126,7 +1126,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
        /* find connected loops within the input edge */
        count = 0;
        while (1) {
-               BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+               BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                        if (!BMO_elem_flag_test(bm, e, EDGE_VIS)) {
                                if (BMO_vert_edge_flags_count(bm, e->v1, EDGE_MARK) == 1 ||
                                    BMO_vert_edge_flags_count(bm, e->v2, EDGE_MARK) == 1)
@@ -1280,7 +1280,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
        const short mat_nr = BMO_slot_int_get(op, "mat_nr");
 
        /* count number of each element type we were passe */
-       BMO_ITER(h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) {
+       BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) {
                switch (h->htype) {
                        case BM_VERT: totv++; break;
                        case BM_EDGE: tote++; break;
@@ -1314,10 +1314,10 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
                int ok = TRUE;
 
 
-               BMO_ITER(v, &oiter, bm, op, "geom", BM_VERT) {
+               BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) {
                        /* count how many flagged edges this vertex uses */
                        int tot_edges = 0;
-                       BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) {
+                       BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
                                if (BMO_elem_flag_test(bm, e, ELE_NEW)) {
                                        tot_edges++;
                                        if (tot_edges > 2) {
@@ -1392,7 +1392,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
 
        /* now, count how many verts we have */
        amount = 0;
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(bm, v, ELE_NEW)) {
                        verts[amount] = v;
                        amount++;
@@ -1459,7 +1459,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
                BMVert **vert_arr = MEM_mallocN(sizeof(BMVert **) * totv, __func__);
                int i = 0;
 
-               BMO_ITER(v, &oiter, bm, op, "geom", BM_VERT) {
+               BMO_ITER (v, &oiter, bm, op, "geom", BM_VERT) {
                        vert_arr[i] = v;
                        i++;
                }
index 88b8eef0fbf0e3f33845d7999cb3e6918855aeeb..f0e8ad81d0768cb31d7cecee682f498dfea5b459 100644 (file)
@@ -93,7 +93,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
                BMIter viter;
                BMVert *v;
 
-               BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                        BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2));
                }
        }
@@ -101,7 +101,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
        BMO_slot_buffer_flag_enable(bm, op, "faces", BM_FACE, FACE_MARK);
        
        /* collect region */
-       BMO_ITER(f, &oiter, bm, op, "faces", BM_FACE) {
+       BMO_ITER (f, &oiter, bm, op, "faces", BM_FACE) {
 
                if (!BMO_elem_flag_test(bm, f, FACE_MARK)) {
                        continue;
@@ -171,7 +171,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
                BMIter viter;
                BMVert *v;
 
-               BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                        if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
                                if (BM_vert_edge_count(v) == 2) {
                                        BM_vert_collapse_edge(bm, v->e, v, TRUE);
@@ -208,7 +208,7 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op)
        int i;
 
 
-       BMO_ITER(e, &oiter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &oiter, bm, op, "edges", BM_EDGE) {
                if (BM_edge_face_pair(e, &fa, &fb)) {
                        BMO_elem_flag_enable(bm, e->v1, VERT_MARK);
                        BMO_elem_flag_enable(bm, e->v2, VERT_MARK);
@@ -219,7 +219,7 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op)
                }
        }
 
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(bm, v, VERT_MARK) && BM_vert_edge_count(v) == 2) {
                        BLI_array_append(verts, v);
                }
@@ -257,12 +257,12 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
        int use_verts = BMO_slot_bool_get(op, "use_verts");
 
        if (use_verts) {
-               BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                        BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2));
                }
        }
 
-       BMO_ITER(e, &eiter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &eiter, bm, op, "edges", BM_EDGE) {
                BMFace *fa, *fb;
 
                if (BM_edge_face_pair(e, &fa, &fb)) {
@@ -276,7 +276,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
        }
 
        if (use_verts) {
-               BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+               BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                        if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
                                if (BM_vert_edge_count(v) == 2) {
                                        BM_vert_collapse_edge(bm, v->e, v, TRUE);
@@ -554,7 +554,7 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
 
                                /* there may be some errors, we don't mind, just move on */
                                if (nf) {
-                                       BM_face_normal_update(bm, nf);
+                                       BM_face_normal_update(nf);
                                }
                                else {
                                        BMO_error_clear(bm);
@@ -604,7 +604,7 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
                                BMEdge *ne = BM_vert_collapse_edge(bm, v->e, v, TRUE); /* join edges */
 
                                if (ne && ne->l) {
-                                       BM_edge_normals_update(bm, ne);
+                                       BM_edge_normals_update(ne);
                                }
                        }
                }
index 24e25ef720f3f5adc8c9c22e04323cce2d9e585c..36d446a0a8c47ba2357e232b087a54683e9edf51 100644 (file)
@@ -163,8 +163,8 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh,
        BMO_elem_flag_enable(target_mesh, target_face, DUPE_NEW);
        
        /* copy per-loop custom data */
-       BM_ITER(source_loop, &iter, source_mesh, BM_LOOPS_OF_FACE, source_face) {
-               BM_ITER(target_loop, &iter2, target_mesh, BM_LOOPS_OF_FACE, target_face) {
+       BM_ITER_ELEM (source_loop, &iter, source_face, BM_LOOPS_OF_FACE) {
+               BM_ITER_ELEM (target_loop, &iter2, target_face, BM_LOOPS_OF_FACE) {
                        if (BLI_ghash_lookup(vhash, source_loop->v) == target_loop->v) {
                                BM_elem_attrs_copy(source_mesh, target_mesh, source_loop, target_loop);
                                break;
@@ -201,7 +201,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
        ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops e");
 
        /* duplicate flagged vertices */
-       BM_ITER(v, &viter, source, BM_VERTS_OF_MESH, source) {
+       BM_ITER_MESH (v, &viter, source, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(source, v, DUPE_INPUT) &&
                    !BMO_elem_flag_test(source, v, DUPE_DONE))
                {
@@ -210,7 +210,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
 
                        v2 = copy_vertex(source, v, target, vhash);
 
-                       BM_ITER(f, &iter, source, BM_FACES_OF_VERT, v) {
+                       BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) {
                                if (BMO_elem_flag_test(source, f, DUPE_INPUT)) {
                                        isolated = 0;
                                        break;
@@ -218,7 +218,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
                        }
 
                        if (isolated) {
-                               BM_ITER(e, &iter, source, BM_EDGES_OF_VERT, v) {
+                               BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
                                        if (BMO_elem_flag_test(source, e, DUPE_INPUT)) {
                                                isolated = 0;
                                                break;
@@ -235,7 +235,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
        }
 
        /* now we dupe all the edges */
-       BM_ITER(e, &eiter, source, BM_EDGES_OF_MESH, source) {
+       BM_ITER_MESH (e, &eiter, source, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(source, e, DUPE_INPUT) &&
                    !BMO_elem_flag_test(source, e, DUPE_DONE))
                {
@@ -255,10 +255,10 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
        }
 
        /* first we dupe all flagged faces and their elements from source */
-       BM_ITER(f, &fiter, source, BM_FACES_OF_MESH, source) {
+       BM_ITER_MESH (f, &fiter, source, BM_FACES_OF_MESH) {
                if (BMO_elem_flag_test(source, f, DUPE_INPUT)) {
                        /* vertex pass */
-                       BM_ITER(v, &viter, source, BM_VERTS_OF_FACE, f) {
+                       BM_ITER_ELEM (v, &viter, f, BM_VERTS_OF_FACE) {
                                if (!BMO_elem_flag_test(source, v, DUPE_DONE)) {
                                        copy_vertex(source, v, target, vhash);
                                        BMO_elem_flag_enable(source, v, DUPE_DONE);
@@ -266,7 +266,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target)
                        }
 
                        /* edge pass */
-                       BM_ITER(e, &eiter, source, BM_EDGES_OF_FACE, f) {
+                       BM_ITER_ELEM (e, &eiter, f, BM_EDGES_OF_FACE) {
                                if (!BMO_elem_flag_test(source, e, DUPE_DONE)) {
                                        copy_edge(op, source, e, target, vhash, ehash);
                                        BMO_elem_flag_enable(source, e, DUPE_DONE);
index 557860e1056466e70be816a401a911fad12f89d8..ccbcb2939151358e86bb2d2f9b448b614c4f503a 100644 (file)
@@ -60,7 +60,7 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op)
        vtouch = MEM_callocN(sizeof(char) * bm->totvert, __func__);
 
        /* tag all boundary verts so as not to untag an edge which is inbetween only 2 faces [] */
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
 
                /* unrelated to flag assignment in this function - since this is the
                 * only place we loop over all edges, disable tag */
@@ -81,14 +81,14 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op)
 
        /* single marked edges unconnected to any other marked edges
         * are illegal, go through and unmark them */
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                /* lame, but we don't want the count to exceed 255,
                 * so just count to 2, its all we need */
                unsigned char *vt;
                vt = &vtouch[BM_elem_index_get(e->v1)]; if (*vt < 2) (*vt)++;
                vt = &vtouch[BM_elem_index_get(e->v2)]; if (*vt < 2) (*vt)++;
        }
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                if (vtouch[BM_elem_index_get(e->v1)] == 1 &&
                    vtouch[BM_elem_index_get(e->v2)] == 1)
                {
@@ -118,7 +118,7 @@ void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
                 * This is needed so we don't split off the edge but then none of its verts which
                 * would leave a duplicate edge.
                 */
-               BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+               BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                        if (UNLIKELY((BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE &&
                                      (BMO_elem_flag_test(bm, e->v2, VERT_SEAM) == FALSE))))
                        {
@@ -130,19 +130,23 @@ void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
 
        bm_edgesplit_validate_seams(bm, op);
 
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) {
                        /* this flag gets copied so we can be sure duplicate edges get it too (important) */
                        BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG);
 
-                       bmesh_edge_separate(bm, e, e->l);
+                       /* keep splitting until each loop has its own edge */
+                       do {
+                               bmesh_edge_separate(bm, e, e->l);
+                       } while (!BM_edge_is_boundary(e));
+
                        BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
                        BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
                }
        }
 
        if (use_verts) {
-               BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+               BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                        if (BMO_elem_flag_test(bm, e->v1, VERT_SEAM) == FALSE) {
                                BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
                        }
@@ -152,7 +156,7 @@ void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
                }
        }
 
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                if (BMO_elem_flag_test(bm, e, EDGE_SEAM)) {
                        if (BM_elem_flag_test(e->v1, BM_ELEM_TAG)) {
                                BM_elem_flag_disable(e->v1, BM_ELEM_TAG);
index b716f92d31cf9904d8b53de611e66ad9163d342b..73997c774afe9cf1fe6870b770fc9396a64d255f 100644 (file)
@@ -56,13 +56,13 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
        BLI_array_declare(edges);
        int i;
 
-       BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) {
+       BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
                BLI_array_empty(edges);
                BLI_array_growitems(edges, f->len);
 
                i = 0;
                firstv = lastv = NULL;
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        v = BM_vert_create(bm, l->v->co, l->v);
 
                        /* skip on the first iteration */
@@ -93,7 +93,7 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
                BM_elem_attrs_copy(bm, bm, f, f2);
 
                l2 = BM_iter_new(&liter2, bm, BM_LOOPS_OF_FACE, f2);
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        BM_elem_attrs_copy(bm, bm, l, l2);
 
                        l3 = l->next;
@@ -118,39 +118,53 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
        BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP);
 }
 
-static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e, BMEdge *newedge)
+/**
+ * \brief Copy the loop pair from an adjacent face to both sides of this quad.
+ *
+ * The face is assumed to be a quad, created by extruding.
+ * This function won't crash if its not but won't work right either.
+ * \a e_b is the new edge.
+ *
+ * \note this function could be exposed as an api call if other areas need it,
+ * so far only extrude does.
+ */
+static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e_a, BMEdge *e_b)
 {
        /* 'a' is the starting edge #e, 'b' is the final edge #newedge */
-       BMLoop *l_dst_a = BM_face_edge_share_loop(f, e);
-       BMLoop *l_dst_b = newedge->l; /* will only ever be one loop */
-       BMLoop *l_src_a = l_dst_a->radial_next;
+       BMLoop *l_dst_a = BM_face_edge_share_loop(f, e_a);
+       BMLoop *l_dst_b = BM_face_edge_share_loop(f, e_b);
+       /* we could only have a face on one-or the other edges,
+        * chech if either side of the face has an adjacent face */
+       BMLoop *l_src_1;
+       BMLoop *l_src_2;
+
        /* there is no l_src_b */
 
        /* sanity */
-       BLI_assert(l_src_a->f != l_dst_a->f);
        BLI_assert(l_dst_a->f == l_dst_b->f);
 
+       if (l_dst_a != l_dst_a->radial_next) {
+               l_src_1 = l_dst_a->radial_next;
+               l_src_2 = l_src_1->next;
+       }
+       else if (l_dst_b != l_dst_b->radial_next) {
+               l_src_2 = l_dst_b->radial_next;
+               l_src_1 = l_src_2->next;
+       }
+       else {
+               /* no new faces on either edge, nothing to copy from */
+               return;
+       }
 
-       BM_elem_attrs_copy(bm, bm, l_src_a->f, l_dst_a->f);
+       BM_elem_attrs_copy(bm, bm, l_src_1->f, l_dst_a->f);
        BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */
 
-
        /* copy data */
-       if (l_src_a->v == l_dst_a->v) {
-               BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_a);
-               BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_b->next);
-
-               BM_elem_attrs_copy(bm, bm, l_src_a->next, l_dst_a->next);
-               BM_elem_attrs_copy(bm, bm, l_src_a->next, l_dst_b);
-       }
-       else {
-               l_src_a = l_src_a->next;
-               BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_a);
-               BM_elem_attrs_copy(bm, bm, l_src_a, l_dst_b->next);
+       BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_a);
+       BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_b->next);
 
-               BM_elem_attrs_copy(bm, bm, l_src_a->prev, l_dst_a->next);
-               BM_elem_attrs_copy(bm, bm, l_src_a->prev, l_dst_b);
-       }
+       BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_a->next);
+       BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_b);
 }
 
 void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
@@ -161,7 +175,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op)
        BMEdge *e, *e2;
        BMFace *f;
        
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                BMO_elem_flag_enable(bm, e, EXT_INPUT);
                BMO_elem_flag_enable(bm, e->v1, EXT_INPUT);
                BMO_elem_flag_enable(bm, e->v2, EXT_INPUT);
@@ -244,7 +258,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
        /* if one flagged face is bordered by an un-flagged face, then we delete
         * original geometry unless caller explicitly asked to keep it. */
        if (!BMO_slot_bool_get(op, "alwayskeeporig")) {
-               BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+               BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
 
                        int edge_face_tot;
 
@@ -255,7 +269,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
                        found = FALSE; /* found a face that isn't input? */
                        edge_face_tot = 0; /* edge/face count */
 
-                       BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) {
+                       BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) {
                                if (!BMO_elem_flag_test(bm, f, EXT_INPUT)) {
                                        found = TRUE;
                                        delorig = TRUE;
@@ -273,10 +287,10 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
        }
 
        /* calculate verts to delete */
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                found = FALSE;
 
-               BM_ITER(e, &viter, bm, BM_EDGES_OF_VERT, v) {
+               BM_ITER_ELEM (e, &viter, v, BM_EDGES_OF_VERT) {
                        if (!BMO_elem_flag_test(bm, e, EXT_INPUT) || !BMO_elem_flag_test(bm, e, EXT_DEL)) {
                                found = TRUE;
                                break;
@@ -285,7 +299,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
 
                /* avoid an extra loop */
                if (found == TRUE) {
-                       BM_ITER(f, &viter, bm, BM_FACES_OF_VERT, v) {
+                       BM_ITER_ELEM (f, &viter, v, BM_FACES_OF_VERT) {
                                if (!BMO_elem_flag_test(bm, f, EXT_INPUT)) {
                                        found = TRUE;
                                        break;
@@ -298,7 +312,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
                }
        }
        
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                if (BMO_elem_flag_test(bm, f, EXT_INPUT)) {
                        BMO_elem_flag_enable(bm, f, EXT_DEL);
                }
@@ -321,7 +335,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
        
        /* if not delorig, reverse loops of original face */
        if (!delorig) {
-               BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+               BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                        if (BMO_elem_flag_test(bm, f, EXT_INPUT)) {
                                BM_face_normal_flip(bm, f);
                        }
@@ -404,18 +418,18 @@ static void calc_solidify_normals(BMesh *bm)
        /* can't use BM_edge_face_count because we need to count only marked faces */
        int *edge_face_count = MEM_callocN(sizeof(int) * bm->totedge, __func__);
 
-       BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                BM_elem_flag_enable(v, BM_ELEM_TAG);
        }
 
        BM_mesh_elem_index_ensure(bm, BM_EDGE);
 
-       BM_ITER(f, &fiter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
                if (!BMO_elem_flag_test(bm, f, FACE_MARK)) {
                        continue;
                }
 
-               BM_ITER(e, &eiter, bm, BM_EDGES_OF_FACE, f) {
+               BM_ITER_ELEM (e, &eiter, f, BM_EDGES_OF_FACE) {
 
                        /* And mark all edges and vertices on the
                         * marked faces */
@@ -426,7 +440,7 @@ static void calc_solidify_normals(BMesh *bm)
                }
        }
 
-       BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
                if (!BMO_elem_flag_test(bm, e, EDGE_MARK)) {
                        continue;
                }
@@ -444,7 +458,7 @@ static void calc_solidify_normals(BMesh *bm)
        MEM_freeN(edge_face_count);
        edge_face_count = NULL; /* don't re-use */
 
-       BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                if (!BM_vert_is_manifold(v)) {
                        BMO_elem_flag_enable(bm, v, VERT_NONMAN);
                        continue;
@@ -455,7 +469,7 @@ static void calc_solidify_normals(BMesh *bm)
                }
        }
 
-       BM_ITER(e, &eiter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
 
                /* If the edge is not part of a the solidify region
                 * its normal should not be considered */
@@ -471,7 +485,7 @@ static void calc_solidify_normals(BMesh *bm)
 
                f1 = f2 = NULL;
 
-               BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) {
+               BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) {
                        if (BMO_elem_flag_test(bm, f, FACE_MARK)) {
                                if (f1 == NULL) {
                                        f1 = f;
@@ -516,19 +530,19 @@ static void calc_solidify_normals(BMesh *bm)
        }
 
        /* normalize accumulated vertex normal */
-       BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                if (!BMO_elem_flag_test(bm, v, VERT_MARK)) {
                        continue;
                }
 
                if (BMO_elem_flag_test(bm, v, VERT_NONMAN)) {
                        /* use standard normals for vertices connected to non-manifold edges */
-                       BM_vert_normal_update(bm, v);
+                       BM_vert_normal_update(v);
                }
                else if (normalize_v3(v->no) == 0.0f && !BM_elem_flag_test(v, BM_ELEM_TAG)) {
                        /* exceptional case, totally flat. use the normal
                         * of any marked face around the vertex */
-                       BM_ITER(f, &fiter, bm, BM_FACES_OF_VERT, v) {
+                       BM_ITER_ELEM (f, &fiter, v, BM_FACES_OF_VERT) {
                                if (BMO_elem_flag_test(bm, f, FACE_MARK)) {
                                        break;
                                }
@@ -557,13 +571,13 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
 
        BM_mesh_elem_index_ensure(bm, BM_VERT);
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                if (!BMO_elem_flag_test(bm, f, FACE_MARK)) {
                        continue;
                }
 
                BLI_array_growitems(verts, f->len);
-               BM_ITER_INDEX(l, &loopIter, bm, BM_LOOPS_OF_FACE, f, i) {
+               BM_ITER_ELEM_INDEX (l, &loopIter, f, BM_LOOPS_OF_FACE, i) {
                        verts[i] = l->v->co;
                }
 
@@ -571,7 +585,7 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
                angle_poly_v3(face_angles, (const float **)verts, f->len);
 
                i = 0;
-               BM_ITER(l, &loopIter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &loopIter, f, BM_LOOPS_OF_FACE) {
                        v = l->v;
                        index = BM_elem_index_get(v);
                        vert_accum[index] += face_angles[i];
@@ -583,7 +597,7 @@ static void solidify_add_thickness(BMesh *bm, const float dist)
                BLI_array_empty(face_angles);
        }
 
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                index = BM_elem_index_get(v);
                if (vert_accum[index]) { /* zero if unselected */
                        madd_v3_v3fl(v->co, v->no, dist * (vert_angles[index] / vert_accum[index]));
index 3bfacb2919775b3277062461d51aef0932c5b69d..4e4ea655414eddb4fab0cf94169b56c59552428b 100644 (file)
@@ -42,17 +42,6 @@ typedef struct SplitEdgeInfo {
        BMLoop *l;
 } SplitEdgeInfo;
 
-static void edge_loop_tangent(BMEdge *e, BMLoop *e_loop, float r_no[3])
-{
-       float tvec[3];
-       BMVert *v1, *v2;
-       BM_edge_ordered_verts_ex(e, &v1, &v2, e_loop);
-
-       sub_v3_v3v3(tvec, v1->co, v2->co); /* use for temp storage */
-       cross_v3_v3v3(r_no, tvec, e_loop->f->no);
-       normalize_v3(r_no);
-}
-
 /**
  * return the tag loop where there is...
  * - only 1 tagged face attached to this edge.
@@ -133,7 +122,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
 
        /* first count all inset edges we will split */
        /* fill in array and initialize tagging */
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (
                    /* tag if boundary is enabled */
                    (use_boundary && BM_edge_is_boundary(e) && BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) ||
@@ -163,7 +152,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
 
        /* fill in array and initialize tagging */
        es = edge_info;
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                i = BM_elem_index_get(e);
                if (i != -1) {
                        /* calc edge-split info */
@@ -188,7 +177,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
 
                /* calc edge-split info */
                es->e_new = es->l->e;
-               edge_loop_tangent(es->e_new, es->l, es->no);
+               BM_edge_face_tangent(es->e_new, es->l, es->no);
 
                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 */
@@ -257,7 +246,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
                                        int vecpair[2];
 
                                        /* find adjacent */
-                                       BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v_split) {
+                                       BM_ITER_ELEM (e, &iter, v_split, BM_EDGES_OF_VERT) {
                                                if (BM_elem_flag_test(e, BM_ELEM_TAG) &&
                                                    e->l && BM_elem_flag_test(e->l->f, BM_ELEM_TAG))
                                                {
@@ -422,7 +411,7 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op)
                                        if (r_vout_len > 2) {
                                                int ok = TRUE;
                                                /* last step, NULL this vertex if has a tagged face */
-                                               BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, v_split) {
+                                               BM_ITER_ELEM (f, &iter, v_split, BM_FACES_OF_VERT) {
                                                        if (BM_elem_flag_test(f, BM_ELEM_TAG)) {
                                                                ok = FALSE;
                                                                break;
index 01028116da36eaa4bc1d439dbd2d53061a751b48..582039fc1a2600afb48ce41957c1eb93a295f59a 100644 (file)
@@ -43,7 +43,7 @@
 #define T2QJOIN                4
 
 /* assumes edges are validated before reaching this poin */
-static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2,
+static float measure_facepair(BMVert *v1, BMVert *v2,
                               BMVert *v3, BMVert *v4, float limit)
 {
        /* gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would make */
@@ -237,15 +237,15 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
        int i, totedge;
 
        /* flag all edges of all input face */
-       BMO_ITER(f1, &siter, bm, op, "faces", BM_FACE) {
+       BMO_ITER (f1, &siter, bm, op, "faces", BM_FACE) {
                BMO_elem_flag_enable(bm, f1, FACE_INPUT);
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f1) {
+               BM_ITER_ELEM (l, &liter, f1, BM_LOOPS_OF_FACE) {
                        BMO_elem_flag_enable(bm, l->e, EDGE_MARK);
                }
        }
 
        /* unflag edges that are invalid; e.g. aren't surrounded by triangle */
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (!BMO_elem_flag_test(bm, e, EDGE_MARK))
                        continue;
 
@@ -266,7 +266,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
        }
        
        i = 0;
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                BMVert *v1, *v2, *v3, *v4;
                BMFace *f1, *f2;
                float measure;
@@ -291,7 +291,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
                if (domat && f1->mat_nr != f2->mat_nr)
                        continue;
 
-               measure = measure_facepair(bm, v1, v2, v3, v4, limit);
+               measure = measure_facepair(v1, v2, v3, v4, limit);
                if (measure < limit) {
                        BLI_array_growone(jedges);
 
@@ -323,7 +323,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
                BMO_elem_flag_enable(bm, e, EDGE_CHOSEN);
        }
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (!BMO_elem_flag_test(bm, e, EDGE_CHOSEN))
                        continue;
 
@@ -332,7 +332,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
                BM_faces_join_pair(bm, f1, f2, e, TRUE);
        }
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(bm, e, EDGE_MARK)) {
                        /* ok, this edge wasn't merged, check if it's
                         * in a 2-tri-pair island, and if so merg */
@@ -344,7 +344,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op)
                                continue;
 
                        for (i = 0; i < 2; i++) {
-                               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, i ? f2 : f1) {
+                               BM_ITER_ELEM (l, &liter, i ? f2 : f1, BM_LOOPS_OF_FACE) {
                                        if (l->e != e && BMO_elem_flag_test(bm, l->e, EDGE_MARK)) {
                                                break;
                                        }
index 17a00f5e095e089c0b5fb8430df5e3c3f901254f..cf1669d441e31d893cdc68dd44af454773873f97 100644 (file)
@@ -70,7 +70,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
        /* create old -> new mappin */
        i = 0;
        /* v2 = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); */ /* UNUSED */
-       BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) {
+       BMO_ITER (v, &siter, bm, &dupeop, "newout", BM_VERT) {
                BLI_array_growone(vmap);
                vmap[i] = v;
                /* v2 = BM_iter_step(&iter); */ /* UNUSED */
@@ -101,8 +101,8 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op)
                int totlayer;
                BMIter liter;
 
-               BMO_ITER(f, &siter, bm, &dupeop, "newout", BM_FACE) {
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BMO_ITER (f, &siter, bm, &dupeop, "newout", BM_FACE) {
+                       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                                totlayer = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
                                for (i = 0; i < totlayer; i++) {
                                        luv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i);
index 4e89b7b7efe04255d0e33cd44d732ed194e5c7a8..e526e2eaca0d3068a5c50f8af31212866933a6af 100644 (file)
@@ -370,7 +370,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op)
        }
 
        /* and now do imat */
-       BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(bm, eve, VERT_MARK)) {
                        mul_m4_v3(mat, eve->co);
                }
@@ -415,7 +415,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
 
                eftemp = BM_face_create_quad_tri(bm, v1, v2, v3, NULL, NULL, FALSE);
                
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, eftemp) {
+               BM_ITER_ELEM (l, &liter, eftemp, BM_LOOPS_OF_FACE) {
                        BMO_elem_flag_enable(bm, l->e, EDGE_MARK);
                }
 
@@ -437,7 +437,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op)
        }
 
        /* must transform after because of sphere subdivision */
-       BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
                        mul_m4_v3(mat, v->co);
                }
index d126da52b22ba249d09802964f02c7d9d7417c82..8cdb3b9b373338162bd7bae1d7f78a38a18541ad 100644 (file)
@@ -43,7 +43,7 @@ static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op)
        BMVert *v2, *doub;
        int split = FALSE;
 
-       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", l->v);
                /* ok: if v2 is NULL (e.g. not in the map) then it's
                 *     a target vert, otherwise it's a double */
@@ -108,7 +108,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op)
        int a, b;
 
        /* mark merge verts for deletion */
-       BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                if ((v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", v))) {
                        BMO_elem_flag_enable(bm, v, ELE_DEL);
 
@@ -119,11 +119,11 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op)
 
        /* check if any faces are getting their own corners merged
           together, split face if so */
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                remdoubles_splitface(f, bm, op);
        }
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (BMO_elem_flag_test(bm, e->v1, ELE_DEL) || BMO_elem_flag_test(bm, e->v2, ELE_DEL)) {
                        v = BMO_slot_map_ptr_get(bm, op, "targetmap", e->v1);
                        v2 = BMO_slot_map_ptr_get(bm, op, "targetmap", e->v2);
@@ -143,9 +143,9 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op)
        }
 
        /* BMESH_TODO, stop abusing face index here */
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                BM_elem_index_set(f, 0); /* set_dirty! */
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        if (BMO_elem_flag_test(bm, l->v, ELE_DEL)) {
                                BMO_elem_flag_enable(bm, f, FACE_MARK|ELE_DEL);
                        }
@@ -158,7 +158,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op)
 
        /* faces get "modified" by creating new faces here, then at the
           end the old faces are deleted */
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                if (!BMO_elem_flag_test(bm, f, FACE_MARK))
                        continue;
 
@@ -170,7 +170,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op)
                BLI_array_empty(edges);
                BLI_array_empty(loops);
                a = 0;
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        v = l->v;
                        v2 = l->next->v;
                        if (BMO_elem_flag_test(bm, v, ELE_DEL)) {
@@ -218,7 +218,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op)
                        BM_elem_attrs_copy(bm, bm, f, f2);
 
                        a = 0;
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f2) {
+                       BM_ITER_ELEM (l, &liter, f2, BM_LOOPS_OF_FACE) {
                                l2 = loops[a];
                                BM_elem_attrs_copy(bm, bm, l2, l);
 
@@ -269,7 +269,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op)
                return;
 
        fac = 1.0f / tot;
-       BM_ITER(l, &iter, bm, BM_LOOPS_OF_VERT, snapv) {
+       BM_ITER_ELEM (l, &iter, snapv, BM_LOOPS_OF_VERT) {
                if (!firstl) {
                        firstl = l;
                }
@@ -290,8 +290,8 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op)
                }
        }
 
-       BMO_ITER(v, &siter, bm, op, "verts", BM_VERT) {
-               BM_ITER(l, &iter, bm, BM_LOOPS_OF_VERT, v) {
+       BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+               BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
                        if (l == firstl) {
                                continue;
                        }
@@ -318,8 +318,8 @@ void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op)
                type = bm->ldata.layers[i].type;
                CustomData_data_initminmax(type, &min, &max);
 
-               BMO_ITER(v, &siter, bm, op, "verts", BM_VERT) {
-                       BM_ITER(l, &iter, bm, BM_LOOPS_OF_VERT, v) {
+               BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+                       BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
                                block = CustomData_bmesh_get_layer_n(&bm->ldata, l->head.data, i);
                                CustomData_data_dominmax(type, block, &min, &max);
                        }
@@ -329,8 +329,8 @@ void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op)
                CustomData_data_multiply(type, &max, 0.5f);
                CustomData_data_add(type, &min, &max);
 
-               BMO_ITER(v, &siter, bm, op, "verts", BM_VERT) {
-                       BM_ITER(l, &iter, bm, BM_LOOPS_OF_VERT, v) {
+               BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
+                       BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
                                block = CustomData_bmesh_get_layer_n(&bm->ldata, l->head.data, i);
                                CustomData_data_copy_value(type, &min, block);
                        }
@@ -350,7 +350,7 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op)
        //BMO_op_callf(bm, "collapse_uvs edges=%s", op, "edges");
        BMO_op_init(bm, &weldop, "weldverts");
        
-       BMO_ITER(v, &siter, bm, op, "verts", BM_VERT) {
+       BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
                if (!snapv) {
                        snapv = v;
                        copy_v3_v3(snapv->co, vec);
@@ -384,7 +384,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
                 BMW_FLAG_NOP, /* no need to use BMW_FLAG_TEST_HIDDEN, already marked data */
                 BMW_NIL_LAY);
 
-       BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+       BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                if (!BMO_elem_flag_test(bm, e, EDGE_MARK))
                        continue;
 
@@ -444,8 +444,8 @@ static void bmo_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer)
                 BMW_FLAG_NOP, /* no need to use BMW_FLAG_TEST_HIDDEN, already marked data */
                 layer);
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+       BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        if (BMO_elem_flag_test(bm, l->e, EDGE_MARK)) {
                                /* walk */
                                BLI_array_empty(blocks);
@@ -500,7 +500,7 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c
        dist3 = dist * 3.0f;
 
        i = 0;
-       BMO_ITER(v, &oiter, bm, op, "verts", BM_VERT) {
+       BMO_ITER (v, &oiter, bm, op, "verts", BM_VERT) {
                BLI_array_growone(verts);
                verts[i++] = v;
        }
@@ -583,7 +583,7 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op)
         * can be merged away into any other verts. Mark all other verts
         * as VERT_KEEP. */
        BMO_slot_buffer_flag_enable(bm, op, "verts", BM_VERT, VERT_IN);
-       BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
                if (!BMO_elem_flag_test(bm, v, VERT_IN)) {
                        BMO_elem_flag_enable(bm, v, VERT_KEEP);
                }
index 7b7b0638a3f35f04aeb2c0b05a153cfb9792602d..57bda579603b587e8df789d614ea7976fc848e25 100644 (file)
@@ -68,7 +68,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op)
        }
 
        /* Count selected edges */
-       BMO_ITER(h, &oiter, bm, op, "edge", BM_VERT | BM_EDGE) {
+       BMO_ITER (h, &oiter, bm, op, "edge", BM_VERT | BM_EDGE) {
                switch (h->htype) {
                        case BM_EDGE:
                                selected_edges++;
@@ -88,7 +88,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op)
        }
 
        /* Make sure we get the correct edge. */
-       BM_ITER(edge, &iter, bm, BM_EDGES_OF_VERT, vertex) {
+       BM_ITER_ELEM (edge, &iter, vertex, BM_EDGES_OF_VERT) {
                if (BMO_elem_flag_test(bm, edge, EDGE_MARK) && BM_vert_in_edge(edge, vertex)) {
                        slide_edge = edge;
                        break;
index 335b025757243a22b3aefd086dd0b22a511aab52..b3d4584107a47a7b3782e86275b95f0f2f5e228b 100644 (file)
@@ -105,7 +105,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar
        float *co = NULL;
        int i, totlayer = CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY);
        
-       BM_vert_normal_update_all(bm, v);
+       BM_vert_normal_update_all(v);
 
        co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, params->origkey);
        copy_v3_v3(co, v->co);
@@ -257,9 +257,9 @@ static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, const SubDParams *par
                BMO_elem_flag_enable(bm, eed, ELE_SPLIT);
                BMO_elem_flag_enable(bm, newe, SUBD_SPLIT);
 
-               BM_CHECK_ELEMENT(bm, v);
-               if (v->e) BM_CHECK_ELEMENT(bm, v->e);
-               if (v->e && v->e->l) BM_CHECK_ELEMENT(bm, v->e->l->f);
+               BM_CHECK_ELEMENT(v);
+               if (v->e) BM_CHECK_ELEMENT(v->e);
+               if (v->e && v->e->l) BM_CHECK_ELEMENT(v->e->l->f);
        }
        
        alter_co(bm, v1, &temp, params, 0, &ov1, &ov2);
@@ -673,7 +673,7 @@ typedef struct SubDFaceData {
        BMFace *face;
 } SubDFaceData;
 
-void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
+void bmo_esubd_exec(BMesh *bm, BMOperator *op)
 {
        BMOpSlot *einput;
        SubDPattern *pat;
@@ -693,7 +693,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
        int beauty, cornertype, singleedge, gridfill;
        int skey, seed, i, j, matched, a, b, numcuts, totesel;
        
-       BMO_slot_buffer_flag_enable(bmesh, op, "edges", BM_EDGE, SUBD_SPLIT);
+       BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, SUBD_SPLIT);
        
        numcuts = BMO_slot_int_get(op, "numcuts");
        seed = BMO_slot_int_get(op, "seed");
@@ -739,16 +739,16 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
        }
        
        /* add a temporary shapekey layer to store displacements on current geometry */
-       BM_data_layer_add(bmesh, &bmesh->vdata, CD_SHAPEKEY);
-       skey = CustomData_number_of_layers(&bmesh->vdata, CD_SHAPEKEY) - 1;
+       BM_data_layer_add(bm, &bm->vdata, CD_SHAPEKEY);
+       skey = CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY) - 1;
        
-       BM_ITER(v, &viter, bmesh, BM_VERTS_OF_MESH, NULL) {
-               float *co = CustomData_bmesh_get_n(&bmesh->vdata, v->head.data, CD_SHAPEKEY, skey);
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
+               float *co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, skey);
                copy_v3_v3(co, v->co);
        }
 
        /* first go through and tag edges */
-       BMO_slot_buffer_from_enabled_flag(bmesh, op, "edges", BM_EDGE, SUBD_SPLIT);
+       BMO_slot_buffer_from_enabled_flag(bm, op, "edges", BM_EDGE, SUBD_SPLIT);
 
        params.numcuts = numcuts;
        params.op = op;
@@ -761,14 +761,14 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
        params.off[1] = (float)BLI_drand() * 200.0f;
        params.off[2] = (float)BLI_drand() * 200.0f;
        
-       BMO_slot_map_to_flag(bmesh, op, "custompatterns",
+       BMO_slot_map_to_flag(bm, op, "custompatterns",
                             BM_FACE, FACE_CUSTOMFILL);
 
-       BMO_slot_map_to_flag(bmesh, op, "edgepercents",
+       BMO_slot_map_to_flag(bm, op, "edgepercents",
                             BM_EDGE, EDGE_PERCENT);
 
 
-       BM_ITER(face, &fiter, bmesh, BM_FACES_OF_MESH, NULL) {
+       BM_ITER_MESH (face, &fiter, bm, BM_FACES_OF_MESH) {
                BMEdge *e1 = NULL, *e2 = NULL;
                float vec1[3], vec2[3];
 
@@ -783,11 +783,11 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                matched = 0;
 
                totesel = 0;
-               BM_ITER_INDEX(nl, &liter, bmesh, BM_LOOPS_OF_FACE, face, i) {
+               BM_ITER_ELEM_INDEX (nl, &liter, face, BM_LOOPS_OF_FACE, i) {
                        edges[i] = nl->e;
                        verts[i] = nl->v;
 
-                       if (BMO_elem_flag_test(bmesh, edges[i], SUBD_SPLIT)) {
+                       if (BMO_elem_flag_test(bm, edges[i], SUBD_SPLIT)) {
                                if (!e1) e1 = edges[i];
                                else     e2 = edges[i];
 
@@ -811,14 +811,14 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                        }
                }
 
-               if (BMO_elem_flag_test(bmesh, face, FACE_CUSTOMFILL)) {
-                       pat = BMO_slot_map_data_get(bmesh, op,
+               if (BMO_elem_flag_test(bm, face, FACE_CUSTOMFILL)) {
+                       pat = BMO_slot_map_data_get(bm, op,
                                                    "custompatterns", face);
                        for (i = 0; i < pat->len; i++) {
                                matched = 1;
                                for (j = 0; j < pat->len; j++) {
                                        a = (j + i) % pat->len;
-                                       if ((!!BMO_elem_flag_test(bmesh, edges[a], SUBD_SPLIT)) != (!!pat->seledges[j])) {
+                                       if ((!!BMO_elem_flag_test(bm, edges[a], SUBD_SPLIT)) != (!!pat->seledges[j])) {
                                                matched = 0;
                                                break;
                                        }
@@ -830,7 +830,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                                        facedata[b].start = verts[i];
                                        facedata[b].face = face;
                                        facedata[b].totedgesel = totesel;
-                                       BMO_elem_flag_enable(bmesh, face, SUBD_SPLIT);
+                                       BMO_elem_flag_enable(bm, face, SUBD_SPLIT);
                                        break;
                                }
                        }
@@ -850,7 +850,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                                        matched = 1;
                                        for (b = 0; b < pat->len; b++) {
                                                j = (b + a) % pat->len;
-                                               if ((!!BMO_elem_flag_test(bmesh, edges[j], SUBD_SPLIT)) != (!!pat->seledges[b])) {
+                                               if ((!!BMO_elem_flag_test(bm, edges[j], SUBD_SPLIT)) != (!!pat->seledges[b])) {
                                                        matched = 0;
                                                        break;
                                                }
@@ -863,7 +863,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                                        BLI_array_growone(facedata);
                                        j = BLI_array_count(facedata) - 1;
 
-                                       BMO_elem_flag_enable(bmesh, face, SUBD_SPLIT);
+                                       BMO_elem_flag_enable(bm, face, SUBD_SPLIT);
 
                                        facedata[j].pat = pat;
                                        facedata[j].start = verts[a];
@@ -879,7 +879,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                        BLI_array_growone(facedata);
                        j = BLI_array_count(facedata) - 1;
                        
-                       BMO_elem_flag_enable(bmesh, face, SUBD_SPLIT);
+                       BMO_elem_flag_enable(bm, face, SUBD_SPLIT);
                        facedata[j].totedgesel = totesel;
                        facedata[j].face = face;
                }
@@ -890,12 +890,12 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
        /* go through and split edges */
        for (i = 0; i < einput->len; i++) {
                edge = ((BMEdge **)einput->data.p)[i];
-               bm_subdivide_multicut(bmesh, edge, &params, edge->v1, edge->v2);
+               bm_subdivide_multicut(bm, edge, &params, edge->v1, edge->v2);
        }
 
        /* copy original-geometry displacements to current coordinates */
-       BM_ITER(v, &viter, bmesh, BM_VERTS_OF_MESH, NULL) {
-               float *co = CustomData_bmesh_get_n(&bmesh->vdata, v->head.data, CD_SHAPEKEY, skey);
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
+               float *co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, skey);
                copy_v3_v3(v->co, co);
        }
 
@@ -916,7 +916,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                        BLI_array_empty(splits);
 
                        /* for case of two edges, connecting them shouldn't be too hard */
-                       BM_ITER(l, &liter, bmesh, BM_LOOPS_OF_FACE, face) {
+                       BM_ITER_ELEM (l, &liter, face, BM_LOOPS_OF_FACE) {
                                BLI_array_growone(loops);
                                loops[BLI_array_count(loops) - 1] = l;
                        }
@@ -925,22 +925,22 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
 
                        /* find the boundary of one of the split edges */
                        for (a = 1; a < vlen; a++) {
-                               if (!BMO_elem_flag_test(bmesh, loops[a - 1]->v, ELE_INNER) &&
-                                   BMO_elem_flag_test(bmesh, loops[a]->v, ELE_INNER))
+                               if (!BMO_elem_flag_test(bm, loops[a - 1]->v, ELE_INNER) &&
+                                   BMO_elem_flag_test(bm, loops[a]->v, ELE_INNER))
                                {
                                        break;
                                }
                        }
                        
-                       if (BMO_elem_flag_test(bmesh, loops[(a + numcuts + 1) % vlen]->v, ELE_INNER)) {
+                       if (BMO_elem_flag_test(bm, loops[(a + numcuts + 1) % vlen]->v, ELE_INNER)) {
                                b = (a + numcuts + 1) % vlen;
                        }
                        else {
                                /* find the boundary of the other edge. */
                                for (j = 0; j < vlen; j++) {
                                        b = (j + a + numcuts + 1) % vlen;
-                                       if (!BMO_elem_flag_test(bmesh, loops[b == 0 ? vlen - 1 : b - 1]->v, ELE_INNER) &&
-                                           BMO_elem_flag_test(bmesh, loops[b]->v, ELE_INNER))
+                                       if (!BMO_elem_flag_test(bm, loops[b == 0 ? vlen - 1 : b - 1]->v, ELE_INNER) &&
+                                           BMO_elem_flag_test(bm, loops[b]->v, ELE_INNER))
                                        {
                                                break;
                                        }
@@ -965,7 +965,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                        for (j = 0; j < BLI_array_count(splits) / 2; j++) {
                                if (splits[j * 2]) {
                                        /* BMFace *nf = */ /* UNUSED */
-                                       BM_face_split(bmesh, face, splits[j * 2]->v, splits[j * 2 + 1]->v, &nl, NULL, FALSE);
+                                       BM_face_split(bm, face, splits[j * 2]->v, splits[j * 2 + 1]->v, &nl, NULL, FALSE);
                                }
                        }
 
@@ -976,7 +976,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                }
 
                j = a = 0;
-               for (nl = BM_iter_new(&liter, bmesh, BM_LOOPS_OF_FACE, face);
+               for (nl = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, face);
                     nl;
                     nl = BM_iter_step(&liter))
                {
@@ -992,23 +992,23 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
                }
                
                j = 0;
-               for (nl = BM_iter_new(&liter, bmesh, BM_LOOPS_OF_FACE, face); nl; nl = BM_iter_step(&liter)) {
+               for (nl = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, face); nl; nl = BM_iter_step(&liter)) {
                        b = (j - a + face->len) % face->len;
                        verts[b] = nl->v;
                        j += 1;
                }
 
-               BM_CHECK_ELEMENT(bmesh, face);
-               pat->connectexec(bmesh, face, verts, &params);
+               BM_CHECK_ELEMENT(face);
+               pat->connectexec(bm, face, verts, &params);
        }
 
        /* copy original-geometry displacements to current coordinates */
-       BM_ITER(v, &viter, bmesh, BM_VERTS_OF_MESH, NULL) {
-               float *co = CustomData_bmesh_get_n(&bmesh->vdata, v->head.data, CD_SHAPEKEY, skey);
+       BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
+               float *co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, skey);
                copy_v3_v3(v->co, co);
        }
 
-       BM_data_layer_free_n(bmesh, &bmesh->vdata, CD_SHAPEKEY, skey);
+       BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, skey);
        
        if (facedata) BLI_array_free(facedata);
        if (edges) BLI_array_free(edges);
@@ -1016,10 +1016,10 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
        BLI_array_free(splits);
        BLI_array_free(loops);
 
-       BMO_slot_buffer_from_enabled_flag(bmesh, op, "outinner", BM_ALL, ELE_INNER);
-       BMO_slot_buffer_from_enabled_flag(bmesh, op, "outsplit", BM_ALL, ELE_SPLIT);
+       BMO_slot_buffer_from_enabled_flag(bm, op, "outinner", BM_ALL, ELE_INNER);
+       BMO_slot_buffer_from_enabled_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT);
        
-       BMO_slot_buffer_from_enabled_flag(bmesh, op, "geomout", BM_ALL, ELE_INNER|ELE_SPLIT|SUBD_SPLIT);
+       BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, ELE_INNER|ELE_SPLIT|SUBD_SPLIT);
 }
 
 /* editmesh-emulating function */
@@ -1064,7 +1064,7 @@ void BM_mesh_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float s
                                BMEdge *e;
                                BMIter eiter;
 
-                               BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, ele) {
+                               BM_ITER_ELEM (e, &eiter, ele, BM_EDGES_OF_VERT) {
                                        if (!BM_elem_flag_test(e, BM_ELEM_SELECT) &&
                                             BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
                                             BM_elem_flag_test(e->v2, BM_ELEM_SELECT))
@@ -1101,7 +1101,7 @@ void bmo_edgebisect_exec(BMesh *bm, BMOperator *op)
        params.origkey = skey;
 
        /* go through and split edges */
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                bm_subdivide_multicut(bm, e, &params, e->v1, e->v2);
        }
 
index fd6106a11c9445e2f3b53d06ea509998c6475cb1..916b10d707efde7a5445c87148c199d3e29ea4f6 100644 (file)
@@ -94,7 +94,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
        
        BMO_slot_buffer_flag_enable(bm, op, "constrain_edges", BM_EDGE, EDGE_MARK);
        
-       BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) {
+       BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
                if (f->len == 3) {
                        BMO_elem_flag_enable(bm, f, FACE_MARK);
                }
@@ -103,7 +103,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
        while (!stop) {
                stop = 1;
                
-               BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+               BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                        BMVert *v1, *v2, *v3, *v4;
                        
                        if (!BM_edge_is_manifold(e) || BMO_elem_flag_test(bm, e, EDGE_MARK)) {
@@ -175,7 +175,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
        
        BLI_begin_edgefill(&sf_ctx);
        
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                BMO_elem_flag_enable(bm, e, EDGE_MARK);
                
                if (!BLI_smallhash_haskey(&hash, (uintptr_t)e->v1)) {
@@ -206,7 +206,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
                BMIter liter;
                
                BMO_elem_flag_enable(bm, f, ELE_NEW);
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
                        if (!BMO_elem_flag_test(bm, l->e, EDGE_MARK)) {
                                BMO_elem_flag_enable(bm, l->e, ELE_NEW);
                        }
index ea1fc5171e51b75696da9a67bfe1949d43ff07d4..87aba98836d0d73665bf775e4bb2a2a241e22a16 100644 (file)
@@ -59,7 +59,7 @@ void bmo_transform_exec(BMesh *bm, BMOperator *op)
 
        BMO_slot_mat4_get(op, "mat", mat);
 
-       BMO_ITER(v, &iter, bm, op, "verts", BM_VERT) {
+       BMO_ITER (v, &iter, bm, op, "verts", BM_VERT) {
                mul_m4_v3(mat, v->co);
        }
 }
@@ -113,7 +113,7 @@ void bmo_reversefaces_exec(BMesh *bm, BMOperator *op)
        BMOIter siter;
        BMFace *f;
 
-       BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) {
+       BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
                BM_face_normal_flip(bm, f);
        }
 }
@@ -131,11 +131,11 @@ void bmo_edgerotate_exec(BMesh *bm, BMOperator *op)
 #define EDGE_OUT   1
 #define FACE_TAINT 1
 
-       BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
+       BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) {
                /**
                 * this ends up being called twice, could add option to not to call check in
                 * #BM_edge_rotate to get some extra speed */
-               if (BM_edge_rotate_check(bm, e)) {
+               if (BM_edge_rotate_check(e)) {
                        BMFace *fa, *fb;
                        if (BM_edge_face_pair(e, &fa, &fb)) {
 
@@ -180,14 +180,14 @@ static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces)
        BMOIter siter;
 
        if (!usefaces) {
-               BMO_ITER(v, &siter, bm, op, "geom", BM_VERT) {
-                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+               BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
+                       BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                                if (!BMO_elem_flag_test(bm, e, SEL_ORIG))
                                        break;
                        }
 
                        if (e) {
-                               BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+                               BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                                        BMO_elem_flag_enable(bm, e, SEL_FLAG);
                                        BMO_elem_flag_enable(bm, BM_edge_other_vert(e, v), SEL_FLAG);
                                }
@@ -199,9 +199,9 @@ static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces)
                BMFace *f, *f2;
                BMLoop *l;
 
-               BMO_ITER(f, &siter, bm, op, "geom", BM_FACE) {
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
-                               BM_ITER(f2, &fiter, bm, BM_FACES_OF_EDGE, l->e) {
+               BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) {
+                       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+                               BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) {
                                        if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) {
                                                BMO_elem_flag_enable(bm, f2, SEL_FLAG);
                                        }
@@ -219,8 +219,8 @@ static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces)
        BMOIter siter;
 
        if (!usefaces) {
-               BMO_ITER(v, &siter, bm, op, "geom", BM_VERT) {
-                       BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+               BMO_ITER (v, &siter, bm, op, "geom", BM_VERT) {
+                       BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                                if (!BMO_elem_flag_test(bm, e, SEL_ORIG))
                                        break;
                        }
@@ -228,7 +228,7 @@ static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces)
                        if (e) {
                                BMO_elem_flag_enable(bm, v, SEL_FLAG);
 
-                               BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) {
+                               BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
                                        BMO_elem_flag_enable(bm, e, SEL_FLAG);
                                }
 
@@ -240,9 +240,9 @@ static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces)
                BMFace *f, *f2;
                BMLoop *l;
 
-               BMO_ITER(f, &siter, bm, op, "geom", BM_FACE) {
-                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
-                               BM_ITER(f2, &fiter, bm, BM_FACES_OF_EDGE, l->e) {
+               BMO_ITER (f, &siter, bm, op, "geom", BM_FACE) {
+                       BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+                               BM_ITER_ELEM (f2, &fiter, l->e, BM_FACES_OF_EDGE) {
                                        if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) {
                                                BMO_elem_flag_enable(bm, f, SEL_FLAG);
                                                break;
@@ -312,7 +312,7 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op)
        BMO_slot_buffer_flag_enable(bm, op, "faces", BM_FACE, FACE_FLAG);
 
        /* find a starting face */
-       BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) {
+       BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
 
                /* clear dirty flag */
                BM_elem_flag_disable(f, BM_ELEM_TAG);
@@ -322,7 +322,7 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op)
 
                if (!startf) startf = f;
 
-               BM_face_center_bounds_calc(bm, f, cent);
+               BM_face_center_bounds_calc(f, cent);
 
                if ((maxx_test = dot_v3v3(cent, cent)) > maxx) {
                        maxx = maxx_test;
@@ -332,7 +332,7 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op)
 
        if (!startf) return;
 
-       BM_face_center_bounds_calc(bm, startf, cent);
+       BM_face_center_bounds_calc(startf, cent);
 
        /* make sure the starting face has the correct winding */
        if (dot_v3v3(cent, startf->no) < 0.0f) {
@@ -358,8 +358,8 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op)
                f = fstack[i];
                i--;
 
-               BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
-                       BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_LOOP, l) {
+               BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+                       BM_ITER_ELEM (l2, &liter2, l, BM_LOOPS_OF_LOOP) {
                                if (!BMO_elem_flag_test(bm, l2->f, FACE_FLAG) || l2 == l)
                                        continue;
 
@@ -395,7 +395,7 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op)
        BLI_array_free(fstack);
 
        /* check if we have faces yet to do.  if so, recurse */
-       BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) {
+       BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) {
                if (!BMO_elem_flag_test(bm, f, FACE_VIS)) {
                        bmo_righthandfaces_exec(bm, op);
                        break;
@@ -419,12 +419,12 @@ void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op)
        clipz = BMO_slot_bool_get(op, "mirror_clip_z");
 
        i = 0;
-       BMO_ITER(v, &siter, bm, op, "verts", BM_VERT) {