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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-23 14:30:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-23 14:30:42 +0400
commitd3f8952269ca00e1ea7aa9d82ccb157c9074522e (patch)
tree791933f63d9d30b47ba1b23da6c0c2ca1a823fee /source
parent49ad20f55aef5eae7371ab237bc60655eecaccb6 (diff)
bmesh editmode - split dissolve into its own menu. mesh delete code was getting quite messy and mixed in too much different functionality just to add in same menu. Now use a pu menu for delete key which can call different ops.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/mesh/bmesh_tools.c208
-rw-r--r--source/blender/editors/mesh/mesh_intern.h3
-rw-r--r--source/blender/editors/mesh/mesh_ops.c9
3 files changed, 140 insertions, 80 deletions
diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c
index 6373ee57b99..2860886eaec 100644
--- a/source/blender/editors/mesh/bmesh_tools.c
+++ b/source/blender/editors/mesh/bmesh_tools.c
@@ -909,97 +909,50 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "rotate_source", 1, "Rotate Source", "Rotate initial selection giving better shape");
}
-static int delete_mesh(bContext *C, Object *obedit, wmOperator *op, int event, Scene *UNUSED(scene))
+/* Note, these values must match delete_mesh() event values */
+static EnumPropertyItem prop_mesh_delete_types[] = {
+ {0, "VERT", 0, "Vertices", ""},
+ {1, "EDGE", 0, "Edges", ""},
+ {2, "FACE", 0, "Faces", ""},
+ {3, "EDGE_FACE", 0, "Edges & Faces", ""},
+ {4, "ONLY_FACE", 0, "Only Faces", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+static int delete_mesh_exec(bContext *C, wmOperator *op)
{
- BMEditMesh *bem = BMEdit_FromObject(obedit);
-
- if (event < 1) return OPERATOR_CANCELLED;
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+ int type = RNA_enum_get(op->ptr, "type");
- if (event == 10) {
- //"Erase Vertices";
+ BMEditMesh *bem = BMEdit_FromObject(obedit);
- if (!EDBM_CallOpf(bem, op, "del geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS))
- return OPERATOR_CANCELLED;
- }
- else if (event == 11) {
- //"Edge Loop"
- if (!EDBM_CallOpf(bem, op, "dissolve_edge_loop edges=%he", BM_ELEM_SELECT))
+ if (type == 0) {
+ if (!EDBM_CallOpf(bem, op, "del geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */
return OPERATOR_CANCELLED;
}
- else if (event == 7) {
- int use_verts = RNA_boolean_get(op->ptr, "use_verts");
- //"Dissolve"
- if (bem->selectmode & SCE_SELECT_FACE) {
- if (!EDBM_CallOpf(bem, op, "dissolve_faces faces=%hf use_verts=%b", BM_ELEM_SELECT, use_verts))
- return OPERATOR_CANCELLED;
- }
- else if (bem->selectmode & SCE_SELECT_EDGE) {
- if (!EDBM_CallOpf(bem, op, "dissolve_edges edges=%he use_verts=%b", BM_ELEM_SELECT, use_verts))
- return OPERATOR_CANCELLED;
- }
- else if (bem->selectmode & SCE_SELECT_VERTEX) {
- if (!EDBM_CallOpf(bem, op, "dissolve_verts verts=%hv", BM_ELEM_SELECT))
- return OPERATOR_CANCELLED;
- }
- }
- else if (event == 4) {
- //Edges and Faces
- if (!EDBM_CallOpf(bem, op, "del geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES))
+ else if (type == 1) {
+ if (!EDBM_CallOpf(bem, op, "del geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)) /* Erase Edges */
return OPERATOR_CANCELLED;
- }
- else if (event == 1) {
- //"Erase Edges"
- if (!EDBM_CallOpf(bem, op, "del geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES))
+ }
+ else if (type == 2) {
+ if (!EDBM_CallOpf(bem, op, "del geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES)) /* Erase Faces */
return OPERATOR_CANCELLED;
}
- else if (event == 2) {
- //"Erase Faces";
- if (!EDBM_CallOpf(bem, op, "del geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES))
+ else if (type == 3) {
+ if (!EDBM_CallOpf(bem, op, "del geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES)) /* Edges and Faces */
return OPERATOR_CANCELLED;
}
- else if (event == 5) {
+ else if (type == 4) {
//"Erase Only Faces";
if (!EDBM_CallOpf(bem, op, "del geom=%hf context=%i",
BM_ELEM_SELECT, DEL_ONLYFACES))
return OPERATOR_CANCELLED;
}
-
- DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
-
- return OPERATOR_FINISHED;
-}
-/* Note, these values must match delete_mesh() event values */
-static EnumPropertyItem prop_mesh_delete_types[] = {
- {7, "DISSOLVE", 0, "Dissolve", ""},
- {12, "COLLAPSE", 0, "Collapse", ""},
- {10, "VERT", 0, "Vertices", ""},
- {1, "EDGE", 0, "Edges", ""},
- {2, "FACE", 0, "Faces", ""},
- {11, "EDGE_LOOP", 0, "Edge Loop", ""},
- {4, "EDGE_FACE", 0, "Edges & Faces", ""},
- {5, "ONLY_FACE", 0, "Only Faces", ""},
- {0, NULL, 0, NULL, NULL}
-};
+ EDBM_flag_disable_all(em, BM_ELEM_SELECT);
-static int delete_mesh_exec(bContext *C, wmOperator *op)
-{
- Object *obedit = CTX_data_edit_object(C);
- BMEditMesh *em = BMEdit_FromObject(obedit);
- Scene *scene = CTX_data_scene(C);
- int type = RNA_enum_get(op->ptr, "type");
-
- if (type != 12) {
- if (delete_mesh(C, obedit, op, type, scene) == OPERATOR_CANCELLED)
- return OPERATOR_CANCELLED;
- EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- }
- else {
- if (!EDBM_CallOpf(em, op, "collapse edges=%he", BM_ELEM_SELECT))
- return OPERATOR_CANCELLED;
- DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
- }
+ DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
@@ -1023,13 +976,66 @@ void MESH_OT_delete(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
- ot->prop = RNA_def_enum(ot->srna, "type", prop_mesh_delete_types, 10, "Type", "Method used for deleting mesh data");
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_mesh_delete_types, 0, "Type", "Method used for deleting mesh data");
+}
- /* 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");
+static int mesh_collapse_edge_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+
+ if (!EDBM_CallOpf(em, op, "collapse edges=%he", BM_ELEM_SELECT))
+ return OPERATOR_CANCELLED;
+ DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
+
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
}
+void MESH_OT_edge_collapse(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Edge Collapse";
+ ot->description = "Collapse selected edges";
+ ot->idname = "MESH_OT_edge_collapse";
+
+ /* api callbacks */
+ ot->exec = mesh_collapse_edge_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int mesh_collapse_edge_loop_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+
+ if (!EDBM_CallOpf(em, op, "dissolve_edge_loop edges=%he", BM_ELEM_SELECT))
+ return OPERATOR_CANCELLED;
+ DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
+
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_edge_collapse_loop(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Edge Collapse Loop";
+ ot->description = "Collapse selected edge loops";
+ ot->idname = "MESH_OT_edge_collapse_loop";
+
+ /* api callbacks */
+ ot->exec = mesh_collapse_edge_loop_exec;
+ ot->poll = ED_operator_editmesh;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
static int addedgeface_mesh_exec(bContext *C, wmOperator *op)
{
@@ -3566,6 +3572,52 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "materials", 0, "Compare Materials", "");
}
+static int mesh_dissolve_exec(bContext *C, wmOperator *op)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ BMEditMesh *em = BMEdit_FromObject(obedit);
+
+ int use_verts = RNA_boolean_get(op->ptr, "use_verts");
+
+ if (em->selectmode & SCE_SELECT_FACE) {
+ if (!EDBM_CallOpf(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_CallOpf(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_CallOpf(em, op, "dissolve_verts verts=%hv", BM_ELEM_SELECT))
+ return OPERATOR_CANCELLED;
+ }
+
+ DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
+
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
+
+ return OPERATOR_FINISHED;
+}
+
+void MESH_OT_dissolve(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Dissolve";
+ ot->description = "Dissolve geometry";
+ ot->idname = "MESH_OT_dissolve";
+
+ /* api callbacks */
+ ot->exec = mesh_dissolve_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");
+}
+
static int 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 3efc3d6146e..7a7a138b6b6 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -155,6 +155,7 @@ 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_limited(struct wmOperatorType *ot);
void MESH_OT_faces_shade_smooth(struct wmOperatorType *ot);
void MESH_OT_faces_shade_flat(struct wmOperatorType *ot);
@@ -175,6 +176,8 @@ void MESH_OT_colors_rotate(struct wmOperatorType *ot);
void MESH_OT_colors_reverse(struct wmOperatorType *ot);
void MESH_OT_delete(struct wmOperatorType *ot);
+void MESH_OT_edge_collapse(struct wmOperatorType *ot);
+void MESH_OT_edge_collapse_loop(struct wmOperatorType *ot);
void MESH_OT_rip(struct wmOperatorType *ot);
void MESH_OT_shape_propagate_to_all(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 3803dcd168f..556288b5171 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -114,12 +114,15 @@ 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_limited);
WM_operatortype_append(MESH_OT_faces_shade_smooth);
WM_operatortype_append(MESH_OT_faces_shade_flat);
WM_operatortype_append(MESH_OT_sort_faces);
WM_operatortype_append(MESH_OT_delete);
+ WM_operatortype_append(MESH_OT_edge_collapse);
+ WM_operatortype_append(MESH_OT_edge_collapse_loop);
WM_operatortype_append(MESH_OT_separate);
WM_operatortype_append(MESH_OT_dupli_extrude_cursor);
@@ -338,8 +341,10 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_SHIFT|KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "rotate_source", FALSE);
- WM_keymap_add_item(keymap, "MESH_OT_delete", XKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "MESH_OT_delete", DELKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_dissolve", DKEY, KM_PRESS, 0, 0);
+
+ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", XKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_knifetool", KKEY, KM_PRESS, 0, 0);
//RNA_enum_set(WM_keymap_add_item(keymap, "MESH_OT_knife_cut", LEFTMOUSE, KM_PRESS, KM_SHIFT, KKEY)->ptr, "type", 2/*KNIFE_MIDPOINT*/);