Made active point and active spline behaviour more predictable on curves/surfaces:
authorKevin Mackay <mackay.ka@gmail.com>
Tue, 5 Nov 2013 23:37:09 +0000 (23:37 +0000)
committerKevin Mackay <mackay.ka@gmail.com>
Tue, 5 Nov 2013 23:37:09 +0000 (23:37 +0000)
* deselect all no longer leaves an active point
* the most recently added spline becomes the active one
* on successful duplicate/delete the active point and active spline are reset

source/blender/blenkernel/intern/curve.c
source/blender/editors/curve/editcurve.c
source/blender/editors/curve/editcurve_add.c

index ca9f97b754c45d977939ec35fe5355772801e8b5..4524b3ac7acd7640739d5f56547f8716c3158373 100644 (file)
@@ -230,6 +230,7 @@ Curve *BKE_curve_copy(Curve *cu)
        cun->editnurb = NULL;
        cun->editfont = NULL;
        cun->selboxes = NULL;
+       cun->lastsel = NULL;
 
 #if 0   // XXX old animation system
        /* single user ipo too */
index bd91740521d4816886526c5eb3d47541595a9ca5..f576440fe927d0e31e687437d3f7dab46c77aa73 100644 (file)
@@ -1279,6 +1279,8 @@ void CU_deselect_all(Object *obedit)
        if (editnurb) {
                Nurb *nu;
                int a;
+               ((Curve *)obedit->data)->lastsel = NULL;
+
                for (nu = editnurb->first; nu; nu = nu->next) {
                        if (nu->bezt) {
                                BezTriple *bezt;
@@ -1902,7 +1904,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
        int a, b, c, starta, enda, diffa, cyclicu, cyclicv, newu, newv;
        char *usel;
 
-       cu->lastsel = NULL;
        while (nu) {
                cyclicu = cyclicv = 0;
                if (nu->type == CU_BEZIER) {
@@ -1927,7 +1928,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
 
                                                newnu = BKE_nurb_copy(nu, newu, 1);
                                                BLI_addtail(newnurb, newnu);
-                                               set_actNurb(obedit, newnu);
                                                memcpy(newnu->bezt, &nu->bezt[starta], diffa * sizeof(BezTriple));
                                                if (newu != diffa) {
                                                        memcpy(&newnu->bezt[diffa], nu->bezt, cyclicu * sizeof(BezTriple));
@@ -1976,7 +1976,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
 
                                                newnu = BKE_nurb_copy(nu, newu, 1);
                                                BLI_addtail(newnurb, newnu);
-                                               set_actNurb(obedit, newnu);
                                                memcpy(newnu->bp, &nu->bp[starta], diffa * sizeof(BPoint));
                                                if (newu != diffa) {
                                                        memcpy(&newnu->bp[diffa], nu->bp, cyclicu * sizeof(BPoint));
@@ -1995,8 +1994,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
                        if (cyclicu != 0) {
                                newnu = BKE_nurb_copy(nu, cyclicu, 1);
                                BLI_addtail(newnurb, newnu);
-                               set_actNurb(obedit, newnu);
-
                                memcpy(newnu->bp, nu->bp, cyclicu * sizeof(BPoint));
                                newnu->flagu &= ~CU_NURB_CYCLIC;
 
@@ -2093,7 +2090,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
                                                                        memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu + a], newu * sizeof(BPoint));
                                                                }
                                                        }
-                                                       set_actNurb(obedit, newnu);
                                                        BLI_addtail(newnurb, newnu);
 
                                                        if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
@@ -2110,7 +2106,6 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
                                                for (b = 0; b < newv; b++) {
                                                        memcpy(&newnu->bp[b * newu], &nu->bp[b * nu->pntsu], newu * sizeof(BPoint));
                                                }
-                                               set_actNurb(obedit, newnu);
                                                BLI_addtail(newnurb, newnu);
 
                                                if (newu != nu->pntsu) newnu->flagu &= ~CU_NURB_CYCLIC;
@@ -2127,32 +2122,35 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
                nu = nu->prev;
        }
 
-       for (nu = newnurb->first; nu; nu = nu->next) {
-               if (nu->type == CU_BEZIER) {
-                       if (split) {
-                               /* recalc first and last */
-                               BKE_nurb_handle_calc_simple(nu, &nu->bezt[0]);
-                               BKE_nurb_handle_calc_simple(nu, &nu->bezt[nu->pntsu - 1]);
-                       }
-               }
-               else {
-                       /* knots done after duplicate as pntsu may change */
-                       nu->knotsu = nu->knotsv = NULL;
-                       BKE_nurb_order_clamp_u(nu);
-                       BKE_nurb_knot_calc_u(nu);
+       if (newnurb->first != NULL) {
+               cu->lastsel = NULL;
+               cu->actnu = -1;
 
-                       if (obedit->type == OB_SURF) {
-                               for (a = 0, bp = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp++) {
-                                       bp->f1 &= ~SURF_SEEN;
+               for (nu = newnurb->first; nu; nu = nu->next) {
+                       if (nu->type == CU_BEZIER) {
+                               if (split) {
+                                       /* recalc first and last */
+                                       BKE_nurb_handle_calc_simple(nu, &nu->bezt[0]);
+                                       BKE_nurb_handle_calc_simple(nu, &nu->bezt[nu->pntsu - 1]);
                                }
+                       }
+                       else {
+                               /* knots done after duplicate as pntsu may change */
+                               nu->knotsu = nu->knotsv = NULL;
+                               BKE_nurb_order_clamp_u(nu);
+                               BKE_nurb_knot_calc_u(nu);
 
-                               BKE_nurb_order_clamp_v(nu);
-                               BKE_nurb_knot_calc_v(nu);
+                               if (obedit->type == OB_SURF) {
+                                       for (a = 0, bp = nu->bp; a < nu->pntsu * nu->pntsv; a++, bp++) {
+                                               bp->f1 &= ~SURF_SEEN;
+                                       }
+
+                                       BKE_nurb_order_clamp_v(nu);
+                                       BKE_nurb_knot_calc_v(nu);
+                               }
                        }
                }
        }
-
-       /* actnu changed */
 }
 
 /**************** switch direction operator ***************/
@@ -6367,6 +6365,7 @@ static int curve_delete_segments(Object *obedit, const bool split)
 static int curve_delete_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);
+       Curve *cu = (Curve *)obedit->data;
        eCurveElem_Types type = RNA_enum_get(op->ptr, "type");
        int retval;
 
@@ -6375,6 +6374,9 @@ static int curve_delete_exec(bContext *C, wmOperator *op)
        else BLI_assert(0);
 
        if (retval == OPERATOR_FINISHED) {
+               cu->lastsel = NULL;
+               cu->actnu = -1;
+
                if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit);
 
                WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
index 9b858a2c4e94e56fbbe9ee137b1af1c6033e7f6f..6804aa3584f0dfe96ae394b3388c0fd71f56c31d 100644 (file)
@@ -458,6 +458,8 @@ Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type
 
        if (nu) { /* should always be set */
                nu->flag |= CU_SMOOTH;
+               cu->actnu = BLI_countlist(editnurb);
+               cu->lastsel = NULL;
 
                BKE_nurb_test2D(nu);
        }