From de662e7cd3b3ca45c4220e3830c32e2b3496c9fe Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Mon, 12 Nov 2018 19:41:53 +0300 Subject: NLA: insert keyframes correctly for strips with non-Replace mode. NLA strips support using the keyframe values in a variety of ways: adding, subtracting, multiplying, linearly mixing with the result of strips located below in the stack. This is intended for layering tweaks on top of a base animation. However, when inserting keyframes into such strips, it simply inserts the final value of the property, irrespective of these settings. This in fact makes the feature nearly useless. To fix this it is necessary to evaluate the NLA stack below the edited strip and correctly compute the raw key that would produce the intended final value, according to the mode and influence. Differential Revision: https://developer.blender.org/D3927 --- source/blender/editors/space_graph/graph_edit.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_graph') diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index e610aee4810..00418d6482a 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -54,6 +54,7 @@ #include "BLT_translation.h" +#include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_fcurve.h" #include "BKE_global.h" @@ -521,6 +522,7 @@ static const EnumPropertyItem prop_graphkeys_insertkey_types[] = { static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) { ListBase anim_data = {NULL, NULL}; + ListBase nla_cache = {NULL, NULL}; bAnimListElem *ale; int filter; size_t num_items; @@ -602,7 +604,7 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) */ if (ale->id && !ale->owner && !fcu->driver) { insert_keyframe(ac->bmain, depsgraph, reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), - fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, flag); + fcu->rna_path, fcu->array_index, cfra, ts->keyframe_type, &nla_cache, flag); } else { AnimData *adt = ANIM_nla_mapping_get(ac, ale); @@ -621,6 +623,8 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) } } + BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); } -- cgit v1.2.3