bmesh api:
authorCampbell Barton <ideasman42@gmail.com>
Sat, 25 Feb 2012 19:43:51 +0000 (19:43 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 25 Feb 2012 19:43:51 +0000 (19:43 +0000)
* added BM_elem_flag_set, BMO_elem_flag_set. to avoid 'if(...) enable(); else disable();' all over the place.
* added bmesh_operator_api_inline.c, the header file was getting messy.

21 files changed:
source/blender/bmesh/CMakeLists.txt
source/blender/bmesh/bmesh.h
source/blender/bmesh/bmesh_operator_api.h
source/blender/bmesh/intern/bmesh_inline.c
source/blender/bmesh/intern/bmesh_marking.c
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_operator_api_inline.c [new file with mode: 0644]
source/blender/bmesh/intern/bmesh_queries.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_extrude.c
source/blender/bmesh/operators/bmo_primitive.c
source/blender/bmesh/operators/bmo_removedoubles.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/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/uvedit/uvedit_ops.c

index 48f653f47594a85d1b5c28e4490b90c8b025cc14..f7dacef88d352de3e813ea2313b617d35b49eebf 100644 (file)
@@ -90,6 +90,7 @@ set(SRC
        intern/bmesh_mods.c
        intern/bmesh_newcore.c
        intern/bmesh_opdefines.c
+       intern/bmesh_operator_api_inline.c
        intern/bmesh_operators.c
        intern/bmesh_operators_private.h
        intern/bmesh_polygon.c
index 6190e3215c6f276223372c43280451b4c237465c..a3f7c07e69d4dd37eac87476b3bdd5917214818d 100644 (file)
@@ -372,6 +372,7 @@ void bmesh_end_edit(BMesh *bm, int flag);
 #include "bmesh_iterators.h"
 #include "bmesh_walkers.h"
 #include "intern/bmesh_inline.c"
+#include "intern/bmesh_operator_api_inline.c"
 
 #ifdef __cplusplus
 }
index b9c9bd529663473ee2131d8b79512db8ee5bdc4b..80f2856b0663686ecc31ce77acf5c8f60df28a55 100644 (file)
@@ -73,6 +73,7 @@ extern "C" {
  *   semantically similar to the iterator api in bmesh_iterators.h).
  */
 
+struct BMesh;
 struct GHashIterator;
 
 /* slot type arrays are terminated by the last member
@@ -182,15 +183,10 @@ void BMO_op_finish(struct BMesh *bm, struct BMOperator *op);
 #define BMO_elem_flag_test(bm, element, oflag)    ((element)->oflags[bm->stackdepth-1].f &   (oflag))
 #define BMO_elem_flag_enable(bm, element, oflag)  ((element)->oflags[bm->stackdepth-1].f |=  (oflag))
 #define BMO_elem_flag_disable(bm, element, oflag) ((element)->oflags[bm->stackdepth-1].f &= ~(oflag))
+#define BMO_elem_flag_set(bm, element, oflag, val)((val) ? BMO_elem_flag_enable(bm, element, oflag) : \
+                                                           BMO_elem_flag_disable(bm, element, oflag))
 #define BMO_elem_flag_toggle(bm, element, oflag)  ((element)->oflags[bm->stackdepth-1].f ^=  (oflag))
 
-/* profiling showed a significant amount of time spent in BMO_elem_flag_test */
-#if 0
-void BMO_elem_flag_enable(struct BMesh *bm, void *element, const short oflag);
-void BMO_elem_flag_disable(struct BMesh *bm, void *element, const short oflag);
-int BMO_elem_flag_test(struct BMesh *bm, void *element, const short oflag);
-#endif
-
 /* count the number of elements with a specific flag.
  * type can be a bitmask of BM_FACE, BM_EDGE, or BM_FACE. */
 int BMO_mesh_flag_count(struct BMesh *bm, const short oflag, const char htype);
@@ -339,44 +335,11 @@ int BMO_slot_map_count(struct BMesh *bm, struct BMOperator *op, const char *slot
  */
 int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag);
 
-/* inserts a key/value mapping into a mapping slot.  note that it copies the
- * value, it doesn't store a reference to it. */
-
-#if 0
-
-BM_INLINE void BMO_slot_map_insert(BMesh *bm, BMOperator *op, const char *slotname,
-                                   void *element, void *data, int len);
-
-/* inserts a key/float mapping pair into a mapping slot. */
-BM_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname,
-                                         void *element, float val);
-
-/* returns 1 if the specified pointer is in the map. */
-BM_INLINE int BMO_slot_map_contains(BMesh *bm, BMOperator *op, const char *slotname, void *element);
-
-/* returns a point to the value of a specific key. */
-BM_INLINE void *BMO_slot_map_data_get(BMesh *bm, BMOperator *op, const char *slotname, void *element);
-
-/* returns the float part of a key/float pair. */
-BM_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname, void *element);
-
-#endif
-
 /* flags all elements in a mapping.  note that the mapping must only have
  * bmesh elements in it.*/
 void BMO_slot_map_to_flag(struct BMesh *bm, struct BMOperator *op,
                           const char *slotname, const short oflag);
 
