correct problem with limited-dissolve not leaving the selection correctly (caused...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 25 Jul 2013 06:05:44 +0000 (06:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 25 Jul 2013 06:05:44 +0000 (06:05 +0000)
source/blender/bmesh/intern/bmesh_opdefines.c
source/blender/bmesh/operators/bmo_dissolve.c
source/blender/bmesh/tools/bmesh_decimate.h
source/blender/bmesh/tools/bmesh_decimate_dissolve.c
source/blender/editors/mesh/editmesh_tools.c

index 497c9e1c153d6ff80329754a71f5b124144ffa9a..784732295edc8d4851b900fe8561eefd6b73f8b7 100644 (file)
@@ -947,7 +947,9 @@ static BMOpDefine bmo_dissolve_limit_def = {
         {"delimit", BMO_OP_SLOT_INT},
         {{'\0'}},
        },
         {"delimit", BMO_OP_SLOT_INT},
         {{'\0'}},
        },
-       {{{'\0'}}},  /* no output */
+       /* slots_out */
+       {{"region.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
+        {{'\0'}}},
        bmo_dissolve_limit_exec,
        BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
        bmo_dissolve_limit_exec,
        BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
@@ -1044,7 +1046,7 @@ static BMOpDefine bmo_subdivide_edgering_def = {
         {{'\0'}},
        },
        {{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* output faces */
         {{'\0'}},
        },
        {{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* output faces */
-        {{'\0'}}},  /* no output */
+        {{'\0'}}},
        bmo_subdivide_edgering_exec,
        BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
        bmo_subdivide_edgering_exec,
        BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC | BMO_OPTYPE_FLAG_SELECT_FLUSH,
 };
@@ -1224,7 +1226,6 @@ static BMOpDefine bmo_rotate_uvs_def = {
         {"use_ccw", BMO_OP_SLOT_BOOL},         /* rotate counter-clockwise if true, otherwise clockwise */
         {{'\0'}},
        },
         {"use_ccw", BMO_OP_SLOT_BOOL},         /* rotate counter-clockwise if true, otherwise clockwise */
         {{'\0'}},
        },
-       /* slots_out */
        {{{'\0'}}},  /* no output */
        bmo_rotate_uvs_exec,
        BMO_OPTYPE_FLAG_NOP,
        {{{'\0'}}},  /* no output */
        bmo_rotate_uvs_exec,
        BMO_OPTYPE_FLAG_NOP,
index e4f2423ca17805d995768890bd6af663735c9429..a3f674503806e87d95045a75b3ad454b99926d18 100644 (file)
@@ -430,5 +430,8 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op)
 
        BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries, delimit,
                                     (BMVert **)BMO_SLOT_AS_BUFFER(vinput), vinput->len,
 
        BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries, delimit,
                                     (BMVert **)BMO_SLOT_AS_BUFFER(vinput), vinput->len,
-                                    (BMEdge **)BMO_SLOT_AS_BUFFER(einput), einput->len);
+                                    (BMEdge **)BMO_SLOT_AS_BUFFER(einput), einput->len,
+                                    FACE_NEW);
+
+       BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "region.out", BM_FACE, FACE_NEW);
 }
 }
index c77cb18c5187c980b7b51e9aa6a84e3ca17f5f97..a1b26990587eb429409c571ee0802dba92b3afc5 100644 (file)
@@ -35,7 +35,8 @@ void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations);
 void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                   const BMO_Delimit delimit,
                                   BMVert **vinput_arr, const int vinput_len,
 void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                   const BMO_Delimit delimit,
                                   BMVert **vinput_arr, const int vinput_len,
-                                  BMEdge **einput_arr, const int einput_len);
+                                  BMEdge **einput_arr, const int einput_len,
+                                  const short oflag_out);
 void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                const BMO_Delimit delimit);
 
 void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                const BMO_Delimit delimit);
 
index 9d4e01d19cd64ca0511e62704e1ebb6304bbc63e..9f97d8f4287c39a442db13e89b18372796d8ef6a 100644 (file)
@@ -72,7 +72,8 @@ static int dissolve_elem_cmp(const void *a1, const void *a2)
 void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                   const BMO_Delimit delimit,
                                   BMVert **vinput_arr, const int vinput_len,
 void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool do_dissolve_boundaries,
                                   const BMO_Delimit delimit,
                                   BMVert **vinput_arr, const int vinput_len,
-                                  BMEdge **einput_arr, const int einput_len)
+                                  BMEdge **einput_arr, const int einput_len,
+                                  const short oflag_out)
 {
        const float angle_max = (float)M_PI / 2.0f;
        DissolveElemWeight *weight_elems = MEM_mallocN(max_ii(einput_len, vinput_len) *
 {
        const float angle_max = (float)M_PI / 2.0f;
        DissolveElemWeight *weight_elems = MEM_mallocN(max_ii(einput_len, vinput_len) *
@@ -155,6 +156,9 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool
                                /* there may be some errors, we don't mind, just move on */
                                if (f_new) {
                                        BM_face_normal_update(f_new);
                                /* there may be some errors, we don't mind, just move on */
                                if (f_new) {
                                        BM_face_normal_update(f_new);
+                                       if (oflag_out) {
+                                               BMO_elem_flag_enable(bm, f_new, oflag_out);
+                                       }
                                }
                                else {
                                        BMO_error_clear(bm);
                                }
                                else {
                                        BMO_error_clear(bm);
@@ -269,7 +273,8 @@ void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const bool do
        BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries,
                                     delimit,
                                     vinput_arr, vinput_len,
        BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries,
                                     delimit,
                                     vinput_arr, vinput_len,
-                                    einput_arr, einput_len);
+                                    einput_arr, einput_len,
+                                    0);
 
        MEM_freeN(vinput_arr);
        MEM_freeN(einput_arr);
 
        MEM_freeN(vinput_arr);
        MEM_freeN(einput_arr);
index e152c83fb9af12df1f4cc6edb64741282e2e372b..f27f69b4d302b0f652f00d4cd851ed5ce31d3127 100644 (file)
@@ -3057,6 +3057,7 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
        BMesh *bm = em->bm;
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
        BMesh *bm = em->bm;
+       BMOperator bmop;
        const float angle_limit = RNA_float_get(op->ptr, "angle_limit");
        const bool use_dissolve_boundaries = RNA_boolean_get(op->ptr, "use_dissolve_boundaries");
        const int delimit = RNA_enum_get(op->ptr, "delimit");
        const float angle_limit = RNA_float_get(op->ptr, "angle_limit");
        const bool use_dissolve_boundaries = RNA_boolean_get(op->ptr, "use_dissolve_boundaries");
        const int delimit = RNA_enum_get(op->ptr, "delimit");
@@ -3094,10 +3095,12 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
                dissolve_flag = BM_ELEM_SELECT;
        }
 
                dissolve_flag = BM_ELEM_SELECT;
        }
 
-       if (!EDBM_op_callf(em, op,
-                          "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b delimit=%i",
-                          dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries, delimit))
-       {
+       EDBM_op_init(em, &bmop, op,
+                    "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b delimit=%i",
+                    dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries, delimit);
+       BMO_op_exec(em->bm, &bmop);
+       BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "region.out", BM_FACE, BM_ELEM_SELECT, true);
+       if (!EDBM_op_finish(em, &bmop, op, true)) {
                return OPERATOR_CANCELLED;
        }
 
                return OPERATOR_CANCELLED;
        }