diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-31 12:23:17 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-31 12:23:17 +0300 |
commit | a60413abd177604f05e360383e3a9c2a9862529b (patch) | |
tree | 91a97029dc95dbc2046fda96bea85f74ff26c568 /source | |
parent | 5ed79ee9d92599fe1f28535896fccdc2c542688b (diff) |
2.5
Edit mesh:
- fixed compile, shul only committed the function declaration, not
the code for 'make fgon'.
- Put the Fgon option under:
ALT+F: make fgon
SHIFT+ALT+F: clear fgon
(note, SHIFT+F = fill :)
- Fixed loop select to use two booleans, as Martin pointed me
correctly at! Using 1 variable was lazy coding.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 74 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_mods.c | 17 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 2 |
5 files changed, 85 insertions, 35 deletions
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 9e1a047bf54..72c2e604b7f 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -264,7 +264,7 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot) /* ********************** */ /* selected faces get hidden edges */ -void make_fgon(EditMesh *em, int make) +int make_fgon(EditMesh *em, int make) { EditFace *efa; EditEdge *eed; @@ -272,7 +272,7 @@ void make_fgon(EditMesh *em, int make) float *nor=NULL; // reference int done=0; - if(!make) { + if(make==0) { for(efa= em->faces.first; efa; efa= efa->next) { if(efa->f & SELECT) { efa->fgonf= 0; @@ -280,12 +280,12 @@ void make_fgon(EditMesh *em, int make) efa->e2->h &= ~EM_FGON; efa->e3->h &= ~EM_FGON; if(efa->e4) efa->e4->h &= ~EM_FGON; + done= 1; } } EM_fgon_flags(em); // redo flags and indices for fgons -// XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - BIF_undo_push("Clear FGon"); - return; + + return done; } /* tagging edges. rule is: @@ -337,13 +337,13 @@ void make_fgon(EditMesh *em, int make) } if(eve) { error("Cannot make polygon with interior vertices"); - return; + return 0; } // check for faces if(nor==NULL) { error("No faces selected to make FGon"); - return; + return 0; } // and there we go @@ -354,15 +354,61 @@ void make_fgon(EditMesh *em, int make) } } - if(done==0) { - error("Didn't find FGon to create"); - } - else { + if(done) EM_fgon_flags(em); // redo flags and indices for fgons + return done; +} + +static int make_fgon_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + + if( make_fgon(em, 1) ) { + DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); + + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; + } + return OPERATOR_CANCELLED; +} + +void MESH_OT_make_fgon(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Make F-gon"; + ot->idname= "MESH_OT_make_fgon"; + + /* api callbacks */ + ot->exec= make_fgon_exec; + ot->poll= ED_operator_editmesh; +} -// XXX DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - BIF_undo_push("Make FGon"); +static int clear_fgon_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + + if( make_fgon(em, 0) ) { + DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA); + + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; } + return OPERATOR_CANCELLED; +} + +void MESH_OT_clear_fgon(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Clear F-gon"; + ot->idname= "MESH_OT_clear_fgon"; + + /* api callbacks */ + ot->exec= clear_fgon_exec; + ot->poll= ED_operator_editmesh; } /* precondition; 4 vertices selected, check for 4 edges and create face */ @@ -411,6 +457,8 @@ static EditFace *addface_from_edges(EditMesh *em) return NULL; } +/* ******************************* */ + /* this also allows to prevent triangles being made in quads */ static int compareface_overlaps(EditFace *vl1, EditFace *vl2) { diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 7bc648a849c..fda9766b2fc 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -2041,22 +2041,18 @@ static void mouse_mesh_loop(bContext *C, short mval[2], short extend, short ring static int mesh_loop_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - short extend= RNA_int_get(op->ptr, "type"); - short mval[2], ring= 0; + short mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; view3d_operator_needs_opengl(C); - /* hmrs, 4 selections in 1 property this way? */ - if(extend>1) ring= 1; - extend &= ~2; + mouse_mesh_loop(C, mval, RNA_boolean_get(op->ptr, "extend"), + RNA_boolean_get(op->ptr, "ring")); - mouse_mesh_loop(C, mval, extend, ring); - - /* allowing tweaks */ - return OPERATOR_PASS_THROUGH; + /* cannot do tweaks for as long this keymap is after transform map */ + return OPERATOR_FINISHED; } void MESH_OT_loop_select(wmOperatorType *ot) @@ -2070,7 +2066,8 @@ void MESH_OT_loop_select(wmOperatorType *ot) ot->poll= ED_operator_editmesh; /* properties */ - RNA_def_enum(ot->srna, "type", prop_select_types, 0, "Type", ""); + RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); + RNA_def_boolean(ot->srna, "ring", 0, "Select Ring", ""); } /* ************************************************** */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 1128a2c93b4..1b86add2376 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -153,12 +153,18 @@ void ED_operatortypes_mesh(void) void ED_keymap_mesh(wmWindowManager *wm) { ListBase *keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0); + wmKeymapItem *kmi; /* selecting */ - RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "type", 0); - RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0)->ptr, "type", 1); - RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT|KM_CTRL, 0)->ptr, "type", 2); - RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT|KM_CTRL, 0)->ptr, "type", 3); + WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); + kmi= WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "extend", 1); + kmi= WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT|KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "ring", 1); + kmi= WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT|KM_CTRL, 0); + RNA_boolean_set(kmi->ptr, "extend", 1); + RNA_boolean_set(kmi->ptr, "ring", 1); + WM_keymap_add_item(keymap, "MESH_OT_de_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); @@ -191,18 +197,17 @@ void ED_keymap_mesh(wmWindowManager *wm) WM_keymap_add_item(keymap, "MESH_OT_extrude_mesh", EKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_edit_faces", PKEY, KM_PRESS, KM_CTRL, 0); - - WM_keymap_add_item(keymap, "MESH_OT_delete_mesh", XKEY, KM_PRESS, 0, 0); - - /* add */ + /* add/remove */ WM_keymap_add_item(keymap, "MESH_OT_add_edge_face", FKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "MESH_OT_make_fgon",MKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "MESH_OT_clear_fgon",MKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "MESH_OT_delete_mesh", XKEY, KM_PRESS, 0, 0); + + WM_keymap_add_item(keymap, "MESH_OT_make_fgon", FKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "MESH_OT_clear_fgon", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 4e04eabe09a..cf39f347060 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -75,7 +75,7 @@ wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier); wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier); -wmKeymapItem *WM_keymap_tweak (ListBase *lb, short type, short val, int modifier, short keymodifier); +void WM_keymap_tweak (ListBase *lb, short type, short val, int modifier, short keymodifier); ListBase *WM_keymap_listbase (struct wmWindowManager *wm, const char *nameid, int spaceid, int regionid); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 14cdf919ff9..b4ab5d9151a 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -126,7 +126,7 @@ wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short v /* enables tweak for mouse/modifier combo on tweak fail, it passes on event with 'val=1', so other keymap items can test */ -wmKeymapItem *WM_keymap_tweak(ListBase *lb, short type, short val, int modifier, short keymodifier) +void WM_keymap_tweak(ListBase *lb, short type, short val, int modifier, short keymodifier) { wmKeymapItem *km= WM_keymap_add_item(lb, "WM_OT_tweak_gesture", type, val, modifier, keymodifier); km->is_tweak= 1; |