-/* pointer versoins of BMO_slot_map_float_get and BMO_slot_map_float_insert.
- *
- * do NOT use these for non-operator-api-allocated memory! instead
- * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */
-
-#if 0
-BM_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname, void *key, void *val);
-BM_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname, void *key);
-#endif
-
 /* this part of the API is used to iterate over element buffer or
  * mapping slots.
  *
@@ -453,104 +416,6 @@ typedef struct BMOElemMapping {
 
 extern const int BMO_OPSLOT_TYPEINFO[BMO_OP_SLOT_TOTAL_TYPES];
 
-BM_INLINE void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname,
-                                   void *element, void *data, int len)
-{
-       BMOElemMapping *mapping;
-       BMOpSlot *slot = BMO_slot_get(op, slotname);
-
-       /*sanity check*/
-       if (slot->slottype != BMO_OP_SLOT_MAPPING) {
-               return;
-       }
-
-       mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len);
-
-       mapping->element = (BMHeader*) element;
-       mapping->len = len;
-       memcpy(mapping + 1, data, len);
-
-       if (!slot->data.ghash) {
-               slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                                                BLI_ghashutil_ptrcmp, "bmesh op");
-       }
-
-       BLI_ghash_insert(slot->data.ghash, element, mapping);
-}
-
-BM_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname,
-                                       void *element, int val)
-{
-       BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int));
-}
-
-BM_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname,
-                                         void *element, float val)
-{
-       BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float));
-}
-
-BM_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname,
-                                       void *element, void *val)
-{
-       BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void*));
-}
-
-BM_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element)
-{
-       BMOpSlot *slot = BMO_slot_get(op, slotname);
-
-       /*sanity check*/
-       if (slot->slottype != BMO_OP_SLOT_MAPPING) return 0;
-       if (!slot->data.ghash) return 0;
-
-       return BLI_ghash_haskey(slot->data.ghash, element);
-}
-
-BM_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname,
-                                      void *element)
-{
-       BMOElemMapping *mapping;
-       BMOpSlot *slot = BMO_slot_get(op, slotname);
-
-       /*sanity check*/
-       if (slot->slottype != BMO_OP_SLOT_MAPPING) return NULL;
-       if (!slot->data.ghash) return NULL;
-
-       mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
-
-       if (!mapping) return NULL;
-
-       return mapping + 1;
-}
-
-BM_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname,
-                                       void *element)
-{
-       float *val = (float*) BMO_slot_map_data_get(bm, op, slotname, element);
-       if (val) return *val;
-
-       return 0.0f;
-}
-
-BM_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname,
-                                   void *element)
-{
-       int *val = (int*) BMO_slot_map_data_get(bm, op, slotname, element);
-       if (val) return *val;
-
-       return 0;
-}
-
-BM_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname,
-                                     void *element)
-{
-       void **val = (void**) BMO_slot_map_data_get(bm, op, slotname, element);
-       if (val) return *val;
-
-       return NULL;
-}
-
 #ifdef __cplusplus
 }
 #endif
index 4433aaa0fc6929e76884f4d79ee50d9f8b4e6f67..b855c4b865a4e31c7b05233ea6de7402bddc9474 100644 (file)
@@ -46,6 +46,12 @@ BM_INLINE void BM_elem_flag_disable(void *element, const char hflag)
        ((BMHeader *)element)->hflag &= ~hflag;
 }
 
+BM_INLINE void BM_elem_flag_set(void *element, const char hflag, const int val)
+{
+       if (val)  BM_elem_flag_enable(element,  hflag);
+       else      BM_elem_flag_disable(element, hflag);
+}
+
 BM_INLINE void BM_elem_flag_toggle(void *element, const char hflag)
 {
        ((BMHeader *)element)->hflag ^= hflag;
index 8a8ccb5efb12c77737b0f9cdf73deb44fbebcf83..21ecc245707e2f5ca4a3a75f13eef569ddc59868 100644 (file)
@@ -115,12 +115,7 @@ void BM_mesh_select_mode_flush(BMesh *bm)
                                ok = FALSE;
                        }
 
-                       if (ok) {
-                               BM_elem_flag_enable(f, BM_ELEM_SELECT);
-                       }
-                       else {
-                               BM_elem_flag_disable(f, BM_ELEM_SELECT);
-                       }
+                       BM_elem_flag_set(f, BM_ELEM_SELECT, ok);
                }
        }
        else if (bm->selectmode & SCE_SELECT_EDGE) {
@@ -139,12 +134,7 @@ void BM_mesh_select_mode_flush(BMesh *bm)
                                ok = FALSE;
                        }
 
-                       if (ok) {
-                               BM_elem_flag_enable(f, BM_ELEM_SELECT);
-                       }
-                       else {
-                               BM_elem_flag_disable(f, BM_ELEM_SELECT);
-                       }
+                       BM_elem_flag_set(f, BM_ELEM_SELECT, ok);
                }
        }
 
@@ -802,9 +792,6 @@ void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag)
 
 /***************** Mesh Hiding stuff *********** */
 
-#define BM_ELEM_HIDE_SET(ele, hide) \
-       (hide) ? BM_elem_flag_enable(ele, BM_ELEM_HIDDEN) : BM_elem_flag_disable(ele, BM_ELEM_HIDDEN);
-
 static void vert_flush_hide_set(BMesh *bm, BMVert *v)
 {
        BMIter iter;
@@ -815,7 +802,7 @@ static void vert_flush_hide_set(BMesh *bm, BMVert *v)
                hide = hide && BM_elem_flag_test(e, BM_ELEM_HIDDEN);
        }
 
