diff options
author | Joshua Leung <aligorith@gmail.com> | 2013-11-05 04:19:21 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2013-11-05 04:19:21 +0400 |
commit | 737239c4c4f1b422c741d53b19bf21939d7382c3 (patch) | |
tree | ee3ee951848c89f299a4913a48fedc098308ea16 | |
parent | 26dc289d99a09406b38d87d8963db05328da711c (diff) |
Bugfix [#36844] Cannot set Restrict Frame Start for FModifiers until Frame End
has been adjusted
Previously, the RNA settings tried to strictly enforce the constraint that the
start frame must be less than the end frame. However, this behaviour was
problematic, as it meant that you had to firstly move the end frame to its new
(higher) value, before moving the start frame. The same also applied in the
opposite direction.
Now, this behaves in the same way that the scene start/end buttons work: if the
new start frame is past the end frame, the end frame is "pushed" along to be the
same value as the start frame. The same applies in the opposite direction.
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 4b50127d999..3d236b1d1bd 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -453,28 +453,66 @@ static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, Pointe static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value)) { - FModifier *fm = (FModifier *)ptr->data; + FModifier *fcm = (FModifier *)ptr->data; /* don't toggle, always switch on */ - fm->flag |= FMODIFIER_FLAG_ACTIVE; + fcm->flag |= FMODIFIER_FLAG_ACTIVE; +} + +static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value) +{ + FModifier *fcm = (FModifier *)ptr->data; + + CLAMP(value, MINAFRAME, MAXFRAME); + fcm->sfra = value; + + /* XXX: maintain old offset? */ + if (fcm->sfra >= fcm->efra) { + fcm->efra = fcm->sfra; + } +} + +static void rna_FModifer_end_frame_set(PointerRNA *ptr, float value) +{ + FModifier *fcm = (FModifier *)ptr->data; + + CLAMP(value, MINAFRAME, MAXFRAME); + fcm->efra = value; + + /* XXX: maintain old offset? */ + if (fcm->efra <= fcm->sfra) { + fcm->sfra = fcm->efra; + } } static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) + float *softmin, float *softmax) { FModifier *fcm = (FModifier *)ptr->data; - *min = MINAFRAMEF; - *max = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->efra : MAXFRAMEF; + /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that, + * or else it becomes tricky to adjust the range... [#36844] + */ + *min = MINAFRAMEF; + *softmin = MINAFRAMEF; + + *softmax = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->efra : MAXFRAMEF; + *max = MAXFRAMEF; } static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float *max, - float *UNUSED(softmin), float *UNUSED(softmax)) + float *softmin, float *softmax) { FModifier *fcm = (FModifier *)ptr->data; - - *min = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF; - *max = MAXFRAMEF; + + /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that, + * or else it becomes tricky to adjust the range... [#36844] + */ + *min = MINAFRAMEF; + *softmin = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF; + + *softmax = MAXFRAMEF; + *max = MAXFRAMEF; } static void rna_FModifier_blending_range(PointerRNA *ptr, float *min, float *max, @@ -1191,14 +1229,14 @@ static void rna_def_fmodifier(BlenderRNA *brna) prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sfra"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_start_frame_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifier_start_frame_set", "rna_FModifier_start_frame_range"); RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if Restrict Frame Range is in use)"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "efra"); - RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_end_frame_range"); + RNA_def_property_float_funcs(prop, NULL, "rna_FModifer_end_frame_set", "rna_FModifier_end_frame_range"); RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if Restrict Frame Range is in use)"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); |