Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-14 07:04:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-14 07:04:36 +0400
commit64d6810cd9708bd56f718718dbfbf5a5bc6bacf1 (patch)
tree15faeaed2d5f8f77a27b7d1c9c57f94f73beca06
parentb913385e32d09534b83ec6489dc820f453d62003 (diff)
Change edgeloop delete to use dissolve, fixes bug [#35738].
Was using edge-slide & remove-doubles but this was error prone since remove doubles could fail in some cases or find doubles where it shouldn't (with very small scale objects). This gives more predictable behavior when the edges of a loop wouldnt slide (in that case they would just drag over to one of the sides with no user control) and multiple edge loops work better too. eg: - http://www.graphicall.org/ftp/ideasman42/edge_loop_del_update.png
-rw-r--r--release/scripts/startup/bl_operators/wm.py24
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c57
-rw-r--r--source/blender/editors/mesh/mesh_intern.h1
-rw-r--r--source/blender/editors/mesh/mesh_ops.c1
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);