-       BM_ELEM_HIDE_SET(v, hide);
+       BM_elem_flag_set(v, BM_ELEM_HIDDEN, hide);
 }
 
 static void edge_flush_hide(BMesh *bm, BMEdge *e)
@@ -828,7 +815,7 @@ static void edge_flush_hide(BMesh *bm, BMEdge *e)
                hide = hide && BM_elem_flag_test(f, BM_ELEM_HIDDEN);
        }
 
-       BM_ELEM_HIDE_SET(e, hide);
+       BM_elem_flag_set(e, BM_ELEM_HIDDEN, hide);
 }
 
 void BM_vert_hide_set(BMesh *bm, BMVert *v, int hide)
@@ -838,13 +825,13 @@ void BM_vert_hide_set(BMesh *bm, BMVert *v, int hide)
        BMEdge *e;
        BMFace *f;
 
-       BM_ELEM_HIDE_SET(v, hide);
+       BM_elem_flag_set(v, BM_ELEM_HIDDEN, hide);
 
        BM_ITER(e, &iter, bm, BM_EDGES_OF_VERT, v) {
-               BM_ELEM_HIDE_SET(e, hide);
+               BM_elem_flag_set(e, BM_ELEM_HIDDEN, hide);
 
                BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) {
-                       BM_ELEM_HIDE_SET(f, hide);
+                       BM_elem_flag_set(f, BM_ELEM_HIDDEN, hide);
                }
        }
 }
@@ -857,10 +844,10 @@ void BM_edge_hide_set(BMesh *bm, BMEdge *e, int hide)
 
        /* edge hiding: faces around the edge */
        BM_ITER(f, &iter, bm, BM_FACES_OF_EDGE, e) {
-               BM_ELEM_HIDE_SET(f, hide);
+               BM_elem_flag_set(f, BM_ELEM_HIDDEN, hide);
        }
        
-       BM_ELEM_HIDE_SET(e, hide);
+       BM_elem_flag_set(e, BM_ELEM_HIDDEN, hide);
 
        /* hide vertices if necassary */
        vert_flush_hide_set(bm, e->v1);
@@ -872,7 +859,7 @@ void BM_face_hide_set(BMesh *bm, BMFace *f, int hide)
        BMIter iter;
        BMLoop *l;
 
-       BM_ELEM_HIDE_SET(f, hide);
+       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);
@@ -883,9 +870,6 @@ void BM_face_hide_set(BMesh *bm, BMFace *f, int hide)
        }
 }
 
-#undef BM_ELEM_HIDE_SET
-
-
 void BM_elem_hide_set(BMesh *bm, void *element, int hide)
 {
        BMHeader *h = element;
index 9621e593f3a62cf9e2c1af955d761f3128332899..b5132312d3c775cf859e6ec87ef4ed09de1027eb 100644 (file)
@@ -355,9 +355,7 @@ static void bmesh_rationalize_normals(BMesh *bm, int undo)
        bmesh_righthandfaces_exec(bm, &bmop);
        
        BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
-               if (BMO_elem_flag_test(bm, f, FACE_FLIP))
-                       BM_elem_flag_enable(f, BM_ELEM_TAG);
-               else BM_elem_flag_disable(f, BM_ELEM_TAG);
+               BM_elem_flag_set(f, BM_ELEM_TAG, BMO_elem_flag_test(bm, f, FACE_FLIP));
        }
 
        BMO_pop(bm);
diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.c b/source/blender/bmesh/intern/bmesh_operator_api_inline.c
new file mode 100644 (file)
index 0000000..8e32f27
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Joseph Eagar, Geoffrey Bantle, Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/bmesh/intern/bmesh_operator_api_inline.c
+ *  \ingroup bmesh
+ *
+ * BMesh inline operator functions.
+ */
+
+#ifndef __BMESH_OPERATOR_API_INLINE_C__
+#define __BMESH_OPERATOR_API_INLINE_C__
+
+#include "bmesh.h"
+
+/* inserts a key/value mapping into a mapping slot.  note that it copies the
+ * value, it doesn't store a reference to it. */
+
+BM_INLINE void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname,
+                                   void *element, void *data, int len)
+{
+       BMOElemMapping *mapping;
+       BMOpSlot *slot = BMO_slot_get(op, slotname);
+
+       /*sanity check*/
+       if (slot->slottype != BMO_OP_SLOT_MAPPING) {
+               return;
+       }
+
+       mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len);
+
+       mapping->element = (BMHeader*) element;
+       mapping->len = len;
+       memcpy(mapping + 1, data, len);
+
+       if (!slot->data.ghash) {
+               slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash,
+                                                BLI_ghashutil_ptrcmp, "bmesh op");
+       }
+
+       BLI_ghash_insert(slot->data.ghash, element, mapping);
+}
+
+BM_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname,
+                                       void *element, int val)
+{
+       BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int));
+}
+
+BM_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname,
+                                         void *element, float val)
+{
+       BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float));
+}
+
+
+/* pointer versoins of BMO_slot_map_float_get and BMO_slot_map_float_insert.
+ *
+ * do NOT use these for non-operator-api-allocated memory! instead
+ * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */
+
+BM_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname,
+                                       void *element, void *val)
+{
+       BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void*));
+}
+
+BM_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element)
+{
+       BMOpSlot *slot = BMO_slot_get(op, slotname);
+
+       /*sanity check*/
+       if (slot->slottype != BMO_OP_SLOT_MAPPING) return 0;
+       if (!slot->data.ghash) return 0;
+
+       return BLI_ghash_haskey(slot->data.ghash, element);
+}
+
+BM_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname,
+                                      void *element)
+{
+       BMOElemMapping *mapping;
+       BMOpSlot *slot = BMO_slot_get(op, slotname);
+
+       /*sanity check*/
+       if (slot->slottype != BMO_OP_SLOT_MAPPING) return NULL;
+       if (!slot->data.ghash) return NULL;
+
+       mapping = (BMOElemMapping *)BLI_ghash_lookup(slot->data.ghash, element);
+
+       if (!mapping) return NULL;
+
+       return mapping + 1;
+}
+
+BM_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname,
+                                       void *element)
+{
+       float *val = (float*) BMO_slot_map_data_get(bm, op, slotname, element);
+       if (val) return *val;
+
+       return 0.0f;
+}
+
+BM_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname,
+                                   void *element)
+{
+       int *val = (int*) BMO_slot_map_data_get(bm, op, slotname, element);
+       if (val) return *val;
+
+       return 0;
+}
+
+BM_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname,
+                                     void *element)
+{
+       void **val = (void**) BMO_slot_map_data_get(bm, op, slotname, element);
+       if (val) return *val;
+
+       return NULL;
+}
+
+#endif /* __BMESH_OPERATOR_API_INLINE_C__ */
index 2eb9e6e918ff9aa2ec3153ee28a884468a5db3db..a8c4cd718455aacd6bd64026470e925afd01b504 100644 (file)
@@ -140,7 +140,9 @@ int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len)
 
        int i, count = 0;
        
-       for (i = 0; i < len; i++) BMO_elem_flag_enable(bm, varr[i], BM_OVERLAP);
+       for (i = 0; i < len; i++) {
+               BMO_elem_flag_enable(bm, varr[i], BM_OVERLAP);
+       }
 
 #ifdef USE_BMESH_HOLES
        for (lst = f->loops.first; lst; lst = lst->next)
index 6ba0c91fb4d9f62a0d4e42a5e60dac0443ddf20e..610790393f1e5b04df21859d8b400acc20d0992d 100644 (file)
@@ -1407,6 +1407,8 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op)
                        printf("cannot find nice quad from concave set of vertices\n");
                }
 
-               if (f) BMO_elem_flag_enable(bm, f, ELE_OUT);
+               if (f) {
+                       BMO_elem_flag_enable(bm, f, ELE_OUT);
+               }
        }
 }
index 2ee70bb4644242dfbbd9055ab4899ad51848e7b8..ddef478a4aac9c7933e79d4156bc7a7f52726e0d 100644 (file)
@@ -88,12 +88,7 @@ void dissolvefaces_exec(BMesh *bm, BMOperator *op)
                BMVert *v;
 
                BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
-                       if (BM_vert_edge_count(v) == 2) {
-                               BMO_elem_flag_disable(bm, v, VERT_MARK);
-                       }
-                       else {
-                               BMO_elem_flag_enable(bm, v, VERT_MARK);
-                       }
+                       BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2));
                }
        }
 
@@ -251,12 +246,7 @@ void dissolveedges_exec(BMesh *bm, BMOperator *op)
 
        if (use_verts) {
                BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
-                       if (BM_vert_edge_count(v) == 2) {
-                               BMO_elem_flag_disable(bm, v, VERT_MARK);
-                       }
-                       else {
-                               BMO_elem_flag_enable(bm, v, VERT_MARK);
-                       }
+                       BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2));
                }
        }
 
index d7626673e4372f0df9d7081ece26888539275467..09b0e2042f46dfdcbc64230d3785d8a27968d76b 100644 (file)
@@ -407,7 +407,9 @@ void splitop_exec(BMesh *bm, BMOperator *op)
                                        break;
                                }
                        }
-                       if (!found) BMO_elem_flag_enable(bm, e, SPLIT_INPUT);
+                       if (!found) {
+                               BMO_elem_flag_enable(bm, e, SPLIT_INPUT);
+                       }
                }
 
                for (v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v = BM_iter_step(&iter)) {
@@ -419,8 +421,9 @@ void splitop_exec(BMesh *bm, BMOperator *op)
                                        break;
                                }
                        }
-                       if (!found) BMO_elem_flag_enable(bm, v, SPLIT_INPUT);
-
+                       if (!found) {
+                               BMO_elem_flag_enable(bm, v, SPLIT_INPUT);
+                       }
                }
        }
 
index 2c6a0e0de6a513554319734246dbdc3bcf7a477c..b194428deba638d24c551c84debde8f7c8008683 100644 (file)
@@ -215,7 +215,9 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op)
                                }
                        }
 
