triangulate and beauty fill also needed changes to selection handling after recent...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 25 Jul 2013 07:00:07 +0000 (07:00 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 25 Jul 2013 07:00:07 +0000 (07:00 +0000)
source/blender/bmesh/operators/bmo_beautify.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/editors/mesh/mesh_intern.h

index 2c0bc7f95d9bd2f44a44edbcd0dbac3bf111d3b3..8755977acda27538b8ed80e3388104b74cf86063 100644 (file)
@@ -415,9 +415,9 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
 
                /* edge is manifold and can be rotated */
                if (BM_edge_rotate_check(e) &&
-                       /* faces are tagged */
-                       BMO_elem_flag_test(bm, e->l->f, FACE_MARK) &&
-                       BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK))
+                   /* faces are tagged */
+                   BMO_elem_flag_test(bm, e->l->f, FACE_MARK) &&
+                   BMO_elem_flag_test(bm, e->l->radial_next->f, FACE_MARK))
                {
                        BM_elem_index_set(e, edge_array_len);  /* set_dirty */
                        BM_elem_flag_enable(e, BM_ELEM_TAG);
index e544592365de55adeb81e133cd7b673c511d97e3..f372053db559ee51e92e9dee59420469e5a02660 100644 (file)
@@ -118,9 +118,10 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Plane"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
-                                     1, 1, RNA_float_get(op->ptr, "radius"), mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
+               1, 1, RNA_float_get(op->ptr, "radius"), mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -162,8 +163,10 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cube"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_cube matrix=%m4 size=%f",
-                                     mat, RNA_float_get(op->ptr, "radius") * 2.0f))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_cube matrix=%m4 size=%f",
+               mat, RNA_float_get(op->ptr, "radius") * 2.0f))
        {
                return OPERATOR_CANCELLED;
        }
@@ -216,10 +219,11 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Circle"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4",
-                                     RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
-                                     cap_end, cap_tri, mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_circle segments=%i diameter=%f cap_ends=%b cap_tris=%b matrix=%m4",
+               RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
+               cap_end, cap_tri, mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -269,7 +273,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
        em = BKE_editmesh_from_object(obedit);
 
        if (!EDBM_op_call_and_selectf(
-               em, op, "verts.out",
+               em, op, "verts.out", false,
                "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4",
                RNA_int_get(op->ptr, "vertices"),
                RNA_float_get(op->ptr, "radius"),
@@ -329,7 +333,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op)
        em = BKE_editmesh_from_object(obedit);
 
        if (!EDBM_op_call_and_selectf(
-               em, op, "verts.out",
+               em, op, "verts.out", false,
                "create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4",
                RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
                RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
@@ -385,11 +389,12 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Grid"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
-                                     RNA_int_get(op->ptr, "x_subdivisions"),
-                                     RNA_int_get(op->ptr, "y_subdivisions"),
-                                     RNA_float_get(op->ptr, "radius"), mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_grid x_segments=%i y_segments=%i size=%f matrix=%m4",
+               RNA_int_get(op->ptr, "x_subdivisions"),
+               RNA_int_get(op->ptr, "y_subdivisions"),
+               RNA_float_get(op->ptr, "radius"), mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -444,7 +449,10 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
 
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_monkey matrix=%m4", mat)) {
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out",  false,
+               "create_monkey matrix=%m4", mat))
+       {
                return OPERATOR_CANCELLED;
        }
 
@@ -485,10 +493,11 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op)
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Sphere"), &dia, mat, &was_editmode, loc, rot, layer);
        em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_call_and_selectf(em, op, "verts.out",
-                                     "create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4",
-                                     RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"),
-                                     RNA_float_get(op->ptr, "size"), mat))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "verts.out", false,
+               "create_uvsphere u_segments=%i v_segments=%i diameter=%f matrix=%m4",
+               RNA_int_get(op->ptr, "segments"), RNA_int_get(op->ptr, "ring_count"),
+               RNA_float_get(op->ptr, "size"), mat))
        {
                return OPERATOR_CANCELLED;
        }
