[Bf-blender-cvs] [65199828766] master: Fix T64681: evaluate curves with generative modifiers and no keys.

Alexander Gavrilov noreply at git.blender.org
Thu May 16 08:50:55 CEST 2019


Commit: 65199828766afff21b1a1741fd5a7d651d92f17d
Author: Alexander Gavrilov
Date:   Thu May 16 09:47:57 2019 +0300
Branches: master
https://developer.blender.org/rB65199828766afff21b1a1741fd5a7d651d92f17d

Fix T64681: evaluate curves with generative modifiers and no keys.

Introduce a new function and use it everywhere, including
automatic curve deletion checks to guarantee consistency.

===================================================================

M	source/blender/blenkernel/BKE_fcurve.h
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/editors/animation/keyframes_general.c
M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/interface/interface_anim.c
M	source/blender/editors/space_action/action_edit.c
M	source/blender/editors/space_graph/graph_edit.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index c1232addee3..4c1a115eb23 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -340,6 +340,7 @@ float evaluate_fcurve_driver(struct PathResolvedRNA *anim_rna,
                              struct FCurve *fcu,
                              struct ChannelDriver *driver_orig,
                              float evaltime);
+bool BKE_fcurve_is_empty(struct FCurve *fcu);
 /* evaluate fcurve and store value */
 float calculate_fcurve(struct PathResolvedRNA *anim_rna, struct FCurve *fcu, float evaltime);
 
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 663eb4027f6..ab7e59a059b 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1894,7 +1894,7 @@ static void animsys_evaluate_fcurves(Depsgraph *depsgraph,
       continue;
     }
     /* Skip empty curves, as if muted. */
-    if (fcu->totvert == 0) {
+    if (BKE_fcurve_is_empty(fcu)) {
       continue;
     }
     PathResolvedRNA anim_rna;
@@ -2009,7 +2009,7 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup *
   /* calculate then execute each curve */
   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 && fcu->totvert != 0) {
+    if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0 && !BKE_fcurve_is_empty(fcu)) {
       PathResolvedRNA anim_rna;
       if (animsys_store_rna_setting(ptr, fcu->rna_path, fcu->array_index, &anim_rna)) {
         const float curval = calculate_fcurve(&anim_rna, fcu, ctime);
@@ -3105,7 +3105,7 @@ static void nlastrip_evaluate_actionclip(PointerRNA *ptr,
     if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) {
       continue;
     }
-    if (fcu->totvert == 0) {
+    if (BKE_fcurve_is_empty(fcu)) {
       continue;
     }
 
@@ -3334,7 +3334,7 @@ static void nla_eval_domain_action(PointerRNA *ptr,
     if ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) {
       continue;
     }
-    if (fcu->totvert == 0) {
+    if (BKE_fcurve_is_empty(fcu)) {
       continue;
     }
 
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index e2d0a479792..3bca77c5b51 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -3070,14 +3070,20 @@ float evaluate_fcurve_driver(PathResolvedRNA *anim_rna,
   return evaluate_fcurve_ex(fcu, evaltime, cvalue);
 }
 
+/* Checks if the curve has valid keys, drivers or modifiers that produce an actual curve. */
+bool BKE_fcurve_is_empty(FCurve *fcu)
+{
+  return (fcu->totvert == 0) && (fcu->driver == NULL) &&
+         !list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE);
+}
+
 /* Calculate the value of the given F-Curve at the given frame, and set its curval */
 float calculate_fcurve(PathResolvedRNA *anim_rna, FCurve *fcu, float evaltime)
 {
   /* only calculate + set curval (overriding the existing value) if curve has
    * any data which warrants this...
    */
-  if ((fcu->totvert) || (fcu->driver && !(fcu->driver->flag & DRIVER_FLAG_INVALID)) ||
-      list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE)) {
+  if (!BKE_fcurve_is_empty(fcu)) {
     /* calculate and set curval (evaluates driver too if necessary) */
     float curval;
     if (fcu->driver) {
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 5214c5f78fa..be8de66a262 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -315,8 +315,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
       clear_fcurve_keys(fcu);
 
       /* check if curve is really unused and if it is, return signal for deletion */
-      if ((list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0) &&
-          (fcu->driver == NULL)) {
+      if (BKE_fcurve_is_empty(fcu)) {
         AnimData *adt = ale->adt;
         ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
         ale->key_data = NULL;
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 97d85d25d66..2dc17c5c397 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1557,8 +1557,7 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
     delete_fcurve_key(fcu, i, 1);
 
     /* Only delete curve too if it won't be doing anything anymore */
-    if ((fcu->totvert == 0) &&
-        (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) {
+    if (BKE_fcurve_is_empty(fcu)) {
       ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
     }
 
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index e34d67b6996..4a0a19f57cf 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -83,7 +83,7 @@ void ui_but_anim_flag(uiBut *but, float cfra)
   if (fcu) {
     if (!driven) {
       /* Empty curves are ignored by the animation evaluation system. */
-      if (fcu->totvert == 0) {
+      if (BKE_fcurve_is_empty(fcu)) {
         return;
       }
 
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index d8ed25c86d3..7fc84db3f75 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -979,8 +979,7 @@ static bool delete_action_keys(bAnimContext *ac)
       changed = delete_fcurve_keys(fcu);
 
       /* Only delete curve too if it won't be doing anything anymore */
-      if ((fcu->totvert == 0) &&
-          (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) {
+      if (BKE_fcurve_is_empty(fcu)) {
         ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
         ale->key_data = NULL;
       }
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index c5f8c32ec7a..8329218eea9 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1172,9 +1172,7 @@ static bool delete_graph_keys(bAnimContext *ac)
     }
 
     /* Only delete curve too if it won't be doing anything anymore */
-    if ((fcu->totvert == 0) &&
-        (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0) &&
-        (fcu->driver == NULL)) {
+    if (BKE_fcurve_is_empty(fcu)) {
       ANIM_fcurve_delete_from_animdata(ac, adt, fcu);
       ale->key_data = NULL;
     }



More information about the Bf-blender-cvs mailing list