From c9a7e4be1738e17fed741ee60482a697529e6251 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 3 Jan 2004 09:22:33 +0000 Subject: * 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 --- source/blender/src/editmesh.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source/blender/src/editmesh.c') 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); + } +} -- cgit v1.2.3