-                       if (!found && (rlen > 1)) BMO_elem_flag_enable(bm, e, EXT_DEL);
+                       if (!found && (rlen > 1)) {
+                               BMO_elem_flag_enable(bm, e, EXT_DEL);
+                       }
                }
        }
 
@@ -243,8 +245,9 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op)
        }
        
        BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
-               if (BMO_elem_flag_test(bm, f, EXT_INPUT))
+               if (BMO_elem_flag_test(bm, f, EXT_INPUT)) {
                        BMO_elem_flag_enable(bm, f, EXT_DEL);
+               }
        }
 
        if (delorig) {
index e674a3f2856a4d8aa4100a1b12618b7588888b81..9cf17490d583368d9bc17d5436437b729ff723b9 100644 (file)
@@ -248,7 +248,7 @@ void bmesh_create_grid_exec(BMesh *bm, BMOperator *op)
                eve = BM_vert_create(bm, vec, NULL);
                BMO_elem_flag_enable(bm, eve, VERT_MARK);
 
-               if (a) {
+               if (a != 0) {
                        e = BM_edge_create(bm, preveve, eve, NULL, TRUE);
                        BMO_elem_flag_enable(bm, e, EDGE_ORIG);
                }
index 2eb1cf7db3e7ce8821a6f2389977d3c9db3ba7d6..bd528faa43ef61d765f2b531129c4adb853833f5 100644 (file)
@@ -124,10 +124,12 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op)
                        if (!v) v = e->v1;
                        if (!v2) v2 = e->v2;
 
-                       if (v == v2)
+                       if (v == v2) {
                                BMO_elem_flag_enable(bm, e, EDGE_COL);
-                       else if (!BM_edge_exists(v, v2))
+                       }
+                       else if (!BM_edge_exists(v, v2)) {
                                BM_edge_create(bm, v, v2, e, TRUE);
+                       }
 
                        BMO_elem_flag_enable(bm, e, ELE_DEL);
                }
index a14af6184114f6e5cf1d13d6a671fdcd0ff0057a..b4ec3d740d48cf0a947c93b32930c1a75f4b758d 100644 (file)
@@ -89,8 +89,9 @@ void bmesh_beautify_fill_exec(BMesh *bm, BMOperator *op)
        BMO_slot_buffer_flag_enable(bm, op, "constrain_edges", EDGE_MARK, BM_EDGE);
        
        BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) {
-               if (f->len == 3)
+               if (f->len == 3) {
                        BMO_elem_flag_enable(bm, f, FACE_MARK);
+               }
        }
 
        while (!stop) {
index d80535efb76f81e641a27a99b2565794213072aa..1acdf05ef35f33d13e3a4ea812c09d8d08668417 100644 (file)
@@ -170,8 +170,9 @@ static void bmesh_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces)
                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) {
-                                       if (!BMO_elem_flag_test(bm, f2, SEL_ORIG))
+                                       if (!BMO_elem_flag_test(bm, f2, SEL_ORIG)) {
                                                BMO_elem_flag_enable(bm, f2, SEL_FLAG);
+                                       }
                                }
                        }
                }
