Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2017-10-17 19:39:10 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2017-10-17 19:39:10 +0300
commit1cb884be35e160740e97065afd6548e6a052c9d8 (patch)
treebc93243f86ec4f28f65c32619538e1e5857e0b6b /source/blender/editors
parent7d3723a54d8a809d5c95b235e90a12e2f6295f0e (diff)
Make auto handle placement aware of cyclic extrapolation.
Cyclic extrapolation is implemented as an f-curve modifier, so this technically violates abstraction separation and is something of a hack. However without such behavior achieving smooth looping with cyclic extrapolation is extremely cumbersome. The new behavior is applied when the first modifier is Cyclic extrapolation in Repeat or Repeat with Offset mode without using influence, repeat count or range restrictions. This change in behavior means that curve handles have to be updated when the modifier is added, removed or its options change. Due to the way code is structured, it seems it requires a helper link to the containing curve from the modifier object. Reviewers: aligorith Differential Revision: https://developer.blender.org/D2783
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/drivers.c2
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c10
-rw-r--r--source/blender/editors/include/ED_anim_api.h2
-rw-r--r--source/blender/editors/object/object_constraint.c2
-rw-r--r--source/blender/editors/object/object_relations.c2
-rw-r--r--source/blender/editors/space_action/action_edit.c2
-rw-r--r--source/blender/editors/space_graph/graph_edit.c6
-rw-r--r--source/blender/editors/space_nla/nla_edit.c4
8 files changed, 19 insertions, 11 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 52b93edae15..0d329898c41 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -123,7 +123,7 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
* Create FModifier so that old scripts won't break
* for now before 2.7 series -- (September 4, 2013)
*/
- add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
+ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu);
}
else {
/* add 2 keyframes so that user has something to work with
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 6bb73416fec..8d77460e197 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -736,7 +736,7 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
/* 'Paste' the F-Modifier(s) from the buffer to the specified list
* - replace: free all the existing modifiers to leave only the pasted ones
*/
-bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace)
+bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *curve)
{
FModifier *fcm;
bool ok = false;
@@ -745,6 +745,8 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace)
if (modifiers == NULL)
return 0;
+ bool was_cyclic = curve && BKE_fcurve_is_cyclic(curve);
+
/* if replacing the list, free the existing modifiers */
if (replace)
free_fmodifiers(modifiers);
@@ -753,6 +755,8 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace)
for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) {
/* make a copy of it */
FModifier *fcmN = copy_fmodifier(fcm);
+
+ fcmN->curve = curve;
/* make sure the new one isn't active, otherwise the list may get several actives */
fcmN->flag &= ~FMODIFIER_FLAG_ACTIVE;
@@ -762,6 +766,10 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace)
ok = 1;
}
+ /* adding or removing the Cycles modifier requires an update to handles */
+ if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic)
+ calchandles_fcurve(curve);
+
/* did we succeed? */
return ok;
}
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 68a5dd8a94e..ab02fd1ccc8 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -572,7 +572,7 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active);
/* 'Paste' the F-Modifier(s) from the buffer to the specified list
* - replace: free all the existing modifiers to leave only the pasted ones
*/
-bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace);
+bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, struct FCurve *curve);
/* ************************************************* */
/* ASSORTED TOOLS */
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 59d78f13ccb..f348806c6f1 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1025,7 +1025,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
* and define basic slope of this curve based on the properties
*/
if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) {
- FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
+ FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu);
FMod_Generator *gen = fcm->data;
/* Assume that we have the following equation:
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index d5b516257a1..91fdfcacf6c 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -637,7 +637,7 @@ bool ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working */
if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first)
- add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
+ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu);
}
/* fall back on regular parenting now (for follow only) */
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index a9920389980..2df5aa29e9a 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1146,7 +1146,7 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
/* only add if one doesn't exist */
if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) {
/* TODO: add some more preset versions which set different extrapolation options? */
- add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES);
+ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, fcu);
}
}
else if (mode == CLEAR_CYCLIC_EXPO) {
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 861a38da2c7..4f737ef164b 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1504,7 +1504,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
/* only add if one doesn't exist */
if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) {
// TODO: add some more preset versions which set different extrapolation options?
- add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES);
+ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, fcu);
}
}
else if (mode == CLEAR_CYCLIC_EXPO) {
@@ -2446,7 +2446,7 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
FModifier *fcm;
/* add F-Modifier of specified type to active F-Curve, and make it the active one */
- fcm = add_fmodifier(&fcu->modifiers, type);
+ fcm = add_fmodifier(&fcu->modifiers, type, fcu);
if (fcm) {
set_active_fmodifier(&fcu->modifiers, fcm);
}
@@ -2582,7 +2582,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
FCurve *fcu = (FCurve *)ale->data;
int tot;
- tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, replace);
+ tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, replace, fcu);
if (tot) {
ale->update |= ANIM_UPDATE_DEPS;
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index f7f7c82171d..a6f76e1d556 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -2316,7 +2316,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
continue;
/* add F-Modifier of specified type to selected, and make it the active one */
- fcm = add_fmodifier(&strip->modifiers, type);
+ fcm = add_fmodifier(&strip->modifiers, type, NULL);
if (fcm) {
set_active_fmodifier(&strip->modifiers, fcm);
@@ -2470,7 +2470,7 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
}
/* paste FModifiers from buffer */
- ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace);
+ ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace, NULL);
ale->update |= ANIM_UPDATE_DEPS;
}
}