@@ -538,7 +547,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
        em = BKE_editmesh_from_object(obedit);
 
        if (!EDBM_op_call_and_selectf(
-               em, op, "verts.out",
+               em, op, "verts.out", false,
                "create_icosphere subdivisions=%i diameter=%f matrix=%m4",
                RNA_int_get(op->ptr, "subdivisions"),
                RNA_float_get(op->ptr, "size"), mat))
index f27f69b4d302b0f652f00d4cd851ed5ce31d3127..1586138a4d396b55440b03d27bc5223a363fb7c3 100644 (file)
@@ -2759,8 +2759,13 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
        Object *obedit = CTX_data_edit_object(C);
        BMEditMesh *em = BKE_editmesh_from_object(obedit);
 
-       if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf edges=ae", BM_ELEM_SELECT))
+       if (!EDBM_op_call_and_selectf(
+               em, op, "geom.out", true,
+               "beautify_fill faces=%hf edges=ae",
+               BM_ELEM_SELECT))
+       {
                return OPERATOR_CANCELLED;
+       }
 
        EDBM_update_generic(em, true, true);
        
@@ -2855,11 +2860,14 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op)
        EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty);
        BMO_op_exec(em->bm, &bmop);
 
+       BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
+
        /* now call beauty fill */
        if (use_beauty) {
-               EDBM_op_callf(em, op,
-                             "beautify_fill faces=%S edges=%S",
-                             &bmop, "faces.out", &bmop, "edges.out");
+               EDBM_op_call_and_selectf(
+                           em, op, "geom.out", true,
+                           "beautify_fill faces=%S edges=%S",
+                           &bmop, "faces.out", &bmop, "edges.out");
        }
 
        if (!EDBM_op_finish(em, &bmop, op, true)) {
@@ -3057,7 +3065,6 @@ 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;
-       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");
@@ -3095,14 +3102,10 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
                dissolve_flag = BM_ELEM_SELECT;
        }
 
-       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;
-       }
+       EDBM_op_call_and_selectf(
+                   em, op, "region.out", true,
+                   "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_update_generic(em, true, true);
 
index f64ea569100df2b601c35a9126298e56278b8fdb..3a3a734eef03201c169ce9907234a2d0016016e9 100644 (file)
@@ -270,7 +270,9 @@ bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...)
        return EDBM_op_finish(em, &bmop, op, true);
 }
 
-bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_slot_out, const char *fmt, ...)
+bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op,
+                              const char *select_slot_out, const bool select_extend,
+                              const char *fmt, ...)
 {
        BMOpSlot *slot_select_out;
        BMesh *bm = em->bm;
@@ -294,8 +296,11 @@ bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select
 
        slot_select_out = BMO_slot_get(bmop.slots_out, select_slot_out);
        hflag = slot_select_out->slot_subtype.elem & BM_ALL_NOLOOP;
+       BLI_assert(hflag != 0);
 
-       BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
+       if (select_extend == false) {
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
+       }
 
        BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, select_slot_out, hflag, BM_ELEM_SELECT, true);
 
index 69f471670edf8c52905663f524446800f4410f42..66079e37b913f0ea77b544223127d65168cae60f 100644 (file)
@@ -59,7 +59,8 @@ struct LinkNode;
 /* Calls a bmesh op, reporting errors to the user, etc */
 bool EDBM_op_callf(struct BMEditMesh *em, struct wmOperator *op, const char *fmt, ...);
 bool EDBM_op_call_and_selectf(struct BMEditMesh *em, struct wmOperator *op,
-                              const char *selectslot, const char *fmt, ...);
+                              const char *select_slot, const bool select_replace,
+                              const char *fmt, ...);
 /* Same as above, but doesn't report errors.*/
 bool EDBM_op_call_silentf(struct BMEditMesh *em, const char *fmt, ...);