Merging revisions 14946-15020 of https://svn.blender.org/svnroot/bf-blender/trunk...
[blender.git] / source / blender / src / buttons_editing.c
index bcd373ddbc3dac75563766ed1d76e252e696019f..d2f798d0b6e0fec0f2f8b667208ab4a16289df53 100644 (file)
@@ -3075,7 +3075,6 @@ static void editing_panel_font_type(Object *ob, Curve *cu)
 
 void do_curvebuts(unsigned short event)
 {
-       extern Nurb *lastnu;
        extern ListBase editNurb;  /* from editcurve */
        Object *ob;
        Curve *cu;
@@ -3109,13 +3108,15 @@ void do_curvebuts(unsigned short event)
                                if(isNurbsel(nu)) {
                                        if((nu->type & 7)==CU_NURBS) {
                                                if(event<B_UNIFV) {
-                                                       nu->flagu &= 1;
-                                                       nu->flagu += ((event-B_UNIFU)<<1);
+                                                       nu->flagu &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */
+                                                       nu->flagu |= ((event-B_UNIFU)<<1);
+                                                       clamp_nurb_order_u(nu);
                                                        makeknots(nu, 1, nu->flagu>>1);
                                                }
                                                else if(nu->pntsv>1) {
-                                                       nu->flagv &= 1;
-                                                       nu->flagv += ((event-B_UNIFV)<<1);
+                                                       nu->flagv &= CU_CYCLIC; /* disable all flags except for CU_CYCLIC */
+                                                       nu->flagv |= ((event-B_UNIFV)<<1);
+                                                       clamp_nurb_order_v(nu);
                                                        makeknots(nu, 2, nu->flagv>>1);
                                                }
                                        }
@@ -3151,15 +3152,13 @@ void do_curvebuts(unsigned short event)
                break;
        case B_SETORDER:
                if(G.obedit) {
-                       nu= lastnu;
+                       nu= get_actNurb();
                        if(nu && (nu->type & 7)==CU_NURBS ) {
-                               if(nu->orderu>nu->pntsu) {
-                                       nu->orderu= nu->pntsu;
+                               if(clamp_nurb_order_u(nu)) {
                                        scrarea_queue_winredraw(curarea);
                                }
                                makeknots(nu, 1, nu->flagu>>1);
-                               if(nu->orderv>nu->pntsv) {
-                                       nu->orderv= nu->pntsv;
+                               if(clamp_nurb_order_v(nu)) {
                                        scrarea_queue_winredraw(curarea);
                                }
                                makeknots(nu, 2, nu->flagv>>1);
@@ -3277,7 +3276,6 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
 {
        Nurb *nu;
        extern ListBase editNurb;  /* from editcurve */
-       extern Nurb *lastnu;
        uiBlock *block;
        short *sp;
 
@@ -3313,8 +3311,11 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
        uiBlockEndAlign(block);
 
        if(ob==G.obedit) {
-               nu= lastnu;
-               if(nu==NULL) nu= lastnu= editNurb.first;
+               nu= get_actNurb();
+               if(nu==NULL && editNurb.first) {
+                       nu= editNurb.first;
+                       set_actNurb(nu);
+               }
                if(nu) {
                        if (ob->type==OB_CURVE) {
                                uiDefBut(block, LABEL, 0, "Tilt",