diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/armature/armature_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 8 | ||||
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/editface.c | 133 | ||||
-rw-r--r-- | source/blender/editors/metaball/mball_edit.c | 20 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 9 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 66 |
9 files changed, 152 insertions, 99 deletions
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index acc8ed0999b..63a57178163 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -213,6 +213,8 @@ void ED_keymap_armature(wmKeyConfig *keyconf) /* only set in editmode armature, by space_view3d listener */ WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0); + kmi= WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "unselected", 1); WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 5b91098ad8f..5c1d1300599 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -3316,11 +3316,12 @@ void ARMATURE_OT_merge (wmOperatorType *ot) /* ************** END Add/Remove stuff in editmode ************ */ /* *************** Tools in editmode *********** */ -static int armature_hide_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_hide_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); bArmature *arm= obedit->data; EditBone *ebone; + const int invert= RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0; /* cancel if nothing selected */ if (CTX_DATA_COUNT(C, selected_bones) == 0) @@ -3328,7 +3329,7 @@ static int armature_hide_exec(bContext *C, wmOperator *UNUSED(op)) for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { - if (ebone->flag & BONE_SELECTED) { + if ((ebone->flag & BONE_SELECTED) != invert) { ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); ebone->flag |= BONE_HIDDEN_A; } @@ -3355,6 +3356,9 @@ void ARMATURE_OT_hide(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected."); } static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 1ea6f42c3c9..054e46971b5 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -193,10 +193,8 @@ void paintface_deselect_all_visible(struct Object *ob, int action, short flush_f void paintface_select_linked(struct bContext *C, struct Object *ob, short mval[2], int mode); int paintface_minmax(struct Object *ob, float *min, float *max); -/* TODO, 2.5x */ -void paintface_unhide(struct Scene *scene); -void paintface_hide(struct Scene *scene); -void paintface_select_swap(struct Scene *scene); +void paintface_hide(struct Object *ob, const int unselected); +void paintface_reveal(struct Object *ob); /* object_vgroup.c */ diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 72d1c703c0e..552f4b3b954 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -152,61 +152,55 @@ MTFace *EM_get_active_mtface(EditMesh *em, EditFace **act_efa, MCol **mcol, int return NULL; } -void paintface_unhide(Scene *scene) +void paintface_hide(Object *ob, const int unselected) { Mesh *me; MFace *mface; int a; - me= get_mesh(OBACT); + me= get_mesh(ob); if(me==0 || me->totface==0) return; - + mface= me->mface; a= me->totface; while(a--) { - if(mface->flag & ME_HIDE) { - mface->flag |= ME_FACE_SEL; - mface->flag -= ME_HIDE; + if((mface->flag & ME_HIDE) == 0) { + if(unselected) { + if( (mface->flag & ME_FACE_SEL)==0) mface->flag |= ME_HIDE; + } + else { + if( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE; + } } + if(mface->flag & ME_HIDE) mface->flag &= ~ME_FACE_SEL; + mface++; } - - paintface_flush_flags(OBACT); + + paintface_flush_flags(ob); } -void paintface_hide(Scene *scene) + +void paintface_reveal(Object *ob) { Mesh *me; MFace *mface; int a; - int shift=0, alt= 0; // XXX - - me= get_mesh(OBACT); + + me= get_mesh(ob); if(me==0 || me->totface==0) return; - - if(alt) { - paintface_unhide(scene); - return; - } - + mface= me->mface; a= me->totface; while(a--) { - if(mface->flag & ME_HIDE); - else { - if(shift) { - if( (mface->flag & ME_FACE_SEL)==0) mface->flag |= ME_HIDE; - } - else { - if( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE; - } + if(mface->flag & ME_HIDE) { + mface->flag |= ME_FACE_SEL; + mface->flag -= ME_HIDE; } - if(mface->flag & ME_HIDE) mface->flag &= ~ME_FACE_SEL; - mface++; } - - paintface_flush_flags(OBACT); + + paintface_flush_flags(ob); } /* Set tface seams based on edge data, uses hash table to find seam edges. */ @@ -359,37 +353,49 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) me= get_mesh(ob); if(me==0) return; - if (action == SEL_TOGGLE) { - action = SEL_SELECT; - + if(action == SEL_INVERT) { mface= me->mface; a= me->totface; while(a--) { - if((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) { - action = SEL_DESELECT; - break; + if((mface->flag & ME_HIDE) == 0) { + mface->flag ^= ME_FACE_SEL; } mface++; } } - - mface= me->mface; - a= me->totface; - while(a--) { - if((mface->flag & ME_HIDE) == 0) { - switch (action) { - case SEL_SELECT: - mface->flag |= ME_FACE_SEL; - break; - case SEL_DESELECT: - mface->flag &= ~ME_FACE_SEL; - break; - case SEL_INVERT: - mface->flag ^= ME_FACE_SEL; - break; + else { + if (action == SEL_TOGGLE) { + action = SEL_SELECT; + + mface= me->mface; + a= me->totface; + while(a--) { + if((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) { + action = SEL_DESELECT; + break; + } + mface++; } } - mface++; + + mface= me->mface; + a= me->totface; + while(a--) { + if((mface->flag & ME_HIDE) == 0) { + switch (action) { + case SEL_SELECT: + mface->flag |= ME_FACE_SEL; + break; + case SEL_DESELECT: + mface->flag &= ~ME_FACE_SEL; + break; + case SEL_INVERT: + mface->flag ^= ME_FACE_SEL; + break; + } + } + mface++; + } } if(flush_flags) { @@ -397,29 +403,6 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) } } -void paintface_select_swap(Scene *scene) -{ - Mesh *me; - MFace *mface; - int a; - - me= get_mesh(OBACT); - if(me==0) return; - - mface= me->mface; - a= me->totface; - while(a--) { - if(mface->flag & ME_HIDE); - else { - if(mface->flag & ME_FACE_SEL) mface->flag &= ~ME_FACE_SEL; - else mface->flag |= ME_FACE_SEL; - } - mface++; - } - - paintface_flush_flags(OBACT); -} - int paintface_minmax(Object *ob, float *min, float *max) { Mesh *me= get_mesh(ob); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 13b4535b47d..da0fb256572 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -374,25 +374,15 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op) Object *obedit= CTX_data_edit_object(C); MetaBall *mb= (MetaBall*)obedit->data; MetaElem *ml; - int hide_unselected= RNA_boolean_get(op->ptr, "unselected"); + const int invert= RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; ml= mb->editelems->first; if(ml) { - /* Hide unselected metaelems */ - if(hide_unselected) { - while(ml){ - if(!(ml->flag & SELECT)) - ml->flag |= MB_HIDE; - ml= ml->next; - } - /* Hide selected metaelems */ - } else { - while(ml){ - if(ml->flag & SELECT) - ml->flag |= MB_HIDE; - ml= ml->next; - } + while(ml){ + if((ml->flag & SELECT) != invert) + ml->flag |= MB_HIDE; + ml= ml->next; } WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 149f442f665..c07c770cf66 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -170,7 +170,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); short changed = 0; - int unselected= RNA_boolean_get(op->ptr, "unselected"); + const int unselected= RNA_boolean_get(op->ptr, "unselected"); CTX_DATA_BEGIN(C, Base*, base, visible_bases) { if(!unselected) { @@ -259,7 +259,7 @@ void OBJECT_OT_hide_render_clear(wmOperatorType *ot) static int object_hide_render_set_exec(bContext *C, wmOperator *op) { - int unselected= RNA_boolean_get(op->ptr, "unselected"); + const int unselected= RNA_boolean_get(op->ptr, "unselected"); CTX_DATA_BEGIN(C, Base*, base, visible_bases) { if(!unselected) { diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 9c0da1f1005..e0a09184e28 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -114,6 +114,9 @@ void BRUSH_OT_curve_preset(struct wmOperatorType *ot); void PAINT_OT_face_select_linked(struct wmOperatorType *ot); void PAINT_OT_face_select_linked_pick(struct wmOperatorType *ot); void PAINT_OT_face_select_all(struct wmOperatorType *ot); +void PAINT_OT_face_select_inverse(struct wmOperatorType *ot); +void PAINT_OT_face_select_hide(struct wmOperatorType *ot); +void PAINT_OT_face_select_reveal(struct wmOperatorType *ot); int facemask_paint_poll(struct bContext *C); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e86a068459e..979b6508b16 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -224,6 +224,9 @@ void ED_operatortypes_paint(void) WM_operatortype_append(PAINT_OT_face_select_linked); WM_operatortype_append(PAINT_OT_face_select_linked_pick); WM_operatortype_append(PAINT_OT_face_select_all); + WM_operatortype_append(PAINT_OT_face_select_inverse); + WM_operatortype_append(PAINT_OT_face_select_hide); + WM_operatortype_append(PAINT_OT_face_select_reveal); } @@ -414,7 +417,11 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap->poll= facemask_paint_poll; WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "PAINT_OT_face_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, 0, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + WM_keymap_add_item(keymap, "PAINT_OT_face_select_reveal", HKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, 0, 0); - } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 2962ea7e51b..b02c0db7da4 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -350,3 +350,69 @@ void PAINT_OT_face_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } + +static int face_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob= CTX_data_active_object(C); + paintface_deselect_all_visible(ob, SEL_INVERT, TRUE); + ED_region_tag_redraw(CTX_wm_region(C)); + return OPERATOR_FINISHED; +} + + +void PAINT_OT_face_select_inverse(wmOperatorType *ot) +{ + ot->name= "Face Select Invert"; + ot->description= "Invert selection of faces"; + ot->idname= "PAINT_OT_face_select_inverse"; + + ot->exec= face_select_inverse_exec; + ot->poll= facemask_paint_poll; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int face_select_hide_exec(bContext *C, wmOperator *op) +{ + const int unselected= RNA_boolean_get(op->ptr, "unselected"); + Object *ob= CTX_data_active_object(C); + paintface_hide(ob, unselected); + ED_region_tag_redraw(CTX_wm_region(C)); + return OPERATOR_FINISHED; +} + +void PAINT_OT_face_select_hide(wmOperatorType *ot) +{ + ot->name= "Face Select Hide"; + ot->description= "Hide selected faces"; + ot->idname= "PAINT_OT_face_select_hide"; + + ot->exec= face_select_hide_exec; + ot->poll= facemask_paint_poll; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects."); +} + +static int face_select_reveal_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_active_object(C); + paintface_reveal(ob); + ED_region_tag_redraw(CTX_wm_region(C)); + return OPERATOR_FINISHED; +} + +void PAINT_OT_face_select_reveal(wmOperatorType *ot) +{ + ot->name= "Face Select Reveal"; + ot->description= "Reveal hidden faces"; + ot->idname= "PAINT_OT_face_select_reveal"; + + ot->exec= face_select_reveal_exec; + ot->poll= facemask_paint_poll; + + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects."); +} |