diff options
-rw-r--r-- | source/blender/include/BIF_editview.h | 1 | ||||
-rw-r--r-- | source/blender/src/editseq.c | 2 | ||||
-rw-r--r-- | source/blender/src/editview.c | 26 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 5 | ||||
-rw-r--r-- | source/blender/src/toolbox.c | 1 |
5 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/include/BIF_editview.h b/source/blender/include/BIF_editview.h index 9192b217f4f..d47bd82332f 100644 --- a/source/blender/include/BIF_editview.h +++ b/source/blender/include/BIF_editview.h @@ -44,6 +44,7 @@ void borderselect(void); void circle_select(void); void deselectall(void); void selectswap(void); +void selectrandom(void); void selectall_type(short obtype); void selectall_layer(unsigned int layernum); void draw_sel_circle(short *mval, short *mvalo, float rad, float rado, int selecting); diff --git a/source/blender/src/editseq.c b/source/blender/src/editseq.c index d07d733ce90..5d511b35633 100644 --- a/source/blender/src/editseq.c +++ b/source/blender/src/editseq.c @@ -3690,7 +3690,7 @@ void seq_mute_sel(int mute) { Sequence *seq; ed= G.scene->ed; - if(!ed) return NULL; + if(!ed) return; for(seq= ed->seqbasep->first; seq; seq= seq->next) { if ((seq->flag & SELECT) && (seq->flag & SEQ_LOCK)==0) { diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index 6e3686259da..93e39cba6eb 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -64,6 +64,7 @@ #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_editVert.h" +#include "BLI_rand.h" /* random object selection */ #include "BKE_armature.h" #include "BKE_depsgraph.h" @@ -1046,6 +1047,31 @@ void selectswap(void) BIF_undo_push("Select Inverse"); } +/* inverts object selection */ +void selectrandom(void) +{ + Base *base; + static short randfac = 50; + if(button(&randfac,0, 100,"Percentage:")==0) return; + + for(base= FIRSTBASE; base; base= base->next) { + if(base->lay & G.vd->lay && + (base->object->restrictflag & OB_RESTRICT_VIEW)==0 + ) { + if (!TESTBASE(base) && ( (BLI_frand() * 100) < randfac)) { + select_base_v3d(base, BA_SELECT); + base->object->flag= base->flag; + } + } + } + + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWDATASELECT, 0); + allqueue(REDRAWNLA, 0); + + countall(); + BIF_undo_push("Select Random"); +} /* selects all objects of a particular type, on currently visible layers */ void selectall_type(short obtype) diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 1c39d286989..3d2f81cba02 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -914,6 +914,9 @@ void do_view3d_select_objectmenu(void *arg, int event) case 2: /* inverse */ selectswap(); break; + case 3: /* random */ + selectrandom(); + break; } allqueue(REDRAWVIEW3D, 0); } @@ -932,6 +935,8 @@ static uiBlock *view3d_select_objectmenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiDefIconTextBlockBut(block, view3d_select_object_layermenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Layer", 0, yco-=20, 120, 19, ""); uiDefIconTextBlockBut(block, view3d_select_object_typemenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Type", 0, yco-=20, 120, 19, ""); diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 43db71108ec..671628bf5c7 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -901,6 +901,7 @@ static TBitem tb_object_select[]= { { 0, "SEPR", 0, NULL}, { 0, "Select/Deselect All|A", 1, NULL}, { 0, "Inverse", 2, NULL}, +{ 0, "Random", 3, NULL}, { 0, "Select All by Layer", 0, tb_object_select_layer}, { 0, "Select All by Type", 0, tb_object_select_type}, { 0, "SEPR", 0, NULL}, |