[Bf-blender-cvs] [fdfcbfd0404] master: Fix T52009: F-Curve "Stepped interpolation" modifier "restrict frame-range" IN and OUT parameters cannot be edited

Joshua Leung noreply at git.blender.org
Tue Jul 11 13:35:47 CEST 2017


Commit: fdfcbfd0404183b78623bd7a65f2701ea23ed463
Author: Joshua Leung
Date:   Tue Jul 11 18:07:11 2017 +1200
Branches: master
https://developer.blender.org/rBfdfcbfd0404183b78623bd7a65f2701ea23ed463

Fix T52009: F-Curve "Stepped interpolation" modifier "restrict frame-range" IN and OUT parameters cannot be edited

The problem here was that the "frame_start" and "frame_end" RNA properties of
the Stepped FModifier were shadowing/overriding "frame_start" and "frame_end"
properties of the base FModifier. As a result, when the range() callback
for the In/Out parameters (defined as part of the base FModifier) checked
it's start/end properties, they were always still zero, meaning that the
acceptable range for the In/Out parameters was 0 -> 0 = 0.

Note:
If you've got old files with this problem, you'll need to manually click on
the frame_start/end properties to flush out the old values. It's probably
not worth the effort of applying a version patch for this (given that this
modifier is not one of the most often used ones AFAIK).

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

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 bccc47aa95d..648c6032520 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -581,6 +581,7 @@ static void rna_FModifier_blending_range(PointerRNA *ptr, float *min, float *max
 
 	*min = 0.0f;
 	*max = fcm->efra - fcm->sfra;
+	printf("blending range: %f -> %f (%f, %f)\n", *min, *max, fcm->sfra, fcm->efra);
 }
 
 static void rna_FModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -765,6 +766,38 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
 	*max = MAXFRAMEF;
 }
 
+static void rna_FModifierStepped_frame_start_set(PointerRNA *ptr, float value)
+{
+	FModifier *fcm = (FModifier *)ptr->data;
+	FMod_Stepped *data = fcm->data;
+	
+	float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
+	rna_FModifierStepped_start_frame_range(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
+	value = CLAMPIS(value, prop_clamp_min, prop_clamp_max);
+	
+	/* Need to set both step-data's start/end and the start/end on the base-data, 
+	 * or else Restrict-Range doesn't work due to RNA-property shadowing (T52009)
+	 */
+	data->start_frame = value;
+	fcm->sfra = value;
+}
+
+static void rna_FModifierStepped_frame_end_set(PointerRNA *ptr, float value)
+{
+	FModifier *fcm = (FModifier *)ptr->data;
+	FMod_Stepped *data = fcm->data;
+	
+	float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
+	rna_FModifierStepped_end_frame_range(ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
+	value = CLAMPIS(value, prop_clamp_min, prop_clamp_max);
+	
+	/* Need to set both step-data's start/end and the start/end on the base-data, 
+	 * or else Restrict-Range doesn't work due to RNA-property shadowing (T52009)
+	 */
+	data->end_frame = value;
+	fcm->efra = value;
+}
+
 static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int keyframe_type, int flag)
 {
 	int index = insert_vert_fcurve(fcu, frame, value, (char)keyframe_type, flag | INSERTKEY_NO_USERPREF);
@@ -1284,13 +1317,13 @@ static void rna_def_fmodifier_stepped(BlenderRNA *brna)
 	
 	prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "start_frame");
-	RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_start_frame_range");
+	RNA_def_property_float_funcs(prop, NULL, "rna_FModifierStepped_frame_start_set", "rna_FModifierStepped_start_frame_range");
 	RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
 	RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
 	
 	prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "end_frame");
-	RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_end_frame_range");
+	RNA_def_property_float_funcs(prop, NULL, "rna_FModifierStepped_frame_end_set", "rna_FModifierStepped_end_frame_range");
 	RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
 	RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
 }




More information about the Bf-blender-cvs mailing list