Commit: 1f55044617d167e81bc56cc359a1adf886045447
Author: Campbell Barton
Date:   Thu Jul 24 03:26:24 2014 +1000
Branches: master
https://developer.blender.org/rB1f55044617d167e81bc56cc359a1adf886045447

Editmesh: Add option to tear boundary vertices when dissolving

===================================================================

M       source/blender/bmesh/intern/bmesh_opdefines.c
M       source/blender/bmesh/operators/bmo_dissolve.c
M       source/blender/editors/mesh/editmesh_tools.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c 
b/source/blender/bmesh/intern/bmesh_opdefines.c
index b9da761..7dc46cf 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -956,6 +956,7 @@ static BMOpDefine bmo_dissolve_verts_def = {
        /* slots_in */
        {{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},
         {"use_face_split", BMO_OP_SLOT_BOOL},
+        {"use_boundary_tear", BMO_OP_SLOT_BOOL},
         {{'\0'}},
        },
        {{{'\0'}}},  /* no output */
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c 
b/source/blender/bmesh/operators/bmo_dissolve.c
index 209ca30..84d3cda 100644
--- a/source/blender/bmesh/operators/bmo_dissolve.c
+++ b/source/blender/bmesh/operators/bmo_dissolve.c
@@ -51,6 +51,7 @@
 #define VERT_MARK_PAIR 4
 #define VERT_TAG    2
 #define VERT_ISGC   8
+#define VERT_MARK_TEAR 16
 
 
 
@@ -85,7 +86,7 @@ static bool UNUSED_FUNCTION(check_hole_in_region) (BMesh *bm, 
BMFace *f)
        return true;
 }
 
-static void bm_face_split(BMesh *bm, const short oflag)
+static void bm_face_split(BMesh *bm, const short oflag, bool use_edge_delete)
 {
        BMIter iter;
        BMVert *v;
@@ -104,6 +105,12 @@ static void bm_face_split(BMesh *bm, const short oflag)
                                                }
                                        }
                                }
+                               /* remove surrounding edges & faces */
+                               if (use_edge_delete) {
+                                       while (v->e) {
+                                               BM_edge_kill(bm, v->e);
+                                       }
+                               }
                        }
                }
        }
@@ -268,7 +275,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
                        }
                }
 
-               bm_face_split(bm, VERT_TAG);
+               bm_face_split(bm, VERT_TAG, false);
        }
 
        if (use_verts) {
@@ -345,13 +352,30 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op)
        BMFace *act_face = bm->act_face;
 
        const bool use_face_split = BMO_slot_bool_get(op->slots_in, 
"use_face_split");
+       const bool use_boundary_tear = BMO_slot_bool_get(op->slots_in, 
"use_boundary_tear");
 
        BMO_ITER (v, &oiter, op->slots_in, "verts", BM_VERT) {
                BMO_elem_flag_enable(bm, v, VERT_MARK | VERT_ISGC);
        }
 
        if (use_face_split) {
-               bm_face_split(bm, VERT_MARK);
+               bm_face_split(bm, VERT_MARK, false);
+       }
+
+       if (use_boundary_tear) {
+               BMO_ITER (v, &oiter, op->slots_in, "verts", BM_VERT) {
+                       if (!BM_vert_is_edge_pair(v)) {
+                               BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
+                                       if (BM_edge_is_boundary(e)) {
+                                               BMO_elem_flag_enable(bm, v, 
VERT_MARK_TEAR);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               if (!use_face_split) {
+                       bm_face_split(bm, VERT_MARK_TEAR, true);
+               }
        }
 
        BMO_ITER (v, &oiter, op->slots_in, "verts", BM_VERT) {
diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index 233de9c..2ee5555 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -3479,6 +3479,11 @@ static void 
edbm_dissolve_prop__use_face_split(wmOperatorType *ot)
        RNA_def_boolean(ot->srna, "use_face_split", 0, "Face Split",
                        "Split off face corners to maintain surrounding 
geometry");
 }
+static void edbm_dissolve_prop__use_boundary_tear(wmOperatorType *ot)
+{
+       RNA_def_boolean(ot->srna, "use_boundary_tear", 0, "Tear Boundary",
+                       "Split off face corners instead of merging faces");
+}
 
 static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op)
 {
@@ -3486,8 +3491,11 @@ static int edbm_dissolve_verts_exec(bContext *C, 
wmOperator *op)
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
 
        const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split");
+       const bool use_boundary_tear = RNA_boolean_get(op->ptr, 
"use_boundary_tear");
 
-       if (!EDBM_op_callf(em, op, "dissolve_verts verts=%hv 
use_face_split=%b", BM_ELEM_SELECT, use_face_split))
+       if (!EDBM_op_callf(em, op,
+                          "dissolve_verts verts=%hv use_face_split=%b 
use_boundary_tear=%b",
+                          BM_ELEM_SELECT, use_face_split, use_boundary_tear))
                return OPERATOR_CANCELLED;
 
        EDBM_update_generic(em, true, true);
@@ -3510,6 +3518,7 @@ void MESH_OT_dissolve_verts(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        edbm_dissolve_prop__use_face_split(ot);
+       edbm_dissolve_prop__use_boundary_tear(ot);
 }
 
 static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op)
@@ -3621,6 +3630,7 @@ void MESH_OT_dissolve_mode(wmOperatorType *ot)
 
        edbm_dissolve_prop__use_verts(ot);
        edbm_dissolve_prop__use_face_split(ot);
+       edbm_dissolve_prop__use_boundary_tear(ot);
 }
 
 static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to