Revision: 29842
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29842
Author:   nazgul
Date:     2010-07-01 13:37:39 +0200 (Thu, 01 Jul 2010)

Log Message:
-----------
Partial merge of 28520 from the trunk

- Merged changes of curve DNA
- Merged changes in curve undo stuff
- Ignored changes in rna, user preferences and drawobject
  (too many conflicts and not actually needed in this branch)

Such merge is needed for easier adopt curve shape keys patch which
was written against latest trunk (and for further easier merge this
patch to the trunk)

Do not merge this commit to the trunk

Modified Paths:
--------------
    branches/nurbs25/source/blender/blenloader/intern/readfile.c
    branches/nurbs25/source/blender/editors/curve/editcurve.c
    branches/nurbs25/source/blender/editors/space_view3d/view3d_select.c
    branches/nurbs25/source/blender/makesdna/DNA_curve_types.h

Modified: branches/nurbs25/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/nurbs25/source/blender/blenloader/intern/readfile.c        
2010-07-01 11:02:43 UTC (rev 29841)
+++ branches/nurbs25/source/blender/blenloader/intern/readfile.c        
2010-07-01 11:37:39 UTC (rev 29842)
@@ -2875,7 +2875,7 @@
        cu->bev.first=cu->bev.last= NULL;
        cu->disp.first=cu->disp.last= NULL;
        cu->editnurb= NULL;
-       cu->lastselbp= NULL;
+       cu->lastsel= NULL;
        cu->path= NULL;
        cu->editfont= NULL;
        

Modified: branches/nurbs25/source/blender/editors/curve/editcurve.c
===================================================================
--- branches/nurbs25/source/blender/editors/curve/editcurve.c   2010-07-01 
11:02:43 UTC (rev 29841)
+++ branches/nurbs25/source/blender/editors/curve/editcurve.c   2010-07-01 
11:37:39 UTC (rev 29842)
@@ -89,6 +89,12 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h" /* for paint cursor */
 
+/* Undo stuff */
+typedef struct {
+       ListBase nubase;
+       void *lastsel;
+} UndoCurve;
+
 void selectend_nurb(Object *obedit, short selfirst, short doswap, short 
selstatus);
 static void select_adjacent_cp(ListBase *editnurb, short next, short cont, 
short selstatus);
 
@@ -371,7 +377,7 @@
                        editnurb= cu->editnurb= MEM_callocN(sizeof(ListBase), 
"editnurb");
                
                nu= cu->nurb.first;
