rename RNA_property_is_set() --> RNA_struct_property_is_set() in preperation to add...
[blender.git] / source / blender / editors / curve / editcurve.c
index 84df77bb120fa3e0a2f6225e00c6c48bf3b6a4ef..aea6f5c43b6e0630d3c49ece88eea32bb7cd821f 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -690,8 +688,8 @@ static void key_to_bezt(float *key, BezTriple *basebezt, BezTriple *bezt)
 
 static void bezt_to_key(BezTriple *bezt, float *key)
 {
-        memcpy(key, bezt->vec, sizeof(float) * 9);
-        key[9] = bezt->alfa;
+       memcpy(key, bezt->vec, sizeof(float) * 9);
+       key[9] = bezt->alfa;
 }
 
 static void calc_keyHandles(ListBase *nurb, float *key)
@@ -818,7 +816,7 @@ static void calc_shapeKeys(Object *obedit)
                                                        if (oldbezt) {
                                                                int j;
                                                                for (j= 0; j < 3; ++j) {
-                                                                       VECSUB(ofs[i], bezt->vec[j], oldbezt->vec[j]);
+                                                                       sub_v3_v3v3(ofs[i], bezt->vec[j], oldbezt->vec[j]);
                                                                        i++;
                                                                }
                                                                ofs[i++][0]= bezt->alfa - oldbezt->alfa;
@@ -834,7 +832,7 @@ static void calc_shapeKeys(Object *obedit)
                                                while(a--) {
                                                        oldbp= getKeyIndexOrig_bp(editnurb, bp);
                                                        if (oldbp) {
-                                                               VECSUB(ofs[i], bp->vec, oldbp->vec);
+                                                               sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec);
                                                                ofs[i+1][0]= bp->alfa - oldbp->alfa;
                                                        }
                                                        i += 2;
@@ -868,10 +866,10 @@ static void calc_shapeKeys(Object *obedit)
                                                        oldbezt= getKeyIndexOrig_bezt(editnurb, bezt);
 
                                                        for (j= 0; j < 3; ++j, ++i) {
-                                                               VECCOPY(fp, bezt->vec[j]);
+                                                               copy_v3_v3(fp, bezt->vec[j]);
 
                                                                if (restore && oldbezt) {
-                                                                       VECCOPY(bezt->vec[j], oldbezt->vec[j]);
+                                                                       copy_v3_v3(bezt->vec[j], oldbezt->vec[j]);
                                                                }
 
                                                                fp+= 3;
@@ -892,12 +890,12 @@ static void calc_shapeKeys(Object *obedit)
                                                while(a--) {
                                                        oldbp= getKeyIndexOrig_bp(editnurb, bp);
 
-                                                       VECCOPY(fp, bp->vec);
+                                                       copy_v3_v3(fp, bp->vec);
 
                                                        fp[3]= bp->alfa;
 
                                                        if(restore && oldbp) {
-                                                               VECCOPY(bp->vec, oldbp->vec);
+                                                               copy_v3_v3(bp->vec, oldbp->vec);
                                                                bp->alfa= oldbp->alfa;
                                                        }
 
@@ -923,10 +921,10 @@ static void calc_shapeKeys(Object *obedit)
                                                                        curofp= ofp + index;
 
                                                                        for (j= 0; j < 3; ++j, ++i) {
-                                                                               VECCOPY(fp, curofp);
+                                                                               copy_v3_v3(fp, curofp);
 
                                                                                if(apply_offset) {
-                                                                                       VECADD(fp, fp, ofs[i]);
+                                                                                       add_v3_v3(fp, ofs[i]);
                                                                                }
 
                                                                                fp+= 3; curofp+= 3;
@@ -935,7 +933,7 @@ static void calc_shapeKeys(Object *obedit)
 
                                                                        if(apply_offset) {
                                                                                /* apply alfa offsets */
-                                                                               VECADD(fp, fp, ofs[i]);
+                                                                               add_v3_v3(fp, ofs[i]);
                                                                                ++i;
                                                                        }
 
@@ -943,7 +941,7 @@ static void calc_shapeKeys(Object *obedit)
                                                                } else {
                                                                        int j;
                                                                        for (j= 0; j < 3; ++j, ++i) {
-                                                                               VECCOPY(fp, bezt->vec[j]);
+                                                                               copy_v3_v3(fp, bezt->vec[j]);
                                                                                fp+= 3;
                                                                        }
                                                                        fp[0]= bezt->alfa;
@@ -961,15 +959,15 @@ static void calc_shapeKeys(Object *obedit)
 
                                                                if (index >= 0) {
                                                                        curofp= ofp + index;
-                                                                       VECCOPY(fp, curofp);
+                                                                       copy_v3_v3(fp, curofp);
                                                                        fp[3]= curofp[3];
 
                                                                        if(apply_offset) {
-                                                                               VECADD(fp, fp, ofs[i]);
+                                                                               add_v3_v3(fp, ofs[i]);
                                                                                fp[3]+=ofs[i+1][0];
                                                                        }
                                                                } else {
-                                                                       VECCOPY(fp, bp->vec);
+                                                                       copy_v3_v3(fp, bp->vec);
                                                                        fp[3]= bp->alfa;
                                                                }
 
@@ -1071,17 +1069,17 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
                        while (a--) {
                                keyIndex= getCVKeyIndex(editnurb, bezt);
                                if(keyIndex) {
-                                       sprintf(rna_path, "splines[%d].bezier_points[%d]", nu_index, pt_index);
-                                       sprintf(orig_rna_path, "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index);
+                                       BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index);
+                                       BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index);
 
                                        if(keyIndex->switched) {
                                                char handle_path[64], orig_handle_path[64];
-                                               sprintf(orig_handle_path, "%s.handle_left", orig_rna_path);
-                                               sprintf(handle_path, "%s.handle_right", rna_path);
+                                               BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path);
+                                               BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path);
                                                fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves);
 
-                                               sprintf(orig_handle_path, "%s.handle_right", orig_rna_path);
-                                               sprintf(handle_path, "%s.handle_left", rna_path);
+                                               BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_right", orig_rna_path);
+                                               BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_left", rna_path);
                                                fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves);
                                        }
 
@@ -1102,8 +1100,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
                        while (a--) {
                                keyIndex= getCVKeyIndex(editnurb, bp);
                                if(keyIndex) {
-                                       sprintf(rna_path, "splines[%d].points[%d]", nu_index, pt_index);
-                                       sprintf(orig_rna_path, "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index);
+                                       BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index);
+                                       BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index);
                                        fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
 
                                        keyIndex->nu_index= nu_index;
@@ -1142,8 +1140,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
                }
 
                if(keyIndex) {
-                       sprintf(rna_path, "splines[%d]", nu_index);
-                       sprintf(orig_rna_path, "splines[%d]", keyIndex->nu_index);
+                       BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index);
+                       BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index);
                        fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
                }
 
