Revision: 34645
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34645
Author:   nazgul
Date:     2011-02-04 21:10:27 +0000 (Fri, 04 Feb 2011)
Log Message:
-----------
- Drivers should now be updated correct when curve changes topology
- Fixed regression with keeping alive f=curves for deleted CVs
  (was a mistake in previous commit in this area)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/curve/editcurve.c

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c      2011-02-04 
16:28:19 UTC (rev 34644)
+++ trunk/blender/source/blender/editors/curve/editcurve.c      2011-02-04 
21:10:27 UTC (rev 34645)
@@ -85,7 +85,7 @@
        ListBase nubase;
        void *lastsel;
        GHash *undoIndex;
-       ListBase fcurves;
+       ListBase fcurves, drivers;
 } UndoCurve;
 
 /* Definitions needed for shape keys */
@@ -1008,7 +1008,7 @@
        Curve *cu= (Curve*)ob->data;
        AnimData *ad= BKE_animdata_from_id(&cu->id);
 
-       return ad && ad->action;
+       return ad && (ad->action || ad->drivers.first);
 }
 
 static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char 
*rna_path, ListBase *orig_curves, ListBase *curves)
@@ -1030,8 +1030,10 @@
                                action_groups_remove_channel(ad->action, fcu);
                                action_groups_add_channel(ad->action, fcu->grp, 
nfcu);
                        }
-                       else if (ad->action)
+                       else if (ad->action && &ad->action->curves == 
orig_curves)
                                BLI_remlink(&ad->action->curves, fcu);
+                       else
+                               BLI_remlink(&ad->drivers, fcu);
 
                        free_fcurve(fcu);
 
@@ -1041,9 +1043,16 @@
        }
 }
 
-/* return 0 if animation data wasn't changed, 1 otherwise */
-int ED_curve_updateAnimPaths(Object *obedit)
+static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu)
 {
+       if(orig_curves==&ad->drivers) BLI_remlink(&ad->drivers, fcu);
+       else action_groups_remove_channel(ad->action, fcu);
+
+       free_fcurve(fcu);
+}
+
+static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
+{
        int nu_index= 0, a, pt_index;
        Curve *cu= (Curve*)obedit->data;
        EditNurb *editnurb= cu->editnurb;
@@ -1051,14 +1060,9 @@
        CVKeyIndex *keyIndex;
        char rna_path[64], orig_rna_path[64];
        AnimData *ad= BKE_animdata_from_id(&cu->id);
-       ListBase *orig_curves= NULL;
        ListBase curves= {0, 0};
        FCurve *fcu, *next;
 
-       if(!curve_is_animated(obedit)) return 0;
-
-       orig_curves= &ad->action->curves;
-
        while(nu) {
                if(nu->bezt) {
                        BezTriple *bezt= nu->bezt;
@@ -1115,6 +1119,21 @@
                nu_index++;
        }
 
+       /* remove pathes for removed control points
+          need this to make further step with copying non-cv related curves 
copying
+          not touching cv's f-cruves */
+       fcu= orig_curves->first;
+       for(fcu= orig_curves->first; fcu; fcu= next) {
+               next= fcu->next;
+
+               if(!strncmp(fcu->rna_path, "splines", 7)) {
+                       char *ch= strchr(fcu->rna_path, '.');
+
+                       if (ch && (!strncmp(ch, ".bezier_points", 14) || 
!strncmp(ch, ".points", 8)))
+                               fcurve_remove(ad, orig_curves, fcu);
+               }
+       }
+
        nu_index= 0;
        nu= editnurb->nurbs.first;
        while(nu) {
@@ -1127,7 +1146,7 @@
                if(keyIndex) {
                        sprintf(rna_path, "splines[%d]", nu_index);
                        sprintf(orig_rna_path, "splines[%d]", 
keyIndex->nu_index);
-                       fcurve_path_rename(ad, orig_rna_path, rna_path, 
&ad->action->curves, &curves);
+                       fcurve_path_rename(ad, orig_rna_path, rna_path, 
orig_curves, &curves);
                }
 
                nu_index++;
@@ -1139,14 +1158,26 @@
        for(fcu= orig_curves->first; fcu; fcu= next) {
                next= fcu->next;
 
-               if(!strncmp(fcu->rna_path, "splines", 7)) {
-                       action_groups_remove_channel(ad->action, fcu);
-                       free_fcurve(fcu);
-               } else BLI_addtail(&curves, fcu);
+               if(!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, 
orig_curves, fcu);
+               else BLI_addtail(&curves, fcu);
        }
-       
-       ad->action->curves= curves;
 
+       *orig_curves= curves;
+}
+
+/* return 0 if animation data wasn't changed, 1 otherwise */
+int ED_curve_updateAnimPaths(Object *obedit)
+{
+       Curve *cu= (Curve*)obedit->data;
+       AnimData *ad= BKE_animdata_from_id(&cu->id);
+
+       if(!curve_is_animated(obedit)) return 0;
+
+       if(ad->action)
+               curve_rename_fcurves(obedit, &ad->action->curves);
+
+       curve_rename_fcurves(obedit, &ad->drivers);
+
        return 1;
 }
 
@@ -1193,7 +1224,6 @@
        EditNurb *editnurb= cu->editnurb;
        Nurb *nu, *newnu, *nu_act= NULL;
        KeyBlock *actkey;
-       int is_anim;
 
        if(obedit==NULL) return;
 
@@ -1201,7 +1231,6 @@
 
        if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
                actkey= ob_get_keyblock(obedit);
-               is_anim= curve_is_animated(obedit);
 
                if(actkey) {
                        // XXX strcpy(G.editModeTitleExtra, "(Key) ");
@@ -1209,10 +1238,6 @@
                        key_to_curve(actkey, cu, &cu->nurb);
                }
 
-               if (is_anim) {
-                       undo_editmode_clear();
-               }
-
                if(editnurb) {
                        freeNurblist(&editnurb->nurbs);
                        free_editNurb_keyIndex(editnurb);
@@ -6882,9 +6907,14 @@
                editnurb->keyindex= dupli_keyIndexHash(undoCurve->undoIndex);
        }
 
-       if(ad && ad->action) {
-               free_fcurves(&ad->action->curves);
-               copy_fcurves(&ad->action->curves, &undoCurve->fcurves);
+       if(ad) {
+               if(ad->action) {
+                       free_fcurves(&ad->action->curves);
+                       copy_fcurves(&ad->action->curves, &undoCurve->fcurves);
+               }
+
+               free_fcurves(&ad->drivers);
+               copy_fcurves(&ad->drivers, &undoCurve->drivers);
        }
 
        /* copy  */
@@ -6925,9 +6955,13 @@
                tmpEditnurb.keyindex= undoCurve->undoIndex;
        }
 
-       if(ad && ad->action)
-               copy_fcurves(&undoCurve->fcurves, &ad->action->curves);
+       if(ad) {
+               if(ad->action)
+                       copy_fcurves(&undoCurve->fcurves, &ad->action->curves);
 
+               copy_fcurves(&undoCurve->drivers, &ad->drivers);
+       }
+
        /* copy  */
        for(nu= nubase->first; nu; nu= nu->next) {
                newnu= duplicateNurb(nu);
@@ -6958,6 +6992,7 @@
                BLI_ghash_free(undoCurve->undoIndex, NULL, 
(GHashValFreeFP)free_cvKeyIndex);
 
        free_fcurves(&undoCurve->fcurves);
+       free_fcurves(&undoCurve->drivers);
 
        MEM_freeN(undoCurve);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to