diff options
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 24 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 57 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 1 |
4 files changed, 59 insertions, 24 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 9cd9131ec4b..fd1f538efd3 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -32,30 +32,6 @@ from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear from bpy.app.translations import pgettext_tip as tip_ -class MESH_OT_delete_edgeloop(Operator): - """Delete an edge loop by merging the faces on each side """ \ - """to a single face loop""" - bl_idname = "mesh.delete_edgeloop" - bl_label = "Delete Edge Loop" - bl_options = {'UNDO', 'REGISTER'} - - @classmethod - def poll(cls, context): - return bpy.ops.transform.edge_slide.poll() - - def execute(self, context): - mesh = context.object.data - use_mirror_x = mesh.use_mirror_x - mesh.use_mirror_x = False - if 'FINISHED' in bpy.ops.transform.edge_slide(value=1.0, correct_uv=True): - bpy.ops.mesh.select_more() - bpy.ops.mesh.remove_doubles() - ret = {'FINISHED'} - else: - ret = {'CANCELLED'} - mesh.use_mirror_x = use_mirror_x - return ret - rna_path_prop = StringProperty( name="Context Attributes", description="RNA context string", diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index fa29a1e2ea8..3581902e29e 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3136,6 +3136,63 @@ void MESH_OT_dissolve_limited(wmOperatorType *ot) "Delimit dissolve operation"); } +/* internally uses dissolve */ +static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = BKE_editmesh_from_object(obedit); + + const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split"); + + /* deal with selection */ + { + BMEdge *e; + BMIter iter; + + BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false); + + BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e, BM_ELEM_SELECT)) { + BMLoop *l_iter = e->l; + do { + BM_elem_flag_enable(l_iter->f, BM_ELEM_TAG); + } while ((l_iter = l_iter->radial_next) != e->l); + } + } + } + + if (!EDBM_op_callf(em, op, + "dissolve_edges edges=%he use_verts=%b use_face_split=%b", + BM_ELEM_SELECT, true, use_face_split)) + { + return OPERATOR_CANCELLED; + } + + BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, BM_ELEM_TAG); + + EDBM_update_generic(em, true, true); + + return OPERATOR_FINISHED; +} + +void MESH_OT_delete_edgeloop(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Delete Edge Loop"; + ot->description = "Delete an edge loop by merging the faces on each side"; + ot->idname = "MESH_OT_delete_edgeloop"; + + /* api callbacks */ + ot->exec = edbm_delete_edgeloop_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "use_face_split", true, "Face Split", + "Split off face corners to maintain surrounding geometry"); +} + static int edbm_split_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 2102ede2672..bc74f4a8bf5 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -202,6 +202,7 @@ void MESH_OT_dissolve_verts(struct wmOperatorType *ot); void MESH_OT_dissolve_edges(struct wmOperatorType *ot); void MESH_OT_dissolve_faces(struct wmOperatorType *ot); void MESH_OT_dissolve_limited(struct wmOperatorType *ot); +void MESH_OT_delete_edgeloop(struct wmOperatorType *ot); void MESH_OT_edge_face_add(struct wmOperatorType *ot); void MESH_OT_duplicate(struct wmOperatorType *ot); void MESH_OT_merge(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 307377a8aa6..966d5ecb00e 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -107,6 +107,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_dissolve_edges); WM_operatortype_append(MESH_OT_dissolve_faces); WM_operatortype_append(MESH_OT_dissolve_limited); + WM_operatortype_append(MESH_OT_delete_edgeloop); WM_operatortype_append(MESH_OT_faces_shade_smooth); WM_operatortype_append(MESH_OT_faces_shade_flat); WM_operatortype_append(MESH_OT_sort_elements); |