@@ -595,21 +596,21 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op)
        for (i = 0; i < num_total; i++) {
                fm = f_ext[i].f;
                if (!BMO_elem_flag_test(bm, fm, FACE_MARK)  && !BM_elem_flag_test(fm, BM_ELEM_HIDDEN)) {
-                       int cont = 1;
-                       for (idx = 0; idx < num_sels && cont == 1; idx++) {
+                       int cont = TRUE;
+                       for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
                                fs = f_ext[indices[idx]].f;
                                switch (type) {
                                        case SIMFACE_MATERIAL:
                                                if (fm->mat_nr == fs->mat_nr) {
                                                        BMO_elem_flag_enable(bm, fm, FACE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
                                        case SIMFACE_IMAGE:
                                                if (f_ext[i].t == f_ext[indices[idx]].t) {
                                                        BMO_elem_flag_enable(bm, fm, FACE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
@@ -617,7 +618,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op)
                                                angle = RAD2DEGF(angle_v3v3(fs->no, fm->no));   /* if the angle between the normals -> 0 */
                                                if (angle / 180.0f <= thresh) {
                                                        BMO_elem_flag_enable(bm, fm, FACE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
@@ -626,7 +627,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op)
                                                if (angle / 180.0f <= thresh) { /* and dot product difference -> 0 */
                                                        if (fabsf(f_ext[i].d - f_ext[indices[idx]].d) <= thresh) {
                                                                BMO_elem_flag_enable(bm, fm, FACE_MARK);
-                                                               cont = 0;
+                                                               cont = FALSE;
                                                        }
                                                }
                                                break;
@@ -634,14 +635,14 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op)
                                        case SIMFACE_AREA:
                                                if (fabsf(f_ext[i].area - f_ext[indices[idx]].area) <= thresh) {
                                                        BMO_elem_flag_enable(bm, fm, FACE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
                                        case SIMFACE_PERIMETER:
                                                if (fabsf(f_ext[i].perim - f_ext[indices[idx]].perim) <= thresh) {
                                                        BMO_elem_flag_enable(bm, fm, FACE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
                                }
@@ -769,14 +770,14 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op)
        for (i = 0; i < num_total; i++) {
                e = e_ext[i].e;
                if (!BMO_elem_flag_test(bm, e, EDGE_MARK) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
-                       int cont = 1;
-                       for (idx = 0; idx < num_sels && cont == 1; idx++) {
+                       int cont = TRUE;
+                       for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
                                es = e_ext[indices[idx]].e;
                                switch (type) {
                                        case SIMEDGE_LENGTH:
                                                if (fabsf(e_ext[i].length - e_ext[indices[idx]].length) <= thresh) {
                                                        BMO_elem_flag_enable(bm, e, EDGE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
@@ -789,14 +790,14 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op)
 
                                                if (angle / 90.0f <= thresh) {
                                                        BMO_elem_flag_enable(bm, e, EDGE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
                                        case SIMEDGE_FACE:
                                                if (e_ext[i].faces == e_ext[indices[idx]].faces) {
                                                        BMO_elem_flag_enable(bm, e, EDGE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
@@ -805,12 +806,12 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op)
                                                        if (e_ext[indices[idx]].faces == 2) {
                                                                if (fabsf(e_ext[i].angle - e_ext[indices[idx]].angle) <= thresh) {
                                                                        BMO_elem_flag_enable(bm, e, EDGE_MARK);
-                                                                       cont = 0;
+                                                                       cont = FALSE;
                                                                }
                                                        }
                                                }
                                                else {
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
@@ -823,7 +824,7 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op)
 
                                                        if (c1 && c2 && fabsf(*c1 - *c2) <= thresh) {
                                                                BMO_elem_flag_enable(bm, e, EDGE_MARK);
-                                                               cont = 0;
+                                                               cont = FALSE;
                                                        }
                                                }
                                                break;
@@ -831,14 +832,14 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op)
                                        case SIMEDGE_SEAM:
                                                if (BM_elem_flag_test(e, BM_ELEM_SEAM) == BM_elem_flag_test(es, BM_ELEM_SEAM)) {
                                                        BMO_elem_flag_enable(bm, e, EDGE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
                                        case SIMEDGE_SHARP:
                                                if (BM_elem_flag_test(e, BM_ELEM_SMOOTH) == BM_elem_flag_test(es, BM_ELEM_SMOOTH)) {
                                                        BMO_elem_flag_enable(bm, e, EDGE_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
                                }
@@ -925,22 +926,22 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op)
        for (i = 0; i < num_total; i++) {
                v = v_ext[i].v;
                if (!BMO_elem_flag_test(bm, v, VERT_MARK) && !BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
-                       int cont = 1;
-                       for (idx = 0; idx < num_sels && cont == 1; idx++) {
+                       int cont = TRUE;
+                       for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
                                vs = v_ext[indices[idx]].v;
                                switch (type) {
                                        case SIMVERT_NORMAL:
                                                /* compare the angle between the normals */
                                                if (RAD2DEGF(angle_v3v3(v->no, vs->no)) / 180.0f <= thresh) {
                                                        BMO_elem_flag_enable(bm, v, VERT_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
                                        case SIMVERT_FACE:
                                                /* number of adjacent faces */
                                                if (v_ext[i].num_faces == v_ext[indices[idx]].num_faces) {
                                                        BMO_elem_flag_enable(bm, v, VERT_MARK);
-                                                       cont = 0;
+                                                       cont = FALSE;
                                                }
                                                break;
 
@@ -951,7 +952,7 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op)
                                                                for (v2 = 0; v2 < v_ext[indices[idx]].dvert->totweight; v2++) {
                                                                        if (v_ext[i].dvert->dw[v1].def_nr == v_ext[indices[idx]].dvert->dw[v2].def_nr) {
                                                                                BMO_elem_flag_enable(bm, v, VERT_MARK);
-                                                                               cont = 0;
+                                                                               cont = FALSE;
                                                                                break;
                                                                        }
                                                                }
index 23e4ad7e2896e688ce4588d8850169eafc2b464b..134b7f9eb0cdeb391daf186797de19ef13e662d4 100644 (file)
@@ -731,7 +731,10 @@ static void BME_bevel_add_vweight(BME_TransData_Head *td, BMesh *bm, BMVert *v,
 {
        BME_TransData *vtd;
 
-       if (BMO_elem_flag_test(bm, v, BME_BEVEL_NONMAN)) return;
+       if (BMO_elem_flag_test(bm, v, BME_BEVEL_NONMAN)) {
+               return;
+       }
+
        BMO_elem_flag_enable(bm, v, BME_BEVEL_BEVEL);
        if ((vtd = BME_get_transdata(td, v))) {
                if (options & BME_BEVEL_EMIN) {
@@ -767,18 +770,23 @@ static void bevel_init_verts(BMesh *bm, int options, BME_TransData_Head *td)
        BMIter iter;
        float weight;
        BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
-               weight = 0.0;
+               weight = 0.0f;
                if (!BMO_elem_flag_test(bm, v, BME_BEVEL_NONMAN)) {
                        /* modifiers should not use selection */
                        if (options & BME_BEVEL_SELECT) {
-                               if(BM_elem_flag_test(v, BM_ELEM_SELECT)) weight = 1.0;
+                               if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
+                                       weight = 1.0f;
+                               }
                        }
                        /* bevel weight NYI */
-                       else if(options & BME_BEVEL_WEIGHT)
+                       else if (options & BME_BEVEL_WEIGHT) {
                                weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT);
-                       else
-                               weight = 1.0;
-                       if(weight > 0.0) {
+                       }
+                       else {
+                               weight = 1.0f;
+                       }
+
+                       if (weight > 0.0f) {
                                BMO_elem_flag_enable(bm, v, BME_BEVEL_BEVEL);
                                BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, weight, -1, NULL);
                        }
@@ -804,6 +812,7 @@ static void bevel_init_edges(BMesh *bm, int options, BME_TransData_Head *td)
                        else {
                                weight = 1.0;
                        }
+
                        if(weight > 0.0) {
                                BMO_elem_flag_enable(bm, e, BME_BEVEL_BEVEL);
                                BMO_elem_flag_enable(bm, e->v1, BME_BEVEL_BEVEL);
@@ -836,15 +845,18 @@ static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_ind
                BMO_elem_flag_enable(bm, v, BME_BEVEL_ORIG);
                if(v->e) {
                        BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1, NULL);
-                       if (!BM_vert_is_manifold(bm, v))
+                       if (!BM_vert_is_manifold(bm, v)) {
                                BMO_elem_flag_enable(bm, v, BME_BEVEL_NONMAN);
+                       }
+
                        /* test wire ver */
                        len = BM_vert_edge_count(v);
                        if (len == 2 && BM_vert_is_wire(bm, v))
                                BMO_elem_flag_disable(bm, v, BME_BEVEL_NONMAN);
                }
-               else
+               else {
                        BMO_elem_flag_enable(bm, v, BME_BEVEL_NONMAN);
+               }
        }
 
        BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
@@ -854,13 +866,22 @@ static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_ind
                        BMO_elem_flag_enable(bm, e->v2, BME_BEVEL_NONMAN);
                        BMO_elem_flag_enable(bm, e, BME_BEVEL_NONMAN);
                }
-               if(BMO_elem_flag_test(bm, e->v1, BME_BEVEL_NONMAN) || BMO_elem_flag_test(bm, e->v2, BME_BEVEL_NONMAN)) BMO_elem_flag_enable(bm, e, BME_BEVEL_NONMAN);
+               if(BMO_elem_flag_test(bm, e->v1, BME_BEVEL_NONMAN) || BMO_elem_flag_test(bm, e->v2, BME_BEVEL_NONMAN)) {
+                       BMO_elem_flag_enable(bm, e, BME_BEVEL_NONMAN);
+               }
        }
 
-       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL)
+       BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
                BMO_elem_flag_enable(bm, f, BME_BEVEL_ORIG);
-       if(options & BME_BEVEL_VERT) bevel_init_verts(bm, options, td);
-       else bevel_init_edges(bm, options, td);
+       }
+
+       if(options & BME_BEVEL_VERT) {
+               bevel_init_verts(bm, options, td);
+       }
+       else {
+               bevel_init_edges(bm, options, td);
+       }
+
        return bm;
 
 }
index 65d44928e3730cb244685e618bdafc9e14429792..ec64caa82539beb6fb9ec9180e0c06fca875a614 100644 (file)
@@ -1162,27 +1162,25 @@ static void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *e, int val
                BM_elem_select_set(em->bm, e, val);
                break;
        case EDGE_MODE_TAG_SEAM:
-               if (val)                {BM_elem_flag_enable(e, BM_ELEM_SEAM);}
-               else                    {BM_elem_flag_disable(e, BM_ELEM_SEAM);}
+               BM_elem_flag_set(e, BM_ELEM_SEAM, val);
                break;
        case EDGE_MODE_TAG_SHARP:
-               if (val)                {BM_elem_flag_disable(e, BM_ELEM_SMOOTH);}
-               else                    {BM_elem_flag_enable(e, BM_ELEM_SMOOTH);}
+               BM_elem_flag_set(e, BM_ELEM_SMOOTH, !val);
                break;
        case EDGE_MODE_TAG_CREASE:
         {
                float *crease = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_CREASE);
                
-               if (val)                {*crease = 1.0f;}
-               else                    {*crease = 0.0f;}
+               if (val)                *crease = 1.0f;
+               else                    *crease = 0.0f;
                break;
         }
        case EDGE_MODE_TAG_BEVEL:
         {
                float *bweight = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_BWEIGHT);
 
-               if (val)                {*bweight = 1.0f;}
-               else                    {*bweight = 0.0f;}
+               if (val)                *bweight = 1.0f;
+               else                    *bweight = 0.0f;
                break;
         }
        }
@@ -1786,9 +1784,10 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event
                        return OPERATOR_CANCELLED;
 
                if (limit) {
+                       /* hflag no-seam --> bmo-tag */
                        BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
-                               if (!BM_elem_flag_test(e, BM_ELEM_SEAM)) BMO_elem_flag_enable(bm, e, BM_ELEM_SELECT);
-                               else                           BMO_elem_flag_disable(bm, e, BM_ELEM_SELECT); /* is this needed ? */
+                               /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */
+                               BMO_elem_flag_set(bm, e, BM_ELEM_SELECT, !BM_elem_flag_test(e, BM_ELEM_SEAM));
                        }
                }
 
@@ -1868,18 +1867,14 @@ static int select_linked_exec(bContext *C, wmOperator *op)
                BMFace *efa;
 
                BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
-                       if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
-                               BM_elem_flag_enable(efa, BM_ELEM_TAG);
-                       }
-                       else {
-                               BM_elem_flag_disable(efa, BM_ELEM_TAG);
-                       }
+                       BM_elem_flag_set(efa, BM_ELEM_TAG, (BM_elem_flag_test(efa, BM_ELEM_SELECT) &&
+                                                           !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)));
                }
 
                if (limit) {
                        BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
-                               if (!BM_elem_flag_test(e, BM_ELEM_SEAM)) BMO_elem_flag_enable(bm, e, BM_ELEM_SELECT);
-                               else                           BMO_elem_flag_disable(bm, e, BM_ELEM_SELECT); /* is this needed ? */
+                               /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */
+                               BMO_elem_flag_set(bm, e, BM_ELEM_SELECT, !BM_elem_flag_test(e, BM_ELEM_SEAM));
                        }
                }
 
@@ -2044,6 +2039,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h
        BMO_push(bm, NULL);
        BM_ITER(h, &iter, bm, itertype, NULL) {
                if (BM_elem_flag_test(h, BM_ELEM_SELECT)) {
+                       /* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */
                        BMO_elem_flag_enable(bm, (BMElemF *)h, BM_ELEM_SELECT);
                }
        }
index ada11483f36dfaa7de89e5a52d07e09a30b7aa8c..91aaa36c77d5a935b8ae50435046c7a0a4972ae7 100644 (file)
@@ -1500,15 +1500,11 @@ void EDBM_reveal_mesh(BMEditMesh *em)
     BMHeader *ele;
        int i;
 
-       /* Use index field to remember what was hidden before all is revealed. */
+       /* Use tag flag to remember what was hidden before all is revealed.
+        * BM_ELEM_HIDDEN --> BM_ELEM_TAG */
        for (i = 0; i < 3; i++) {
                BM_ITER(ele, &iter, em->bm, iter_types[i], NULL) {
-                       if (BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
-                               BM_elem_flag_enable(ele, BM_ELEM_TAG);
-                       }
-                       else {
-                               BM_elem_flag_disable(ele, BM_ELEM_TAG);
-                       }
+                       BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_HIDDEN));
                }
        }
 
@@ -1759,10 +1755,7 @@ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth)
        
        BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
                if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
-                       if (smooth)
-                               BM_elem_flag_enable(efa, BM_ELEM_SMOOTH);
-                       else
-                               BM_elem_flag_disable(efa, BM_ELEM_SMOOTH);
+                       BM_elem_flag_set(efa, BM_ELEM_SMOOTH, smooth);
                }
        }
 }
@@ -2365,13 +2358,9 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
 
+       /* BM_ELEM_SELECT --> BM_ELEM_TAG */
        BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-               if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
-                       BM_elem_flag_enable(e, BM_ELEM_TAG);
-               }
-               else {
-                       BM_elem_flag_disable(e, BM_ELEM_TAG);
-               }
+               BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT));
        }
 
        /* handle case of one vert selected.  identify
@@ -2507,12 +2496,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
        BMO_slot_buffer_hflag_enable(bm, &bmop, side?"edgeout2":"edgeout1", BM_ELEM_SELECT, BM_EDGE, TRUE);
 
        BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
-               if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
-                       BM_elem_flag_enable(e, BM_ELEM_TAG);
-               }
-               else {
-                       BM_elem_flag_disable(e, BM_ELEM_TAG);
-               }
+               BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT));
        }
 
        /* constrict edge selection again */
