Page Menu
Home
Search
Configure Global Search
Log In
Files
F4821
selrando03.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Juho Vepsalainen (bebraw)
Nov 13 2013, 1:19 PM
Size
5 KB
Subscribers
None
selrando03.txt
View Options
Index: source/blender/include/BDR_editcurve.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BDR_editcurve.h,v
retrieving revision 1.14
diff -u -p -u -r1.14 BDR_editcurve.h
--- source/blender/include/BDR_editcurve.h 6 Nov 2006 18:20:56 -0000 1.14
+++ source/blender/include/BDR_editcurve.h 25 Apr 2007 19:17:18 -0000
@@ -83,6 +83,7 @@ void select_more_nurb(void);
void select_less_nurb(void);
void select_next_nurb(void);
void select_prev_nurb(void);
+void select_random_nurb(void);
void adduplicate_nurb(void);
void delNurb(void);
void nurb_set_smooth(short event);
@@ -98,4 +99,3 @@ int bezt_compare (const void *e1, const
extern void undo_push_curve(char *name);
#endif /* BDR_EDITCURVE_H */
-
Index: source/blender/src/editcurve.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editcurve.c,v
retrieving revision 1.59
diff -u -p -u -r1.59 editcurve.c
--- source/blender/src/editcurve.c 22 Apr 2007 22:08:18 -0000 1.59
+++ source/blender/src/editcurve.c 25 Apr 2007 19:17:20 -0000
@@ -50,6 +50,7 @@
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "BLI_dynstr.h"
+#include "BLI_rand.h"
#include "DNA_curve_types.h"
#include "DNA_ipo_types.h"
@@ -3331,6 +3332,99 @@ void select_less_nurb()
countall();
allqueue(REDRAWVIEW3D, 0);
BIF_undo_push("Select Less");
+}
+
+void select_random_nurb()
+{
+ Nurb *nu= editNurb.first;
+ BezTriple *bezt;
+ BPoint *bp;
+ static short randfac= 50;
+ float randomlimit= 0.5; /* don't set this value too low! it has to be between 0 and 1 */
+ int a, i= 0, j= 0;
+ int amount_of_nurbs= count_curveverts(&editNurb);
+ int amount_of_nurbs_to_select= 0, amount_of_found_nurbs= 0;
+ char *selectednurbs;
+ short breakloop= 0;
+
+ if(!G.obedit) return;
+
+ if(!button(&randfac,0, 100,"Percentage:")) return;
+
+ if(randfac == 0) return;
+
+ BLI_srand( BLI_rand() ); /* random seed */
+
+ if((nu->type & 7)==CU_BEZIER) amount_of_nurbs /= 3; /* remember handles! */
+ /* note that there can be both nurbs and bezier curve objects!!! doesn't handle this yet */
+
+ selectednurbs= MEM_callocN(amount_of_nurbs, "temp array");
+
+ amount_of_nurbs_to_select= amount_of_nurbs*randfac/100;
+
+ while(1) {
+ if((nu->type & 7)==CU_BEZIER) {
+ a= nu->pntsu;
+ bezt= nu->bezt;
+ while(a--) {
+ if((selectednurbs[i] != 1) && (BLI_frand() < randomlimit)) {
+ amount_of_found_nurbs++;
+ selectednurbs[i]= 1;
+
+ if (bezt->hide == 0) {
+ bezt->f1 |= 1;
+ bezt->f2 |= 1;
+ bezt->f3 |= 1;
+ }
+
+ /* break loop when we have found enough nurbs */
+ if(amount_of_found_nurbs == amount_of_nurbs_to_select) {
+ breakloop=1;
+ break;
+ }
+ }
+ bezt++;
+ i++;
+ }
+ }
+ else {
+ a= nu->pntsu*nu->pntsv;
+ bp= nu->bp;
+ while(a--) {
+ if((selectednurbs[i] != 1) && (BLI_frand() < randomlimit)) {
+ amount_of_found_nurbs++;
+ selectednurbs[i]= 1;
+
+ if(bp->hide == 0) bp->f1 |= 1;
+
+ /* break loop when we have found enough nurbs */
+ if(amount_of_found_nurbs == amount_of_nurbs_to_select) {
+ breakloop=1;
+ break;
+ }
+ }
+ bp++;
+ i++;
+ }
+ }
+
+ if((breakloop == 1) || (j == 100)) break;
+
+ /* if we are at the end, go to the beginning */
+ if(!nu->next) {
+ nu= editNurb.first;
+ i=0;
+ j++;
+ }
+ else
+ nu= nu->next;
+ }
+
+ MEM_freeN(selectednurbs);
+
+ countall();
+ allqueue(REDRAWVIEW3D, 0);
+ BIF_undo_push("Select Random:Nurbs");
}
void adduplicate_nurb()
Index: source/blender/src/header_view3d.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/header_view3d.c,v
retrieving revision 1.230
diff -u -p -u -r1.230 header_view3d.c
--- source/blender/src/header_view3d.c 22 Apr 2007 22:08:18 -0000 1.230
+++ source/blender/src/header_view3d.c 25 Apr 2007 19:17:21 -0000
@@ -1102,6 +1102,9 @@ void do_view3d_select_curvemenu(void *ar
case 12: /* select previous */
select_prev_nurb();
break;
+ case 13: /* select random */
+ select_random_nurb();
+ break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -1121,6 +1124,7 @@ static uiBlock *view3d_select_curvemenu(
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Random...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 13, "");
if (OBACT->type == OB_SURF) {
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
Index: source/blender/src/toolbox.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/toolbox.c,v
retrieving revision 1.163
diff -u -p -u -r1.163 toolbox.c
--- source/blender/src/toolbox.c 22 Apr 2007 22:08:19 -0000 1.163
+++ source/blender/src/toolbox.c 25 Apr 2007 19:17:22 -0000
@@ -948,6 +948,7 @@ static TBitem tb_curve_select[]= {
{ 0, "SEPR", 0, NULL},
{ 0, "(De)select All|A", 2, NULL},
{ 0, "Inverse", 3, NULL},
+{ 0, "Random...", 13, NULL},
{ 0, "Row|Shift R", 5, NULL},
{ 0, "SEPR", 0, NULL},
{ 0, "(De)select First", 7, NULL},
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ec/b9/f6b2add4b7372061bd7781301e95
Event Timeline
Log In to Comment