Page Menu
Home
Search
Configure Global Search
Log In
Files
F4822
selrando04.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
7 KB
Subscribers
None
selrando04.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 26 Apr 2007 04:55:14 -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 26 Apr 2007 04:55:14 -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"
@@ -1026,6 +1027,68 @@ void switchdirection_knots(float *base,
/* **************** EDIT ************************ */
+static void selectall_nurb() {
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ int b;
+
+ for(nu= editNurb.first; nu; nu= nu->next) {
+ if((nu->type & 7)==1) {
+ b= nu->pntsu;
+ bezt= nu->bezt;
+ while(b--) {
+ if(bezt->hide==0) {
+ bezt->f1 |= 1;
+ bezt->f2 |= 1;
+ bezt->f3 |= 1;
+ }
+ bezt++;
+ }
+ }
+ else {
+ b= nu->pntsu*nu->pntsv;
+ bp= nu->bp;
+ while(b--) {
+ if(bp->hide==0)
+ bp->f1 |= 1;
+ bp++;
+ }
+ }
+ }
+}
+
+static void unselectall_nurb() {
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ int b;
+
+ for(nu= editNurb.first; nu; nu= nu->next) {
+ if((nu->type & 7)==1) {
+ b= nu->pntsu;
+ bezt= nu->bezt;
+ while(b--) {
+ if(bezt->hide==0) {
+ bezt->f1 &= ~1;
+ bezt->f2 &= ~1;
+ bezt->f3 &= ~1;
+ }
+ bezt++;
+ }
+ }
+ else {
+ b= nu->pntsu*nu->pntsv;
+ bp= nu->bp;
+ while(b--) {
+ if(bp->hide==0)
+ bp->f1 &= ~ 1;
+ bp++;
+ }
+ }
+ }
+}
+
void deselectall_nurb()
{
Nurb *nu;
@@ -1076,39 +1139,10 @@ void deselectall_nurb()
}
if(a) break;
}
-
- for(nu= editNurb.first; nu; nu= nu->next) {
- if((nu->type & 7)==1) {
- b= nu->pntsu;
- bezt= nu->bezt;
- while(b--) {
- if(bezt->hide==0) {
- if(a) {
- bezt->f1 &= ~1;
- bezt->f2 &= ~1;
- bezt->f3 &= ~1;
- }
- else {
- bezt->f1 |= 1;
- bezt->f2 |= 1;
- bezt->f3 |= 1;
- }
- }
- bezt++;
- }
- }
- else {
- b= nu->pntsu*nu->pntsv;
- bp= nu->bp;
- while(b--) {
- if(bp->hide==0) {
- if(a) bp->f1 &= ~ 1;
- else bp->f1 |= 1;
- }
- bp++;
- }
- }
- }
+
+ if(a) unselectall_nurb();
+ else selectall_nurb();
+
countall();
allqueue(REDRAWVIEW3D, 0);
}
@@ -3331,6 +3365,106 @@ void select_less_nurb()
countall();
allqueue(REDRAWVIEW3D, 0);
BIF_undo_push("Select Less");
+}
+
+void select_random_nurb()
+{
+ Nurb *nu;
+ BezTriple *bezt;
+ BPoint *bp;
+ static short randfac= 50;
+ float randomlimit= 0.3; /* 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); /* returns value with handles */
+ 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;
+
+ if(randfac == 100) {
+ selectall_nurb();
+ return;
+ }
+
+ for(nu= editNurb.first; nu; nu= nu->next) {
+ if((nu->type & 7)==CU_BEZIER) {
+ amount_of_nurbs -= nu->pntsu*2; /* subtract handles */
+ }
+ }
+
+ selectednurbs= MEM_callocN(amount_of_nurbs, "temp array");
+ amount_of_nurbs_to_select= amount_of_nurbs*randfac/100;
+ nu= editNurb.first;
+ BLI_srand( BLI_rand() ); /* random seed */
+
+ while(j < 1000) {
+ 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) 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 26 Apr 2007 04:55:15 -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 26 Apr 2007 04:55:15 -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
da/9c/0e50fbe9507cc44aa18ffe45e199
Event Timeline
Log In to Comment