Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / anim_sys.c
index 9afee556c96d2ca480bf6e95c3770243c0d51d3c..7e01b88fc3b714aa7b285aa72a3c563c11e3c0e8 100644 (file)
@@ -729,14 +729,10 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o
                        DynStr *ds = BLI_dynstr_new();
                        const char *postfixPtr = oldNamePtr + oldNameLen;
                        char *newPath = NULL;
-                       char oldChar;
-                       
+
                        /* add the part of the string that goes up to the start of the prefix */
                        if (prefixPtr > oldpath) {
-                               oldChar = prefixPtr[0];
-                               prefixPtr[0] = 0;
-                               BLI_dynstr_append(ds, oldpath);
-                               prefixPtr[0] = oldChar;
+                               BLI_dynstr_nappend(ds, oldpath, prefixPtr - oldpath);
                        }
                        
                        /* add the prefix */
@@ -1613,7 +1609,7 @@ static bool animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_ind
 }
 
 /* Simple replacement based data-setting of the FCurve using RNA */
-bool BKE_animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
+bool BKE_animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu, float curval)
 {
        char *path = NULL;
        bool free_path = false;
@@ -1624,7 +1620,7 @@ bool BKE_animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu)
        
        /* write value to setting */
        if (path)
-               ok = animsys_write_rna_setting(ptr, path, fcu->array_index, fcu->curval);
+               ok = animsys_write_rna_setting(ptr, path, fcu->array_index, curval);
        
        /* free temp path-info */
        if (free_path)
@@ -1647,8 +1643,8 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr, ListBase *list, AnimMapper
                if ((fcu->grp == NULL) || (fcu->grp->flag & AGRP_MUTED) == 0) {
                        /* check if this curve should be skipped */
                        if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
-                               calculate_fcurve(fcu, ctime);
-                               BKE_animsys_execute_fcurve(ptr, remap, fcu); 
+                               const float curval = calculate_fcurve(fcu, ctime);
+                               BKE_animsys_execute_fcurve(ptr, remap, fcu, curval);
                        }
                }
        }
@@ -1677,8 +1673,8 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime
                                /* evaluate this using values set already in other places
                                 * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
                                 *       new to only be done when drivers only changed */
-                               calculate_fcurve(fcu, ctime);
-                               ok = BKE_animsys_execute_fcurve(ptr, NULL, fcu);
+                               const float curval = calculate_fcurve(fcu, ctime);
+                               ok = BKE_animsys_execute_fcurve(ptr, NULL, fcu, curval);
                                
                                /* clear recalc flag */
                                driver->flag &= ~DRIVER_FLAG_RECALC;
@@ -1746,8 +1742,8 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
        for (fcu = agrp->channels.first; (fcu) && (fcu->grp == agrp); fcu = fcu->next) {
                /* check if this curve should be skipped */
                if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
-                       calculate_fcurve(fcu, ctime);
-                       BKE_animsys_execute_fcurve(ptr, remap, fcu); 
+                       const float curval = calculate_fcurve(fcu, ctime);
+                       BKE_animsys_execute_fcurve(ptr, remap, fcu, curval);
                }
        }
 }
@@ -2878,8 +2874,8 @@ void BKE_animsys_eval_driver(EvaluationContext *eval_ctx,
                         * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
                         *       new to only be done when drivers only changed */
                        //printf("\told val = %f\n", fcu->curval);
-                       calculate_fcurve(fcu, eval_ctx->ctime);
-                       ok = BKE_animsys_execute_fcurve(&id_ptr, NULL, fcu);
+                       const float curval = calculate_fcurve(fcu, eval_ctx->ctime);
+                       ok = BKE_animsys_execute_fcurve(&id_ptr, NULL, fcu, curval);
                        //printf("\tnew val = %f\n", fcu->curval);
 
                        /* clear recalc flag */