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:
authorMartin Poirier <theeth@yahoo.com>2010-02-01 21:30:00 +0300
committerMartin Poirier <theeth@yahoo.com>2010-02-01 21:30:00 +0300
commit46b0e90cf68cbc983afdabc4ea8572fc5a6938a2 (patch)
tree7a1efe61e0a2d7227124064fb49338b99d64759f /source/blender/editors/mesh
parentbfdf6d139e4935bbdd35b1766f92b754311cde39 (diff)
Mesh Extrude menu
Todo for Campbell: - Make menu context sensitive - Make menu automatically run the operator if there is only one option Note: Saved configurations and keymaps with references to "Extrude and Move" operator needs to be updated to either call the menu or one of the new extrude macros.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c115
-rw-r--r--source/blender/editors/mesh/mesh_ops.c26
2 files changed, 63 insertions, 78 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 38c3565d67a..f601dcb06cf 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -623,46 +623,16 @@ void hashvert_flag(EditMesh *em, int flag)
}
/* generic extern called extruder */
-void extrude_mesh(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op)
+void extrude_mesh(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op, short type)
{
float nor[3]= {0.0, 0.0, 0.0};
- short nr, transmode= 0;
+ short transmode= 0;
- /* extrude depends on totvertsel etc */
- EM_stats_update(em);
-
- if(em->selectmode & SCE_SELECT_VERTEX) {
- if(em->totvertsel==0) nr= 0;
- else if(em->totvertsel==1) nr= 4;
- else if(em->totedgesel==0) nr= 4;
- else if(em->totfacesel==0)
- nr= 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
- else if(em->totfacesel==1)
- nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
- else
- nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
- }
- else if(em->selectmode & SCE_SELECT_EDGE) {
- if (em->totedgesel==0) nr = 0;
- else if (em->totedgesel==1) nr = 3;
- else if(em->totfacesel==0) nr = 3;
- else if(em->totfacesel==1)
- nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3");
- else
- nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
- }
- else {
- if (em->totfacesel == 0) nr = 0;
- else if (em->totfacesel == 1) nr = 1;
- else
- nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
- }
-
- if(nr<1) return;
+ if(type<1) return;
- if(nr==1) transmode= extrudeflag(obedit, em, SELECT, nor, 0);
- else if(nr==4) transmode= extrudeflag_verts_indiv(em, SELECT, nor);
- else if(nr==3) transmode= extrudeflag_edges_indiv(em, SELECT, nor);
+ if(type==1) transmode= extrudeflag(obedit, em, SELECT, nor, 0);
+ else if(type==4) transmode= extrudeflag_verts_indiv(em, SELECT, nor);
+ else if(type==3) transmode= extrudeflag_edges_indiv(em, SELECT, nor);
else transmode= extrudeflag_face_indiv(em, SELECT, nor);
if(transmode==0) {
@@ -682,7 +652,7 @@ void extrude_mesh(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op)
/* individual faces? */
// BIF_TransformSetUndo("Extrude");
- if(nr==2) {
+ if(type==2) {
// initTransform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_MIRROR);
// Transform();
}
@@ -706,7 +676,7 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event)
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
- extrude_mesh(scene, obedit, em, op);
+ extrude_mesh(scene, obedit, em, op, RNA_int_get(op->ptr, "type"));
BKE_mesh_end_editmesh(obedit->data, em);
@@ -723,7 +693,7 @@ static int mesh_extrude_exec(bContext *C, wmOperator *op)
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
- extrude_mesh(scene, obedit, em, op);
+ extrude_mesh(scene, obedit, em, op, RNA_int_get(op->ptr, "type"));
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
@@ -732,62 +702,69 @@ static int mesh_extrude_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-/* extrude options */
-EnumPropertyItem extrude_item_region = {1, "REGION", 0, "Region", ""};
-EnumPropertyItem extrude_item_faces = {2, "FACES", 0, "Individual Faces", ""};
-EnumPropertyItem extrude_item_edges = {3, "EDGES", 0, "Only Edges", ""};
-EnumPropertyItem extrude_item_verts = {4, "VERTS", 0, "Only Vertices", ""};
+EnumPropertyItem extrude_items[] = {
+ {1, "REGION", 0, "Region", ""},
+ {2, "FACES", 0, "Individual Faces", ""},
+ {3, "EDGES", 0, "Only Edges", ""},
+ {4, "VERTS", 0, "Only Vertices", ""},
+ {0, NULL, 0, NULL, NULL}};
+
static EnumPropertyItem *extrude_itemf(bContext *C, PointerRNA *ptr, int *free)
{
EnumPropertyItem *item= NULL;
Object *obedit= CTX_data_edit_object(C);
- EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
+ EditMesh *em;
int totitem= 0;
if(!obedit)
- return NULL;
+ return extrude_items;
+
+ em = BKE_mesh_get_editmesh(obedit->data);
+
+ EM_stats_update(em);
if(em->selectmode & SCE_SELECT_VERTEX) {
if(em->totvertsel==0) {}
- else if(em->totvertsel==1) { RNA_enum_item_add(&item, &totitem, &extrude_item_verts); }
- else if(em->totedgesel==0) { RNA_enum_item_add(&item, &totitem, &extrude_item_verts); }
+ else if(em->totvertsel==1) { RNA_enum_item_add(&item, &totitem, &extrude_items[3]); }
+ else if(em->totedgesel==0) { RNA_enum_item_add(&item, &totitem, &extrude_items[3]); }
else if(em->totfacesel==0) {
- RNA_enum_item_add(&item, &totitem, &extrude_item_edges);
- RNA_enum_item_add(&item, &totitem, &extrude_item_verts);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[2]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[3]);
}
else if(em->totfacesel==1) {
- RNA_enum_item_add(&item, &totitem, &extrude_item_region);
- RNA_enum_item_add(&item, &totitem, &extrude_item_edges);
- RNA_enum_item_add(&item, &totitem, &extrude_item_verts);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[0]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[2]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[3]);
}
else {
- RNA_enum_item_add(&item, &totitem, &extrude_item_region);
- RNA_enum_item_add(&item, &totitem, &extrude_item_edges);
- RNA_enum_item_add(&item, &totitem, &extrude_item_verts);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[0]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[1]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[2]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[3]);
}
}
else if(em->selectmode & SCE_SELECT_EDGE) {
if (em->totedgesel==0) {}
- else if (em->totedgesel==1) { RNA_enum_item_add(&item, &totitem, &extrude_item_edges); }
- else if(em->totfacesel==0) { RNA_enum_item_add(&item, &totitem, &extrude_item_edges); }
+ else if (em->totedgesel==1) { RNA_enum_item_add(&item, &totitem, &extrude_items[2]); }
+ else if(em->totfacesel==0) { RNA_enum_item_add(&item, &totitem, &extrude_items[2]); }
else if(em->totfacesel==1) {
- RNA_enum_item_add(&item, &totitem, &extrude_item_region);
- RNA_enum_item_add(&item, &totitem, &extrude_item_edges);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[0]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[2]);
}
else {
- RNA_enum_item_add(&item, &totitem, &extrude_item_region);
- RNA_enum_item_add(&item, &totitem, &extrude_item_faces);
- RNA_enum_item_add(&item, &totitem, &extrude_item_edges);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[0]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[1]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[2]);
}
}
else {
if (em->totfacesel == 0) {}
- else if (em->totfacesel == 1) { RNA_enum_item_add(&item, &totitem, &extrude_item_region); }
+ else if (em->totfacesel == 1) { RNA_enum_item_add(&item, &totitem, &extrude_items[0]); }
else {
- RNA_enum_item_add(&item, &totitem, &extrude_item_region);
- RNA_enum_item_add(&item, &totitem, &extrude_item_faces);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[0]);
+ RNA_enum_item_add(&item, &totitem, &extrude_items[1]);
}
}
@@ -803,9 +780,7 @@ static EnumPropertyItem *extrude_itemf(bContext *C, PointerRNA *ptr, int *free)
void MESH_OT_extrude(wmOperatorType *ot)
{
-#if 0
PropertyRNA *prop;
-#endif
/* identifiers */
ot->name= "Extrude";
@@ -820,12 +795,10 @@ void MESH_OT_extrude(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-#if 0
/* properties */
- prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
+ prop= RNA_def_enum(ot->srna, "type", extrude_items, 0, "Type", "");
RNA_def_enum_funcs(prop, extrude_itemf);
ot->prop= prop;
-#endif
}
static int split_mesh(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 46c7976ddc9..5dd940be785 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -188,16 +188,29 @@ void ED_operatormacros_mesh(void)
otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
- ot= WM_operatortype_append_macro("MESH_OT_extrude_move_along_normals", "Extrude Along Normals", OPTYPE_UNDO|OPTYPE_REGISTER);
- ot->poll = ED_operator_editmesh_face_select; /* restrict extrude along normals to face select */
- WM_operatortype_macro_define(ot, "MESH_OT_extrude");
+ ot= WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
+ otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude");
+ RNA_enum_set(otmacro->ptr, "type", 1);
otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_enum_set(otmacro->ptr, "constraint_orientation", V3D_MANIP_NORMAL);
RNA_boolean_set_array(otmacro->ptr, "constraint_axis", constraint_axis);
- ot= WM_operatortype_append_macro("MESH_OT_extrude_move", "Extrude and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
- WM_operatortype_macro_define(ot, "MESH_OT_extrude");
+ ot= WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
+ otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude");
+ RNA_enum_set(otmacro->ptr, "type", 2);
+ otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+
+ ot= WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
+ otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude");
+ RNA_enum_set(otmacro->ptr, "type", 3);
+ otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ RNA_enum_set(otmacro->ptr, "proportional", 0);
+
+ ot= WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
+ otmacro= WM_operatortype_macro_define(ot, "MESH_OT_extrude");
+ RNA_enum_set(otmacro->ptr, "type", 4);
otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
}
@@ -251,8 +264,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "inside", 1);
- WM_keymap_add_item(keymap, "MESH_OT_extrude_move_along_normals", EKEY, KM_PRESS, 0, 0); /* this first so it's selected if possible */
- WM_keymap_add_item(keymap, "MESH_OT_extrude_move", EKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0);