diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-08 17:48:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-08 17:48:57 +0400 |
commit | 8193d83cd99a56709609e41f1f4eb28db8aa2d29 (patch) | |
tree | c91e26cf505bb973944e9261625392d966d144a5 /source/blender/editors | |
parent | 4d842df17e8446d798f82a3f9bd54486d1c31c22 (diff) |
split dissolve into 3 different operators (face/edge/vert).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 92 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 4 |
3 files changed, 78 insertions, 22 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a80a940b117..644b6137714 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2795,50 +2795,102 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot) join_triangle_props(ot); } -static int edbm_dissolve_exec(bContext *C, wmOperator *op) +/* -------------------------------------------------------------------- */ +/* Dissolve */ + +static int edbm_dissolve_verts_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, "dissolve_verts verts=%hv", BM_ELEM_SELECT)) + return OPERATOR_CANCELLED; + + EDBM_update_generic(em, true, true); + + return OPERATOR_FINISHED; +} + +void MESH_OT_dissolve_verts(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Dissolve Vertices"; + ot->description = "Dissolve geometry"; + ot->idname = "MESH_OT_dissolve_verts"; + + /* api callbacks */ + ot->exec = edbm_dissolve_verts_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + +static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); const bool use_verts = RNA_boolean_get(op->ptr, "use_verts"); - if (em->selectmode & SCE_SELECT_FACE) { - if (!EDBM_op_callf(em, op, "dissolve_faces faces=%hf use_verts=%b", BM_ELEM_SELECT, use_verts)) - return OPERATOR_CANCELLED; - } - else if (em->selectmode & SCE_SELECT_EDGE) { - if (!EDBM_op_callf(em, op, "dissolve_edges edges=%he use_verts=%b", BM_ELEM_SELECT, use_verts)) - return OPERATOR_CANCELLED; - } - else if (em->selectmode & SCE_SELECT_VERTEX) { - if (!EDBM_op_callf(em, op, "dissolve_verts verts=%hv", BM_ELEM_SELECT)) - return OPERATOR_CANCELLED; - } + if (!EDBM_op_callf(em, op, "dissolve_edges edges=%he use_verts=%b", BM_ELEM_SELECT, use_verts)) + return OPERATOR_CANCELLED; + + EDBM_update_generic(em, true, true); + + return OPERATOR_FINISHED; +} + +void MESH_OT_dissolve_edges(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Dissolve Edges"; + ot->description = "Dissolve geometry"; + ot->idname = "MESH_OT_dissolve_edges"; + + /* api callbacks */ + ot->exec = edbm_dissolve_edges_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "use_verts", 0, "Dissolve Verts", "Dissolve remaining vertices"); +} + +static int edbm_dissolve_faces_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = BKE_editmesh_from_object(obedit); + + const bool use_verts = RNA_boolean_get(op->ptr, "use_verts"); + + if (!EDBM_op_callf(em, op, "dissolve_faces faces=%hf use_verts=%b", BM_ELEM_SELECT, use_verts)) + return OPERATOR_CANCELLED; EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } -void MESH_OT_dissolve(wmOperatorType *ot) +void MESH_OT_dissolve_faces(wmOperatorType *ot) { /* identifiers */ - ot->name = "Dissolve"; + ot->name = "Dissolve Faces"; ot->description = "Dissolve geometry"; - ot->idname = "MESH_OT_dissolve"; + ot->idname = "MESH_OT_dissolve_faces"; /* api callbacks */ - ot->exec = edbm_dissolve_exec; + ot->exec = edbm_dissolve_faces_exec; ot->poll = ED_operator_editmesh; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* TODO, move dissolve into its own operator so this doesnt confuse non-dissolve options */ - RNA_def_boolean(ot->srna, "use_verts", 0, "Dissolve Verts", - "When dissolving faces/edges, also dissolve remaining vertices"); + RNA_def_boolean(ot->srna, "use_verts", 0, "Dissolve Verts", "Dissolve remaining vertices"); } + static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 4975ade9849..3cec07414d0 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -196,7 +196,9 @@ void MESH_OT_fill(struct wmOperatorType *ot); void MESH_OT_beautify_fill(struct wmOperatorType *ot); void MESH_OT_quads_convert_to_tris(struct wmOperatorType *ot); void MESH_OT_tris_convert_to_quads(struct wmOperatorType *ot); -void MESH_OT_dissolve(struct wmOperatorType *ot); +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_edge_face_add(struct wmOperatorType *ot); void MESH_OT_duplicate(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 45902ed47a3..f27479b57a3 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -101,7 +101,9 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_beautify_fill); WM_operatortype_append(MESH_OT_quads_convert_to_tris); WM_operatortype_append(MESH_OT_tris_convert_to_quads); - WM_operatortype_append(MESH_OT_dissolve); + WM_operatortype_append(MESH_OT_dissolve_verts); + 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_faces_shade_smooth); WM_operatortype_append(MESH_OT_faces_shade_flat); |