@@ -2376,7 +2374,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
        BezTriple *bezt;
        BPoint *bp;
        int a;
-       short lastsel= 0, sel=0;
+       short lastsel= 0;
        
        if(next==0) return;
        
@@ -2388,13 +2386,12 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
                        if(next < 0) bezt= (nu->bezt + (a-1));
                        while(a--) {
                                if(a-abs(next) < 0) break;
-                               sel= 0;
                                if((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) {
                                        bezt+=next;
                                        if(!(bezt->f2 & SELECT) || (selstatus==0)) {
-                                               sel= select_beztriple(bezt, selstatus, 1, VISIBLE);     
+                                               short sel= select_beztriple(bezt, selstatus, 1, VISIBLE);
                                                if((sel==1) && (cont==0)) lastsel= 1;
-                                       }                                                       
+                                       }
                                }
                                else {
                                        bezt+=next;
@@ -2410,11 +2407,10 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short
                        if(next < 0) bp= (nu->bp + (a-1));
                        while(a--) {
                                if(a-abs(next) < 0) break;
-                               sel=0;
                                if((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) {
                                        bp+=next;
                                        if(!(bp->f1 & SELECT) || (selstatus==0)) {
-                                               sel= select_bpoint(bp, selstatus, 1, VISIBLE);
+                                               short sel= select_bpoint(bp, selstatus, 1, VISIBLE);
                                                if((sel==1) && (cont==0)) lastsel= 1;
                                        }                       
                                }
@@ -2443,7 +2439,6 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu
        BezTriple *bezt;
        Curve *cu;
        int a;
-       short sel;
 
        if(obedit==NULL) return;
 
@@ -2451,7 +2446,6 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu
        cu->lastsel= NULL;
 
        for(nu= editnurb->first; nu; nu= nu->next) {
-               sel= 0;
                if(nu->type == CU_BEZIER) {
                        a= nu->pntsu;
                        
@@ -2464,6 +2458,7 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu
                        }
                        
                        while(a--) {
+                               short sel;
                                if(doswap) sel= swap_selection_beztriple(bezt);
                                else sel= select_beztriple(bezt, selstatus, 1, VISIBLE);
                                
@@ -2483,6 +2478,7 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu
 
                        while(a--) {
                                if (bp->hide == 0) {
+                                       short sel;
                                        if(doswap) sel= swap_selection_bpoint(bp);
                                        else sel= select_bpoint(bp, selstatus, 1, VISIBLE);
                                        
@@ -2816,12 +2812,7 @@ void CURVE_OT_select_inverse(wmOperatorType *ot)
 /** Divide the line segments associated with the currently selected
  * curve nodes (Bezier or NURB). If there are no valid segment
  * selections within the current selection, nothing happens.
- *
- * @deffunc subdividenurb subdivideNurb(void)
- * @return Nothing
- * @param  None
-*/
-
+ */
 static void subdividenurb(Object *obedit, int number_cuts)
 {
        Curve *cu= obedit->data;
@@ -2899,14 +2890,14 @@ static void subdividenurb(Object *obedit, int number_cuts)
                                                        interp_v3_v3v3(vec+12, vec+3, vec+6, factor);
 
                                                        /* change handle of prev beztn */
-                                                       VECCOPY((beztn-1)->vec[2], vec);
+                                                       copy_v3_v3((beztn-1)->vec[2], vec);
                                                        /* new point */
-                                                       VECCOPY(beztn->vec[0], vec+9);
+                                                       copy_v3_v3(beztn->vec[0], vec+9);
                                                        interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor);
-                                                       VECCOPY(beztn->vec[2], vec+12);
+                                                       copy_v3_v3(beztn->vec[2], vec+12);
                                                        /* handle of next bezt */
-                                                       if(a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {VECCOPY(beztnew->vec[0], vec+6);}
-                                                       else {VECCOPY(bezt->vec[0], vec+6);}
+                                                       if(a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);}
+                                                       else {copy_v3_v3(bezt->vec[0], vec+6);}
 
                                                        beztn->radius = (prevbezt->radius + bezt->radius)/2;
                                                        beztn->weight = (prevbezt->weight + bezt->weight)/2;
@@ -3390,7 +3381,7 @@ static int convertspline(short type, Nurb *nu)
                        a= nr;
                        bp= nu->bp;
                        while(a--) {
-                               VECCOPY(bezt->vec[1], bp->vec);
+                               copy_v3_v3(bezt->vec[1], bp->vec);
                                bezt->f1=bezt->f2=bezt->f3= bp->f1;
                                bezt->h1= bezt->h2= HD_VECT;
                                bezt->weight= bp->weight;
@@ -3427,7 +3418,7 @@ static int convertspline(short type, Nurb *nu)
                        while(a--) {
                                if(type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) {
                                        /* vector handle becomes 1 poly vertice */
-                                       VECCOPY(bp->vec, bezt->vec[1]);
+                                       copy_v3_v3(bp->vec, bezt->vec[1]);
                                        bp->vec[3]= 1.0;
                                        bp->f1= bezt->f2;
                                        nr-= 2;
@@ -3437,7 +3428,7 @@ static int convertspline(short type, Nurb *nu)
                                }
                                else {
                                        for(c=0;c<3;c++) {
-                                               VECCOPY(bp->vec, bezt->vec[c]);
+                                               copy_v3_v3(bp->vec, bezt->vec[c]);
                                                bp->vec[3]= 1.0;
                                                if(c==0) bp->f1= bezt->f1;
                                                else if(c==1) bp->f1= bezt->f2;
@@ -3484,13 +3475,13 @@ static int convertspline(short type, Nurb *nu)
                                a= nr;
                                bp= nu->bp;
                                while(a--) {
-                                       VECCOPY(bezt->vec[0], bp->vec);
+                                       copy_v3_v3(bezt->vec[0], bp->vec);
                                        bezt->f1= bp->f1;
                                        bp++;
-                                       VECCOPY(bezt->vec[1], bp->vec);
+                                       copy_v3_v3(bezt->vec[1], bp->vec);
                                        bezt->f2= bp->f1;
                                        bp++;
-                                       VECCOPY(bezt->vec[2], bp->vec);
+                                       copy_v3_v3(bezt->vec[2], bp->vec);
                                        bezt->f3= bp->f1;
                                        bezt->radius= bp->radius;
                                        bezt->weight= bp->weight;
@@ -4481,7 +4472,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
                                (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb");
                        ED_curve_beztcpy(editnurb, newbezt, nu->bezt, nu->pntsu);
                        *(newbezt+nu->pntsu)= *bezt;
-                       VECCOPY(temp, bezt->vec[1]);
+                       copy_v3_v3(temp, bezt->vec[1]);
                        MEM_freeN(nu->bezt);
                        nu->bezt= newbezt;
                        newbezt+= nu->pntsu;
@@ -4500,7 +4491,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
                        BEZ_SEL(newbezt);
                        cu->lastsel= newbezt;
                        newbezt->h2= newbezt->h1;
-                       VECCOPY(temp, bezt->vec[1]);
+                       copy_v3_v3(temp, bezt->vec[1]);
                        MEM_freeN(nu->bezt);
                        nu->bezt= newbezt;
                        bezt= newbezt+1;
@@ -4512,7 +4503,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3])
                        *newbezt= *bezt;
                        BEZ_SEL(newbezt);
                        newbezt->h2= newbezt->h1;
-                       VECCOPY(temp, bezt->vec[1]);
+                       copy_v3_v3(temp, bezt->vec[1]);
 
                        newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu");
                        memcpy(newnu, nu, sizeof(Nurb));
@@ -4645,7 +4636,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        RegionView3D *rv3d= CTX_wm_region_view3d(C);
 
-       if(rv3d && !RNA_property_is_set(op->ptr, "location")) {
+       if(rv3d && !RNA_struct_property_is_set(op->ptr, "location")) {
                Curve *cu;
                ViewContext vc;
                float location[3];
@@ -4725,18 +4716,6 @@ static int extrude_exec(bContext *C, wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
-static int extrude_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
-{
-       if(extrude_exec(C, op) == OPERATOR_FINISHED) {
-               RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION);
-               WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
-
-               return OPERATOR_FINISHED;
-       }
-
-       return OPERATOR_CANCELLED;
-}
-
 void CURVE_OT_extrude(wmOperatorType *ot)
 {
        /* identifiers */
@@ -4746,7 +4725,6 @@ void CURVE_OT_extrude(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= extrude_exec;
-       ot->invoke= extrude_invoke;
        ot->poll= ED_operator_editsurfcurve;
 
        /* flags */
@@ -5477,6 +5455,24 @@ static int point_on_nurb(Nurb *nu, void *point)
        }
 }
 
+static Nurb *get_lastsel_nurb(Curve *cu)
+{
+       ListBase *nubase= curve_editnurbs(cu);
+       Nurb *nu= nubase->first;
+
+       if(!cu->lastsel)
+               return NULL;
+
+       while (nu) {
+               if (point_on_nurb(nu, cu->lastsel))
+                       return nu;
+
+               nu= nu->next;
+       }
+
+       return NULL;
+}
+
 static void select_nth_bezt(Nurb *nu, BezTriple *bezt, int nth)
 {
        int a, start;
@@ -5526,21 +5522,11 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth)
 int CU_select_nth(Object *obedit, int nth)
 {
        Curve *cu= (Curve*)obedit->data;
-       ListBase *nubase= curve_editnurbs(cu);
        Nurb *nu;
-       int ok=0;
-
-       /* Search nurb to which selected point belongs to */
-       nu= nubase->first;
-       while (nu) {
-               if (point_on_nurb(nu, cu->lastsel)) {
-                       ok= 1;
-                       break;
-               }
-               nu= nu->next;
-       }
 
-       if (!ok) return 0;
+       nu= get_lastsel_nurb(cu);
+       if (!nu)
+               return 0;
 
        if (nu->bezt) {
                select_nth_bezt(nu, cu->lastsel, nth);
@@ -5600,16 +5586,6 @@ static int duplicate_exec(bContext *C, wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
-static int duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
-{
-       duplicate_exec(C, op);
-
-       RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION);
-       WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
-
-       return OPERATOR_FINISHED;
-}
-
 void CURVE_OT_duplicate(wmOperatorType *ot)
 {
        /* identifiers */
@@ -5619,14 +5595,10 @@ void CURVE_OT_duplicate(wmOperatorType *ot)
        
        /* api callbacks */
        ot->exec= duplicate_exec;
-       ot->invoke= duplicate_invoke;
        ot->poll= ED_operator_editsurfcurve;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
-       /* to give to transform */
-       RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
 }
 
 /********************** delete operator *********************/
@@ -5779,6 +5751,7 @@ static int delete_exec(bContext *C, wmOperator *op)
                                                clamp_nurb_order_u(nu);
                                        }*/
                                }
+                               clamp_nurb_order_u(nu);
                                nurbs_knot_calc_u(nu);
                        }
                        nu= next;
@@ -5927,7 +5900,14 @@ static int delete_exec(bContext *C, wmOperator *op)
                                        MEM_freeN(nu1->bp);
                                        nu1->bp= bp;
                                        nu1->pntsu= a;
+                                       nu1->knotsu= NULL;
                                        nu->pntsu= cut+1;
+
+                                       clamp_nurb_order_u(nu);
+                                       nurbs_knot_calc_u(nu);
+
+                                       clamp_nurb_order_u(nu1);
+                                       nurbs_knot_calc_u(nu1);
                                }
                        }
                }
@@ -6076,7 +6056,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
                        
                                if(cu->nurb.first) {
                                        /* watch it: switch order here really goes wrong */
-                                       mul_m4_m4m4(cmat, base->object->obmat, imat);
+                                       mult_m4_m4m4(cmat, imat, base->object->obmat);
                                        
                                        nu= cu->nurb.first;
                                        while(nu) {
@@ -6190,7 +6170,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
 
        if(rv3d) {
                copy_m4_m4(viewmat, rv3d->viewmat);
-               VECCOPY(zvec, rv3d->viewinv[2]);
+               copy_v3_v3(zvec, rv3d->viewinv[2]);
        }
 
        setflagsNurb(editnurb, 0);
@@ -6531,8 +6511,8 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
        return nu;
 }
 
-static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) {
-       
+static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
+{
        Object *obedit= CTX_data_edit_object(C);
        ListBase *editnurb;
        Nurb *nu;
@@ -6601,11 +6581,13 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
        return OPERATOR_FINISHED;
 }
 
-static int curve_prim_add(bContext *C, wmOperator *op, int type) {
+static int curve_prim_add(bContext *C, wmOperator *op, int type)
+{
        return curvesurf_prim_add(C, op, type, 0);
 }
 
-static int surf_prim_add(bContext *C, wmOperator *op, int type) {
+static int surf_prim_add(bContext *C, wmOperator *op, int type)
+{
        return curvesurf_prim_add(C, op, type, 1);
 }
 
@@ -7069,3 +7051,24 @@ void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count)
        memcpy(dst, src, count*sizeof(BPoint));
        keyIndex_updateBP(editnurb, src, dst, count);
 }
+
+int ED_curve_actSelection(Curve *cu, float center[3])
+{
+       Nurb *nu= get_lastsel_nurb(cu);
+
+       if(!nu)
+               return 0;
+
+       if(nu->bezt) {
+               BezTriple *bezt= cu->lastsel;
+
+               copy_v3_v3(center, bezt->vec[1]);
+       }
+       else {
+               BPoint *bp= cu->lastsel;
+
+               copy_v3_v3(center, bp->vec);
+       }
+
+       return 1;
+}