-               cu->lastselbp= NULL;   /* for select row */
+               cu->lastsel= NULL;   /* for select row */
                
                while(nu) {
                        newnu= duplicateNurb(nu);
@@ -436,6 +442,8 @@
                BezTriple *bezt;
                int a;
 
+               cu->lastsel= NULL;
+
                for(nu= editnurb->first; nu; nu= nu->next) {
                        if(nu->type == CU_BEZIER) {
                                bezt= nu->bezt;
@@ -727,7 +735,7 @@
        if(obedit && obedit->type==OB_SURF);
        else return OPERATOR_CANCELLED;
 
-       cu->lastselbp= NULL;
+       cu->lastsel= NULL;
 
        nu= editnurb->first;
        while(nu) {
@@ -934,9 +942,12 @@
        Nurb *nu, *newnu;
        BezTriple *bezt, *bezt1;
        BPoint *bp, *bp1;
+       Curve *cu= (Curve*)obedit->data;
        int a, b, starta, enda, newu, newv;
        char *usel;
 
+       cu->lastsel= NULL;
+
        nu= editnurb->last;
        while(nu) {
                if(nu->type == CU_BEZIER) {
@@ -2419,11 +2430,15 @@
        Nurb *nu;
        BPoint *bp;
        BezTriple *bezt;
+       Curve *cu;
        int a;
        short sel;
-       
+
        if(obedit==0) return;
-       
+
+       cu= (Curve*)obedit->data;
+       cu->lastsel= NULL;
+
        for(nu= editnurb->first; nu; nu= nu->next) {
                sel= 0;
                if(nu->type == CU_BEZIER) {
@@ -2739,6 +2754,8 @@
        BezTriple *bezt;
        int a;
 
+       cu->lastsel= NULL;
+
        for(nu= editnurb->first; nu; nu= nu->next) {
                if(nu->type == CU_BEZIER) {
                        bezt= nu->bezt;
@@ -4114,12 +4131,18 @@
 
                        if(bezt) {
 
-                               if(hand==1) select_beztriple(bezt, SELECT, 1, 
HIDDEN);
-                               else if(hand==0) bezt->f1|= SELECT;
-                               else bezt->f3|= SELECT;
+                               if(hand==1) {
+                                       select_beztriple(bezt, SELECT, 1, 
HIDDEN);
+                                       cu->lastsel= bezt;
+                               } else {
+                                       if(hand==0) bezt->f1|= SELECT;
+                                       else bezt->f3|= SELECT;
+
+                                       cu->lastsel= NULL;
+                               }
                        }
                        else {
-                               cu->lastselbp= bp;
+                               cu->lastsel= bp;
                                select_bpoint(bp, SELECT, 1, HIDDEN);
                        }
 
@@ -4127,8 +4150,13 @@
                else {
                        if(bezt) {
                                if(hand==1) {
-                                       if(bezt->f2 & SELECT) 
select_beztriple(bezt, DESELECT, 1, HIDDEN);
-                                       else select_beztriple(bezt, SELECT, 1, 
HIDDEN);
+                                       if(bezt->f2 & SELECT) {
+                                               select_beztriple(bezt, 
DESELECT, 1, HIDDEN);
+                                               if (bezt == cu->lastsel) 
cu->lastsel = NULL;
+                                       } else {
+                                               select_beztriple(bezt, SELECT, 
1, HIDDEN);
+                                               cu->lastsel= bezt;
+                                       }
                                } else if(hand==0) {
                                        bezt->f1 ^= SELECT;
                                } else {
@@ -4136,10 +4164,12 @@
                                }
                        }
                        else {
-                               if(bp->f1 & SELECT) select_bpoint(bp, DESELECT, 
1, HIDDEN);
-                               else {
+                               if(bp->f1 & SELECT) {
+                                       select_bpoint(bp, DESELECT, 1, HIDDEN);
+                                       if (cu->lastsel == bp) cu->lastsel = 
NULL;
+                               } else {
                                        select_bpoint(bp, SELECT, 1, HIDDEN);
-                                       cu->lastselbp= bp;
+                                       cu->lastsel= bp;
                                }
                        }
 
@@ -4793,7 +4823,7 @@
 
        if(editnurb->first==0)
                return OPERATOR_CANCELLED;
-       if(cu->lastselbp==NULL)
+       if(cu->lastsel==NULL)
                return OPERATOR_CANCELLED;
 
        /* find the correct nurb and toggle with u of v */
@@ -4801,7 +4831,7 @@
                bp= nu->bp;
                for(v=0; v<nu->pntsv; v++) {
                        for(u=0; u<nu->pntsu; u++, bp++) {
-                               if(bp==cu->lastselbp) {
+                               if(bp==cu->lastsel) {
                                        if(bp->f1 & SELECT) {
                                                ok= 1;
                                                break;
@@ -4812,11 +4842,11 @@
                }
 
                if(ok) {
-                       if(last==cu->lastselbp) {
+                       if(last==cu->lastsel) {
                                direction= 1-direction;
                                setflagsNurb(editnurb, 0);
                        }
-                       last= cu->lastselbp;
+                       last= cu->lastsel;
 
                        bp= nu->bp;
                        for(a=0; a<nu->pntsv; a++) {
@@ -6047,49 +6077,87 @@
 
 /****************** undo for curves ****************/
 
-static void undoCurve_to_editCurve(void *lbu, void *lbe)
+static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu)
 {
-       ListBase *lb= lbu;
-       ListBase *editnurb= lbe;
+       if (nu->bezt) {
+               BezTriple *lastbezt= (BezTriple*)lastsel;
+               if (lastbezt >= nu->bezt && lastbezt < nu->bezt + nu->pntsu) {
+                       return newnu->bezt + (lastbezt - nu->bezt);
+               }
+       } else {
+               BPoint *lastbp= (BPoint*)lastsel;
+               if (lastbp >= nu->bp && lastbp < nu->bp + nu->pntsu*nu->pntsv) {
+                       return newnu->bp + (lastbp - nu->bp);
+               }
+       }
+
+       return NULL;
+}
+
+static void undoCurve_to_editCurve(void *ucu, void *cue)
+{
+       Curve *cu= cue;
+       UndoCurve *undoCurve= ucu;
+       ListBase *undobase= &undoCurve->nubase;
+       ListBase *editbase= cu->editnurb;
        Nurb *nu, *newnu;
-       
-       freeNurblist(editnurb);
+       void *lastsel= NULL;
 
+       freeNurblist(editbase);
+
        /* copy  */
-       for(nu= lb->first; nu; nu= nu->next) {
+       for(nu= undobase->first; nu; nu= nu->next) {
                newnu= duplicateNurb(nu);
-               BLI_addtail(editnurb, newnu);
+
+               if (lastsel == NULL) {
+                       lastsel= undo_check_lastsel(undoCurve->lastsel, nu, 
newnu);
+               }
+
+               BLI_addtail(editbase, newnu);
        }
+
+       cu->lastsel= lastsel;
 }
 
-static void *editCurve_to_undoCurve(void *lbe)
+static void *editCurve_to_undoCurve(void *cue)
 {
-       ListBase *editnurb= lbe;
-       ListBase *lb;
+       Curve *cu= cue;
+       ListBase *nubase= cu->editnurb;
+       UndoCurve *undoCurve;
        Nurb *nu, *newnu;
+       void *lastsel= NULL;
 
-       lb= MEM_callocN(sizeof(ListBase), "listbase undo");
-       
+       undoCurve= MEM_callocN(sizeof(UndoCurve), "undoCurve");
+
        /* copy  */
-       for(nu= editnurb->first; nu; nu= nu->next) {
+       for(nu= nubase->first; nu; nu= nu->next) {
                newnu= duplicateNurb(nu);
-               BLI_addtail(lb, newnu);
+
+               if (lastsel == NULL) {
+                       lastsel= undo_check_lastsel(cu->lastsel, nu, newnu);
+               }
+
+               BLI_addtail(&undoCurve->nubase, newnu);
        }
-       return lb;
+
+       undoCurve->lastsel= lastsel;
+
+       return undoCurve;
 }
 
-static void free_undoCurve(void *lbv)
+static void free_undoCurve(void *ucv)
 {
-       ListBase *lb= lbv;
-       
-       freeNurblist(lb);
-       MEM_freeN(lb);
+       UndoCurve *undoCurve= ucv;
+
+       freeNurblist(&undoCurve->nubase);
+
+       MEM_freeN(undoCurve);
 }
 
 static void *get_data(bContext *C)
 {
        Object *obedit= CTX_data_edit_object(C);
-       return curve_get_editcurve(obedit);
+       return obedit->data;
 }
 
 /* and this is all the undo system needs to know */

Modified: branches/nurbs25/source/blender/editors/space_view3d/view3d_select.c
===================================================================
--- branches/nurbs25/source/blender/editors/space_view3d/view3d_select.c        
2010-07-01 11:02:43 UTC (rev 29841)
+++ branches/nurbs25/source/blender/editors/space_view3d/view3d_select.c        
2010-07-01 11:37:39 UTC (rev 29842)
@@ -563,14 +563,15 @@
 
 static void do_lasso_select_curve__doSelect(void *userData, Nurb *nu, BPoint 
*bp, BezTriple *bezt, int beztindex, int x, int y)
 {
-       struct { ViewContext vc; short (*mcords)[2]; short moves; short select; 
} *data = userData;
-       
+       struct { ViewContext *vc; short (*mcords)[2]; short moves; short 
select; } *data = userData;
+       Object *obedit= data->vc->obedit;
+       Curve *cu= (Curve*)obedit->data;
+
        if (lasso_inside(data->mcords, data->moves, x, y)) {
                if (bp) {
                        bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
+                       if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = 
NULL;
                } else {
-                       Curve *cu= data->vc.obedit->data;
-                       
                        if (cu->drawflag & CU_HIDE_HANDLES) {
                                /* can only be beztindex==0 here since handles 
are hidden */
                                bezt->f1 = bezt->f2 = bezt->f3 = 
data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
@@ -583,16 +584,18 @@
                                        bezt->f3 = 
data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT);
                                }
                        }
+
+                       if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel 
= NULL;
                }
        }
 }
 
 static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short 
moves, short select)
 {
-       struct { ViewContext vc; short (*mcords)[2]; short moves; short select; 
} data;
+       struct { ViewContext *vc; short (*mcords)[2]; short moves; short 
select; } data;
 
        /* set vc->editnurb */
-       data.vc = *vc;
+       data.vc = vc;
        data.mcords = mcords;
        data.moves = moves;
        data.select = select;
@@ -1283,14 +1286,15 @@
 
 static void do_nurbs_box_select__doSelect(void *userData, Nurb *nu, BPoint 
*bp, BezTriple *bezt, int beztindex, int x, int y)
 {
-       struct { ViewContext vc; rcti *rect; int select; } *data = userData;
+       struct { ViewContext *vc; rcti *rect; int select; } *data = userData;
+       Object *obedit= data->vc->obedit;
+       Curve *cu= (Curve*)obedit->data;
 
        if (BLI_in_rcti(data->rect, x, y)) {
                if (bp) {
                        bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
+                       if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = 
NULL;
                } else {
-                       Curve *cu= data->vc.obedit->data;
-                       
                        if (cu->drawflag & CU_HIDE_HANDLES) {
                                /* can only be beztindex==0 here since handles 
are hidden */
                                bezt->f1 = bezt->f2 = bezt->f3 = 
data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
@@ -1303,14 +1307,16 @@
                                        bezt->f3 = 
data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT);
                                }
                        }
+
+                       if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel 
= NULL;
                }
        }
 }
 static void do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int 
extend)
 {
-       struct { ViewContext vc; rcti *rect; int select; } data;
+       struct { ViewContext *vc; rcti *rect; int select; } data;
        
-       data.vc = *vc;
+       data.vc = vc;
        data.rect = rect;
        data.select = select;
 
@@ -1874,18 +1880,29 @@
        struct {ViewContext *vc; short select, mval[2]; float radius; } *data = 
userData;
        int mx = x - data->mval[0], my = y - data->mval[1];
        float r = sqrt(mx*mx + my*my);
+       Object *obedit= data->vc->obedit;
+       Curve *cu= (Curve*)obedit->data;
 
        if (r<=data->radius) {
                if (bp) {
                        bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
+
+                       if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = 
NULL;
                } else {

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to