diff options
author | Matt Ebb <matt@mke3.net> | 2004-01-03 12:22:33 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2004-01-03 12:22:33 +0300 |
commit | c9a7e4be1738e17fed741ee60482a697529e6251 (patch) | |
tree | f51032c1e6d470c76d60844df4aaed54551006d0 /source | |
parent | cf8b43a2c88faefd97565d997481c0f8db016574 (diff) |
* Ported mesh editmode 'select random' from tuhopuu by popular request
Description:
Mesh editmode header/toolbox: Select -> Random...
Randomly selects a user-set percentage of vertices, adding to the current selection.
* Modified some menu entries to be consistent with the guidelines doc.
* Added 'Align Active Camera to View' in 3D View menu
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BIF_editmesh.h | 3 | ||||
-rw-r--r-- | source/blender/src/editmesh.c | 34 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 52 | ||||
-rw-r--r-- | source/blender/src/toolbox.c | 24 |
4 files changed, 83 insertions, 30 deletions
diff --git a/source/blender/include/BIF_editmesh.h b/source/blender/include/BIF_editmesh.h index 0850551907c..15cb9bdeb0f 100644 --- a/source/blender/include/BIF_editmesh.h +++ b/source/blender/include/BIF_editmesh.h @@ -155,10 +155,11 @@ void undo_redo_mesh(void); void undo_clear_mesh(void); void undo_menu_mesh(void); -/* Stuff */ +/* Selection */ void select_non_manifold(void); void select_more(void); void select_less(void); +void selectrandom_mesh(void); #endif diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c index 6f6dbaf00e7..dbe2be1b27b 100644 --- a/source/blender/src/editmesh.c +++ b/source/blender/src/editmesh.c @@ -8709,3 +8709,37 @@ void select_less(void) allqueue(REDRAWVIEW3D, 0); } + + +void selectrandom_mesh(void) /* randomly selects a user-set % of vertices */ +{ + EditVert *eve; + int newsel = 0; /* to decide whether to redraw or not */ + short randfac = 50; + + if(G.obedit==0) return; + + /* Get the percentage of vertices to randomly select as 'randfac' */ + if(button(&randfac,0, 100,"Percentage:")==0) return; + + if(G.obedit->lay & G.vd->lay) { + eve= G.edve.first; + while(eve) { + BLI_srand( BLI_rand() ); /* random seed */ + if ( (BLI_frand() * 100) < randfac) { + eve->f |= SELECT; + newsel = 1; + } else { + /* Deselect other vertices + * + * - Commenting this out makes it add to the selection, + * rather than replace it. + * eve->f &= ~SELECT; + */ + } + eve= eve->next; + } + countall(); + allqueue(REDRAWVIEW3D, 0); + } +} diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index c16231ea09a..f6dc3d0ae5a 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -229,6 +229,7 @@ static uiBlock *view3d_view_cameracontrolsmenu(void *arg_unused) static void do_view3d_viewmenu(void *arg, int event) { extern int play_anim(int mode); + void setcameratoview3d(void); // view.c float *curs; @@ -282,10 +283,18 @@ static void do_view3d_viewmenu(void *arg, int event) case 13: /* Play Back Animation */ play_anim(0); break; - case 14: /* Backdrop Panel */ + case 14: /* Align Active Camera to View */ + /* This ugly hack is a symptom of the nasty persptoetsen function, + * but at least it works for now. + */ + G.qual |= LR_SHIFTKEY; + persptoetsen(PAD0); + G.qual &= ~LR_SHIFTKEY; + break; + case 15: /* Background Image... */ add_blockhandler(curarea, VIEW3D_HANDLER_BACKGROUND, UI_PNL_UNSTOW); break; - case 15: /* View Panel */ + case 16: /* View Panel */ add_blockhandler(curarea, VIEW3D_HANDLER_PROPERTIES, UI_PNL_UNSTOW); break; } @@ -301,8 +310,8 @@ static uiBlock *view3d_viewmenu(void *arg_unused) block= uiNewBlock(&curarea->uiblocks, "view3d_viewmenu", UI_EMBOSSP, UI_HELV, curarea->headwin); uiBlockSetButmFunc(block, do_view3d_viewmenu, NULL); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "View Properties...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 15, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Background Image...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "View Properties...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 16, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Background Image...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 15, ""); if(!curarea->full) uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 99, ""); else uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 99, ""); @@ -335,19 +344,22 @@ static uiBlock *view3d_viewmenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBlockBut(block, view3d_view_cameracontrolsmenu, NULL, ICON_RIGHTARROW_THIN, "Viewport Navigation", 0, yco-=20, 120, 19, ""); + uiDefIconTextBlockBut(block, view3d_view_cameracontrolsmenu, NULL, ICON_RIGHTARROW_THIN, "View Navigation", 0, yco-=20, 120, 19, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Frame All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Frame Selected|NumPad .", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected|NumPad *", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 12, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Centre Cursor|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align Active Camera to View|Shift NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Centre View to Cursor|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation|Alt A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 13, ""); - if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); @@ -578,7 +590,7 @@ void do_view3d_select_meshmenu(void *arg, int event) selectconnected_mesh(LR_CTRLKEY); break; case 5: /* select random */ - // selectrandom_mesh(); + selectrandom_mesh(); break; case 6: /* select Faceloop */ loop('s'); @@ -614,20 +626,24 @@ static uiBlock *view3d_select_meshmenu(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, "Random...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, + "Non-Manifold|Ctrl Alt Shift M", + 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, + menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "More|Ctrl NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Less|Ctrl NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, - "Non-manifold|Shift Ctrl Alt M", - 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Faceloop|Shift R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); -// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random Vertices...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Face Loop...|Shift R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Linked Vertices|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); if(curarea->headertype==HEADERTOP) { @@ -2235,14 +2251,14 @@ static uiBlock *view3d_pose_armaturemenu(void *arg_unused) uiDefIconTextBlockBut(block, view3d_pose_armature_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, ""); 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, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Copy Current Pose", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Paste Pose", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Paste Flipped Pose", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - - 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, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Paste Flipped Pose", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index b4471cac26c..cc2fab0a3e7 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -1577,17 +1577,19 @@ static TBitem tb_object_select[]= { static TBitem tb_mesh_select[]= { -{ 0, "Border Select|B", 0, NULL}, -{ 0, "SEPR", 0, NULL}, -{ 0, "(De)select All|A", 2, NULL}, -{ 0, "Inverse", 3, NULL}, -{ 0, "SEPR", 0, NULL}, -{ 0, "Face Loop|Shift R", 6, NULL}, -{ 0, "Linked Vertices|Ctrl L", 4, NULL}, -{ 0, "SEPR", 0, NULL}, -{ 0, "More|Ctrl Numpad +", 7, NULL}, -{ 0, "Less|Ctrl Numpad -", 8, NULL}, -{ 0, "Non-manifold|Shift Ctrl Alt M", 9, NULL}, +{ 0, "Border Select|B", 0, NULL}, +{ 0, "SEPR", 0, NULL}, +{ 0, "(De)select All|A", 2, NULL}, +{ 0, "Inverse", 3, NULL}, +{ 0, "SEPR", 0, NULL}, +{ 0, "Random...", 5, NULL}, +{ 0, "Non-Manifold|Shift Ctrl Alt M", 9, NULL}, +{ 0, "SEPR", 0, NULL}, +{ 0, "More|Ctrl Numpad +", 7, NULL}, +{ 0, "Less|Ctrl Numpad -", 8, NULL}, +{ 0, "SEPR", 0, NULL}, +{ 0, "Face Loop...|Shift R", 6, NULL}, +{ 0, "Linked Vertices|Ctrl L", 4, NULL}, { -1, "", 0, do_view3d_select_meshmenu}}; |