simple changes for bez point selection. use as a flag incase other flags are stored...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 20 Sep 2008 13:21:10 +0000 (13:21 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 20 Sep 2008 13:21:10 +0000 (13:21 +0000)
source/blender/blenkernel/intern/curve.c
source/blender/include/blendef.h
source/blender/src/drawipo.c
source/blender/src/editcurve.c
source/blender/src/editipo.c
source/blender/src/editipo_mods.c
source/blender/src/retopo.c

index 396bdda9c10528b7013b1b9a16aadcab9c1b1b7c..c5ad9e58a4c309fb13bf2b3ea7a0306e1ae66eb5 100644 (file)
@@ -1519,7 +1519,7 @@ void makeBevelList(Object *ob)
                                        bevp->y= bp->vec[1];
                                        bevp->z= bp->vec[2];
                                        bevp->alfa= bp->alfa;
-                                       bevp->f1= 1;
+                                       bevp->f1= SELECT;
                                        bevp++;
                                        bp++;
                                }
@@ -1579,11 +1579,11 @@ void makeBevelList(Object *ob)
                                                
                                                /* indicate with handlecodes double points */
                                                if(prevbezt->h1==prevbezt->h2) {
-                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->f1= 1;
+                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->f1= SELECT;
                                                }
                                                else {
-                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->f1= 1;
-                                                       else if(prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->f1= 1;
+                                                       if(prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->f1= SELECT;
+                                                       else if(prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->f1= SELECT;
                                                }
                                                
                                                v1= data;
@@ -2385,9 +2385,9 @@ void sethandlesNurb(short code)
                                bezt= nu->bezt;
                                a= nu->pntsu;
                                while(a--) {
-                                       if(bezt->f1 || bezt->f3) {
-                                               if(bezt->f1) bezt->h1= code;
-                                               if(bezt->f3) bezt->h2= code;
+                                       if((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+                                               if(bezt->f1 & SELECT) bezt->h1= code;
+                                               if(bezt->f3 & SELECT) bezt->h2= code;
                                                if(bezt->h1!=bezt->h2) {
                                                        if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
                                                        if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
@@ -2415,8 +2415,8 @@ void sethandlesNurb(short code)
                                        bezt= nu->bezt;
                                        a= nu->pntsu;
                                        while(a--) {
-                                               if(bezt->f1 && bezt->h1) ok= 1;
-                                               if(bezt->f3 && bezt->h2) ok= 1;
+                                               if((bezt->f1 & SELECT) && bezt->h1) ok= 1;
+                                               if((bezt->f3 & SELECT) && bezt->h2) ok= 1;
                                                if(ok) break;
                                                bezt++;
                                        }
@@ -2432,8 +2432,8 @@ void sethandlesNurb(short code)
                                bezt= nu->bezt;
                                a= nu->pntsu;
                                while(a--) {
-                                       if(bezt->f1) bezt->h1= ok;
-                                       if(bezt->f3 ) bezt->h2= ok;
+                                       if(bezt->f1 & SELECT) bezt->h1= ok;
+                                       if(bezt->f3 & SELECT) bezt->h2= ok;
        
                                        bezt++;
                                }
index 7fd607f6feb9bb898dc880d9a117b1c0de924e96..5a883dc9e21a331fee5bc3da4533aed6700bc345 100644 (file)
 /* for curve objects in editmode that can have hidden handles - may use for IPO's later */
 #define BEZSELECTED_HIDDENHANDLES(bezt)   ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
 
+#define BEZ_SEL(bezt)          { (bezt)->f1 |=  SELECT; (bezt)->f2 |=  SELECT; (bezt)->f3 |=  SELECT; }
+#define BEZ_DESEL(bezt)                { (bezt)->f1 &= ~SELECT; (bezt)->f2 &= ~SELECT; (bezt)->f3 &= ~SELECT; }
+#define BEZ_INVSEL(bezt)       { (bezt)->f1 ^=  SELECT; (bezt)->f2 ^=  SELECT; (bezt)->f3 ^=  SELECT; }
+
 /* psfont */
 #define FNT_PDRAW 1
 #define FNT_HAEBERLI 2
index ec6a0f0d75b8174be547a8efaef9eaf4b381adb1..1454c0d4f091e29e2282254d7334874b2686ca76 100644 (file)
@@ -1315,7 +1315,7 @@ static void draw_ipohandles(int sel)
                                                glVertex2fv(fp+3); glVertex2fv(fp+6); 
                                                glEnd();
                                        }
-                                       else if( (bezt->f1 & 1)==sel) {
+                                       else if( (bezt->f1 & SELECT)==sel) {
                                                fp= bezt->vec[0];
                                                cpack(col[bezt->h1]);
                                                
index 261bb26b0c4507d595e032587dfb09c3c0553598..f15ffcdcb58c852a6b225ba03d5041cc9f180625 100644 (file)
@@ -262,7 +262,7 @@ static void printweightsNurb__doPrint(void *userData, Nurb *nurb, BPoint *bp, Be
 {
        char str[30];
 
-       if (bp && (bp->f1&1)) {
+       if (bp && (bp->f1 & SELECT)) {
                sprintf(str,"%2.2f", bp->vec[3]);
 
                cpack(0x737373);
@@ -2916,12 +2916,12 @@ void addvert_Nurb(int mode)
        if((nu->type & 7)==CU_BEZIER) {
                /* which bezpoint? */
                if(bezt== nu->bezt) {   /* first */
-                       bezt->f1= bezt->f2= bezt->f3= 0;
+                       BEZ_DESEL(bezt);
                        newbezt =
                                (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
                        memcpy(newbezt+1, bezt, nu->pntsu*sizeof(BezTriple));
                        *newbezt= *bezt;
-                       newbezt->f1= newbezt->f2= newbezt->f3= SELECT;
+                       BEZ_SEL(newbezt);
                        if(newbezt->h1 >= 0) newbezt->h2= newbezt->h1;
                        else newbezt->h2= newbezt->h1= HD_ALIGN; /* does this ever happen? */
                        VECCOPY(temp, bezt->vec[1]);
@@ -2930,7 +2930,7 @@ void addvert_Nurb(int mode)
                        bezt= newbezt+1;
                }
                else if(bezt== (nu->bezt+nu->pntsu-1)) {  /* last */
-                       bezt->f1= bezt->f2= bezt->f3= 0;
+                       BEZ_DESEL(bezt);
                        newbezt =
                                (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
                        memcpy(newbezt, nu->bezt, nu->pntsu*sizeof(BezTriple));
@@ -2939,7 +2939,7 @@ void addvert_Nurb(int mode)
                        MEM_freeN(nu->bezt);
                        nu->bezt= newbezt;
                        newbezt+= nu->pntsu;
-                       newbezt->f1= newbezt->f2= newbezt->f3= SELECT;
+                       BEZ_SEL(newbezt);
                        if(newbezt->h1 >= 0) newbezt->h2= newbezt->h1;
                        else newbezt->h2= newbezt->h1= HD_ALIGN; /* does this ever happen? */
                        bezt= nu->bezt+nu->pntsu-1;
index ecb9e845104c3df3d21b97446716b32478b0e0e5..45641fc80ca5fb595fe740cbe1c608a9702094b5 100644 (file)
@@ -1318,14 +1318,10 @@ void update_editipo_flags(void)
                        for(a=0; a<G.sipo->totipo; a++) {
                                if(ik->data[a]) {
                                        if(ik->flag & 1) {
-                                               ik->data[a]->f1 |= SELECT;
-                                               ik->data[a]->f2 |= SELECT;
-                                               ik->data[a]->f3 |= SELECT;
+                                               BEZ_SEL(ik->data[a]);
                                        }
                                        else {
-                                               ik->data[a]->f1 &= ~SELECT;
-                                               ik->data[a]->f2 &= ~SELECT;
-                                               ik->data[a]->f3 &= ~SELECT;
+                                               BEZ_DESEL(ik->data[a]);
                                        }
                                }
                        }
@@ -1423,7 +1419,7 @@ static short findnearest_ipovert(IpoCurve **icu, BezTriple **bezt)
                                        if(ei->disptype!=IPO_DISPBITS && ei->icu->ipo==IPO_BEZ) {
                                                /* middle points get an advantage */
                                                temp= -3+abs(mval[0]- sco[0][0])+ abs(mval[1]- sco[0][1]);
-                                               if( bezt1->f1 & 1) temp+=5;
+                                               if( bezt1->f1 & SELECT) temp+=5;
                                                if(temp<dist) { 
                                                        hpoint= 0; 
                                                        *bezt= bezt1; 
@@ -1514,18 +1510,18 @@ void mouse_select_ipo(void)
                        if(bezt) {
                                if(hand==1) {
                                        if(BEZSELECTED(bezt)) {
-                                               bezt->f1= bezt->f2= bezt->f3= 0;
+                                               BEZ_DESEL(bezt);
                                        }
                                        else {
-                                               bezt->f1= bezt->f2= bezt->f3= SELECT;
+                                               BEZ_SEL(bezt);
                                        }
                                }
                                else if(hand==0) {
-                                       if(bezt->f1 & SELECT) bezt->f1= 0;
+                                       if(bezt->f1 & SELECT) bezt->f1 &= ~SELECT;
                                        else bezt->f1= SELECT;
                                }
                                else {
-                                       if(bezt->f3 & SELECT) bezt->f3= 0;
+                                       if(bezt->f3 & SELECT) bezt->f3 &= ~SELECT;
                                        else bezt->f3= SELECT;
                                }
                        }                               
@@ -1535,7 +1531,7 @@ void mouse_select_ipo(void)
                        
                        if(bezt) {
                                if(hand==1) {
-                                       bezt->f1|= SELECT; bezt->f2|= SELECT; bezt->f3|= SELECT;
+                                       BEZ_SEL(bezt);
                                }
                                else if(hand==0) bezt->f1 |= SELECT;
                                else bezt->f3 |= SELECT;
@@ -2261,7 +2257,7 @@ void add_duplicate_editipo(void)
                                        while(b--) {
                                                *beztn= *bezt;
                                                if(bezt->f2 & SELECT) {
-                                                       beztn->f1= beztn->f2= beztn->f3= 0;
+                                                       BEZ_DESEL(beztn);
                                                        beztn++;
                                                        *beztn= *bezt;
                                                }
@@ -3474,14 +3470,10 @@ void make_ipokey(void)
                        if(ik->data[a]) {
                                bezt= ik->data[a];
                                if(sel) {
-                                       bezt->f1 |= SELECT;
-                                       bezt->f2 |= SELECT;
-                                       bezt->f3 |= SELECT;
+                                       BEZ_SEL(bezt);
                                }
                                else {
-                                       bezt->f1 &= ~SELECT;
-                                       bezt->f2 &= ~SELECT;
-                                       bezt->f3 &= ~SELECT;
+                                       BEZ_DESEL(bezt);
                                }
                        }
                }
@@ -4645,7 +4637,7 @@ void duplicate_ipo_keys(Ipo *ipo)
        for (icu=ipo->curve.first; icu; icu=icu->next){
                for (i=0; i<icu->totvert; i++){
                        /* If a key is selected */
-                       if (icu->bezt[i].f2 & 1){
+                       if (icu->bezt[i].f2 & SELECT){
                                /* Expand the list */
                                newbezt = MEM_callocN(sizeof(BezTriple) * (icu->totvert+1), "beztriple");
                                memcpy (newbezt, icu->bezt, sizeof(BezTriple) * (i+1));
@@ -4655,15 +4647,10 @@ void duplicate_ipo_keys(Ipo *ipo)
                                MEM_freeN (icu->bezt);
                                icu->bezt=newbezt;
                                /* Unselect the current key*/
-                               icu->bezt[i].f1 &= ~ 1;
-                               icu->bezt[i].f2 &= ~ 1;
-                               icu->bezt[i].f3 &= ~ 1;
+                               BEZ_DESEL(&icu->bezt[i]);
                                i++;
                                /* Select the copied key */
-                               icu->bezt[i].f1 |= 1;
-                               icu->bezt[i].f2 |= 1;
-                               icu->bezt[i].f3 |= 1;
-                               
+                               BEZ_SEL(&icu->bezt[i]);
                        }
                }
        }
index 24bb111c8d1639a3ce57750e85930660c76bae8e..94a373d58416a658870e1f1ba7af766845d0f2f6 100644 (file)
@@ -136,10 +136,10 @@ void swap_selectall_editipo(void)
                                        b= ei->icu->totvert;
                                        while(b--) {
                                                if(totipo_vertsel) {
-                                                       bezt->f1= bezt->f2= bezt->f3= 0;
+                                                       BEZ_DESEL(bezt);
                                                }
                                                else {
-                                                       bezt->f1= bezt->f2= bezt->f3= SELECT;
+                                                       BEZ_SEL(bezt);
                                                }
                                                bezt++;
                                        }
@@ -228,7 +228,7 @@ void deselectall_editipo(void)
                                        bezt= ei->icu->bezt;
                                        b= ei->icu->totvert;
                                        while(b--) {
-                                               bezt->f1= bezt->f2= bezt->f3= 0;
+                                               BEZ_SEL(bezt);
                                                bezt++;
                                        }
                                }
@@ -374,18 +374,14 @@ static int selected_bezier_loop(int (*looptest)(EditIpo *),
 int select_bezier_add(BezTriple *bezt) 
 {
        /* Select the bezier triple */
-       bezt->f1 |= SELECT;
-       bezt->f2 |= SELECT;
-       bezt->f3 |= SELECT;
+       BEZ_SEL(bezt);
        return 0;
 }
 
 int select_bezier_subtract(BezTriple *bezt) 
 {
        /* Deselect the bezier triple */
-       bezt->f1 &= ~SELECT;
-       bezt->f2 &= ~SELECT;
-       bezt->f3 &= ~SELECT;
+       BEZ_DESEL(bezt);
        return 0;
 }
 
@@ -412,9 +408,9 @@ static int set_bezier_auto(BezTriple *bezt)
        /* is a handle selected? If so
         * set it to type auto
         */
-       if(bezt->f1 || bezt->f3) {
-               if(bezt->f1) bezt->h1= 1; /* the secret code for auto */
-               if(bezt->f3) bezt->h2= 1;
+       if((bezt->f1  & SELECT) || (bezt->f3 & SELECT)) {
+               if(bezt->f1 & SELECT) bezt->h1= 1; /* the secret code for auto */
+               if(bezt->f3 & SELECT) bezt->h2= 1;
 
                /* if the handles are not of the same type, set them
                 * to type free
@@ -435,9 +431,9 @@ static int set_bezier_vector(BezTriple *bezt)
        /* is a handle selected? If so
         * set it to type vector
         */
-       if(bezt->f1 || bezt->f3) {
-               if(bezt->f1) bezt->h1= 2; /* the code for vector */
-               if(bezt->f3) bezt->h2= 2;
+       if((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+               if(bezt->f1 & SELECT) bezt->h1= 2; /* the code for vector */
+               if(bezt->f3 & SELECT) bezt->h2= 2;
     
                /* if the handles are not of the same type, set them
                 * to type free
@@ -455,8 +451,8 @@ static int bezier_isfree(BezTriple *bezt)
        /* queries whether the handle should be set
         * to type 'free' (I think)
         */
-       if(bezt->f1 && bezt->h1) return 1;
-       if(bezt->f3 && bezt->h2) return 1;
+       if((bezt->f1 & SELECT) && bezt->h1) return 1;
+       if((bezt->f3 & SELECT) && bezt->h2) return 1;
        return 0;
 }
 
@@ -464,8 +460,8 @@ static int set_bezier_free(BezTriple *bezt)
 {
        /* Sets selected bezier handles to type 'free' 
         */
-       if(bezt->f1) bezt->h1= HD_FREE;
-       if(bezt->f3) bezt->h2= HD_FREE;
+       if(bezt->f1 & SELECT) bezt->h1= HD_FREE;
+       if(bezt->f3 & SELECT) bezt->h2= HD_FREE;
        return 0;
 }
 
@@ -473,8 +469,8 @@ static int set_bezier_align(BezTriple *bezt)
 {
        /* Sets selected bezier handles to type 'align' 
         */
-       if(bezt->f1) bezt->h1= HD_ALIGN;
-       if(bezt->f3) bezt->h2= HD_ALIGN;
+       if(bezt->f1 & SELECT) bezt->h1= HD_ALIGN;
+       if(bezt->f3 & SELECT) bezt->h2= HD_ALIGN;
        return 0;
 }
 
@@ -1032,6 +1028,7 @@ void borderselect_ipo(void)
                                select_proj_ipo(&rectf, val);
                }
                else {
+                       int selflag= (val==LEFTMOUSE) ? SELECT : 0;
                        
                        ei= G.sipo->editipo;
                        for(a=0; a<G.sipo->totipo; a++, ei++) {
@@ -1040,14 +1037,12 @@ void borderselect_ipo(void)
                                                b= ei->icu->totvert;
                                                bezt= ei->icu->bezt;
                                                while(b--) {
-                                                       int bit= (val==LEFTMOUSE);
-                                                       
                                                        if(BLI_in_rctf(&rectf, bezt->vec[0][0], bezt->vec[0][1]))
-                                                               bezt->f1 = (bezt->f1&~SELECT) | bit;
+                                                               bezt->f1 = selflag ? (bezt->f1 | SELECT) : (bezt->f1 & ~SELECT);
                                                        if(BLI_in_rctf(&rectf, bezt->vec[1][0], bezt->vec[1][1]))
-                                                               bezt->f2 = (bezt->f2&~SELECT) | bit;
+                                                               bezt->f2 = selflag ? (bezt->f2 | SELECT) : (bezt->f2 & ~SELECT);
                                                        if(BLI_in_rctf(&rectf, bezt->vec[2][0], bezt->vec[2][1]))
-                                                               bezt->f3 = (bezt->f3&~SELECT) | bit;
+                                                               bezt->f3 = selflag ? (bezt->f3 | SELECT) : (bezt->f3 & ~SELECT);
 
                                                        bezt++;
                                                }
@@ -1211,19 +1206,13 @@ void set_ipo_key_selection(Ipo *ipo, int sel)
        for (icu=ipo->curve.first; icu; icu=icu->next){
                for (i=0; i<icu->totvert; i++){
                        if (sel == 2) {
-                               icu->bezt[i].f1^=1;
-                               icu->bezt[i].f2^=1;
-                               icu->bezt[i].f3^=1;
+                               BEZ_INVSEL(&icu->bezt[i]);
                        }
                        else if (sel == 1){
-                               icu->bezt[i].f1|=1;
-                               icu->bezt[i].f2|=1;
-                               icu->bezt[i].f3|=1;
+                               BEZ_SEL(&icu->bezt[i]);
                        }
                        else{
-                               icu->bezt[i].f1&=~1;
-                               icu->bezt[i].f2&=~1;
-                               icu->bezt[i].f3&=~1;
+                               BEZ_DESEL(&icu->bezt[i]);
                        }
                }
        }
@@ -1240,10 +1229,10 @@ int fullselect_ipo_keys(Ipo *ipo)
        
        for (icu=ipo->curve.first; icu; icu=icu->next) {
                for (i=0; i<icu->totvert; i++){
-                       if (icu->bezt[i].f2 & 1){
+                       if (icu->bezt[i].f2 & SELECT){
                                tvtot+=3;
-                               icu->bezt[i].f1 |= 1;
-                               icu->bezt[i].f3 |= 1;
+                               icu->bezt[i].f1 |= SELECT;
+                               icu->bezt[i].f3 |= SELECT;
                        }
                }
        }
index 60be622e3addb0759884fb3d6b44dc25a35048b7..47eee872a8a2b97e902809f4407e938df276966c 100644 (file)
@@ -826,11 +826,11 @@ void retopo_do_all()
                                }
                                else if(nu->type & CU_BEZIER) {
                                        for(i=0; i<nu->pntsu; ++i) {
-                                               if(nu->bezt[i].f1 & 1)
+                                               if(nu->bezt[i].f1 & SELECT)
                                                        retopo_do_vert(G.vd, nu->bezt[i].vec[0]);
-                                               if(nu->bezt[i].f2 & 1)
+                                               if(nu->bezt[i].f2 & SELECT)
                                                        retopo_do_vert(G.vd, nu->bezt[i].vec[1]);
-                                               if(nu->bezt[i].f3 & 1)
+                                               if(nu->bezt[i].f3 & SELECT)
                                                        retopo_do_vert(G.vd, nu->bezt[i].vec[2]);
                                        }
                                }