index 22bf1daa6e105b1bd63a5acea052f9981ff4f48e..67adac9bea2b93586391a891ca3daa60f238d632 100644 (file)
@@ -2053,12 +2053,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
        // transform now requires awareness for select mode, so we tag the f1 flags in verts
        if(selectmode & SCE_SELECT_VERTEX) {
                BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
-                       if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
-                               BM_elem_flag_enable(eve, BM_ELEM_TAG);
-                       }
-                       else {
-                               BM_elem_flag_disable(eve, BM_ELEM_TAG);
-                       }
+                       BM_elem_flag_set(eve, BM_ELEM_TAG, BM_elem_flag_test(eve, BM_ELEM_SELECT));
                }
        }
        else if(selectmode & SCE_SELECT_EDGE) {
index 4a6ef28baac2c720026801846c8dc3489ca59d9f..3deb4636200b34cb85670d240bc442fc7481aa03 100644 (file)
@@ -1437,12 +1437,8 @@ static void weld_align_uv(bContext *C, int tool)
 
                /* flush vertex tags to edges */
                BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
-                       if (BM_elem_flag_test(eed->v1, BM_ELEM_TAG) && BM_elem_flag_test(eed->v2, BM_ELEM_TAG)) {
-                               BM_elem_flag_enable(eed, BM_ELEM_TAG);
-                       }
-                       else {
-                               BM_elem_flag_disable(eed, BM_ELEM_TAG);
-                       }
+                       BM_elem_flag_set(eed, BM_ELEM_TAG, (BM_elem_flag_test(eed->v1, BM_ELEM_TAG) &&
+                                                           BM_elem_flag_test(eed->v2, BM_ELEM_TAG)));
                }
 
                /* find a vertex with only one tagged edge */