Commit: 3e26a7a594a9f2d91cba48ba70d30e3ca38a5505
Author: Joshua Leung
Date:   Wed Mar 5 19:38:14 2014 +1300
https://developer.blender.org/rB3e26a7a594a9f2d91cba48ba70d30e3ca38a5505

Fix T38774: Changing extrapolation type via RNA doesn't update FCurve

- Added update callback to perform on-update validation when changing the
  extrapolation mode on F-Curves
- There was a patch in the tracker for adding an "update()" method to F-Curves
  which does a similar thing when manually called by scripts. Since we've added
  a function for this in RNA anyways, we might as well add this too while we're
  at it. (NOTE: upon closer inspection, the original patch by Tom Edwards had a
  number of issues, so I ended up reimplementing here)

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

M       source/blender/makesrna/intern/rna_fcurve.c

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

diff --git a/source/blender/makesrna/intern/rna_fcurve.c 
b/source/blender/makesrna/intern/rna_fcurve.c
index 4e19392..b4438f5 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -429,6 +429,21 @@ static void rna_FCurve_range(FCurve *fcu, float range[2])
 }
 
 
+/* allow scripts to update curve after editing manually */
+static void rna_FCurve_update_data_ex(FCurve *fcu)
+{
+       sort_time_fcurve(fcu);
+       testhandles_fcurve(fcu, TRUE);
+}
+
+/* RNA update callback for F-Curves after curve shape changes */
+static void rna_FCurve_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), 
PointerRNA *ptr)
+{
+       BLI_assert(ptr->type == &RNA_FCurve);
+       rna_FCurve_update_data_ex((FCurve *)ptr->data);
+}
+
+
 static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
 {
        FCurve *fcu = (FCurve *)ptr->data;
@@ -1768,7 +1783,7 @@ static void rna_def_fcurve(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "extend");
        RNA_def_property_enum_items(prop, prop_mode_extend_items);
        RNA_def_property_ui_text(prop, "Extrapolation", "");
-       RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, 
NULL);
+       RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, 
"rna_FCurve_update_data");
 
        /* Pointers */
        prop = RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
@@ -1863,9 +1878,13 @@ static void rna_def_fcurve(BlenderRNA *brna)
                             "Evaluate F-Curve at given frame", -FLT_MAX, 
FLT_MAX);
        RNA_def_property_flag(parm, PROP_REQUIRED);
        /* return value */
-       parm = RNA_def_float(func, "position", 0, -FLT_MAX, FLT_MAX, 
"Position", "F-Curve position", -FLT_MAX, FLT_MAX);
+       parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "Value", 
"Value of F-Curve specific frame", -FLT_MAX, FLT_MAX);
        RNA_def_function_return(func, parm);
        
+       /* -- update / recalculate -- */
+       func = RNA_def_function(srna, "update", "rna_FCurve_update_data_ex");
+       RNA_def_function_ui_description(func, "Ensure keyframes are sorted in 
chronological order and handles are set correctly");
+       
        /* -- time extents/range -- */
        func = RNA_def_function(srna, "range", "rna_FCurve_range");
        RNA_def_function_ui_description(func, "Get the time extents for 
F-Curve");

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

Reply via email to