From e090595ec997445b63711e5dc1fc3f78be80c341 Mon Sep 17 00:00:00 2001 From: Chris Want Date: Sat, 3 Jan 2004 05:07:31 +0000 Subject: Hide selected/hide unselected/show all bones in posemode using the usual HKEY, shift-HKEY, alt-HKEY, and also through the menu. Thanks to malefico for the feature request, and thanks to broken for doing the menu code. --- source/blender/include/BIF_editarmature.h | 5 +++ source/blender/src/editarmature.c | 66 +++++++++++++++++++++++++++++++ source/blender/src/header_view3d.c | 44 +++++++++++++++++++++ source/blender/src/space.c | 9 ++++- 4 files changed, 123 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/include/BIF_editarmature.h b/source/blender/include/BIF_editarmature.h index 9cc281c94d8..9dd17cb9612 100644 --- a/source/blender/include/BIF_editarmature.h +++ b/source/blender/include/BIF_editarmature.h @@ -110,6 +110,11 @@ void unique_editbone_name (char* name); struct Bone *get_first_selected_bone (void); void auto_align_armature(void); void create_vgroups_from_armature(Object *ob, Object *par); + +void hide_selected_pose_bones(void); +void hide_unselected_pose_bones(void); +void show_all_pose_bones(void); + int is_delay_deform(void); #define BONESEL_TIP 0x08000000 diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 41daaa370a2..85602d58178 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -2707,6 +2707,72 @@ void create_vgroups_from_armature(Object *ob, Object *par) } } +int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr) { + if (bone->flag & BONE_SELECTED) { + bone->flag |= BONE_HIDDEN; + bone->flag &= ~BONE_SELECTED; + } + return 0; +} + +void hide_selected_pose_bones(void) { + bArmature *arm; + + arm=get_armature (G.obpose); + + if (!arm) + return; + + bone_looper(G.obpose, arm->bonebase.first, NULL, + hide_selected_pose_bone); + + force_draw(); +} + +int hide_unselected_pose_bone(Object *ob, Bone *bone, void *ptr) { + if (~bone->flag & BONE_SELECTED) { + bone->flag |= BONE_HIDDEN; + } + return 0; +} + +void hide_unselected_pose_bones(void) { + bArmature *arm; + + arm=get_armature (G.obpose); + + if (!arm) + return; + + bone_looper(G.obpose, arm->bonebase.first, NULL, + hide_unselected_pose_bone); + + force_draw(); +} + +int show_pose_bone(Object *ob, Bone *bone, void *ptr) { + if (bone->flag & BONE_HIDDEN) { + bone->flag &= ~BONE_HIDDEN; + bone->flag |= BONE_SELECTED; + } + + return 0; +} + +void show_all_pose_bones(void) { + bArmature *arm; + + arm=get_armature (G.obpose); + + if (!arm) + return; + + bone_looper(G.obpose, arm->bonebase.first, NULL, + show_pose_bone); + + force_draw(); +} + int is_delay_deform(void) { bArmature *arm; diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 64686611444..229a3d7986b 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -1394,6 +1394,8 @@ static uiBlock *view3d_edit_mesh_normalsmenu(void *arg_unused) return block; } + + static void do_view3d_edit_mesh_showhidemenu(void *arg, int event) { @@ -2165,6 +2167,41 @@ static void do_view3d_pose_armaturemenu(void *arg, int event) allqueue(REDRAWVIEW3D, 0); } +static void do_view3d_pose_armature_showhidemenu(void *arg, int event) +{ + + switch(event) { + + case 0: /* show hidden bones */ + show_all_pose_bones(); + break; + case 1: /* hide selected bones */ + hide_selected_pose_bones(); + break; + case 2: /* hide deselected bones */ + hide_unselected_pose_bones(); + break; + } + allqueue(REDRAWVIEW3D, 0); +} + +static uiBlock *view3d_pose_armature_showhidemenu(void *arg_unused) +{ + uiBlock *block; + short yco = 20, menuwidth = 120; + + block= uiNewBlock(&curarea->uiblocks, "view3d_pose_armature_showhidemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); + uiBlockSetButmFunc(block, do_view3d_pose_armature_showhidemenu, NULL); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Hidden|Alt H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Selected|H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Hide Deselected|Shift H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + + uiBlockSetDirection(block, UI_RIGHT); + uiTextBoundsBlock(block, 60); + return block; +} + static uiBlock *view3d_pose_armaturemenu(void *arg_unused) { uiBlock *block; @@ -2185,7 +2222,14 @@ static uiBlock *view3d_pose_armaturemenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Insert Keyframe|I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, + menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBlockBut(block, view3d_pose_armature_showhidemenu, + NULL, ICON_RIGHTARROW_THIN, + "Show/Hide Bones", 0, yco-=20, 120, 19, ""); + if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); } diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 0c89457a469..54c11d1594c 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1047,7 +1047,14 @@ void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) } else if(G.f & G_FACESELECT) hide_tface(); - + else if(G.obpose) { + if (G.qual==0) + hide_selected_pose_bones(); + else if (G.qual==LR_SHIFTKEY) + hide_unselected_pose_bones(); + else if (G.qual==LR_ALTKEY) + show_all_pose_bones(); + } break; case IKEY: break; -- cgit v1.2.3