From f283aa61c5a5f7b0ff9869dc32519806237f8965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Sun, 24 Jul 2016 03:18:40 +0200 Subject: Fix T48397: Can not bake tweaked NLA We need to leave tweak mode before trying to modifiy the action as doing so will leave Blender in a semi-corrupted state. Reviewers: #animation Reviewed by: aligorith Maniphest Tasks: T48397 Differential Revision: https://developer.blender.org/D2119 --- source/blender/makesrna/intern/rna_animation.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/blender/makesrna/intern/rna_animation.c') diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index c3d1070b8c2..7a1954036e3 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -116,6 +116,23 @@ static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value) } } +static void rna_AnimData_tweakmode_set(PointerRNA *ptr, const int value) +{ + AnimData *adt = (AnimData *)ptr->data; + + /* NOTE: technically we should also set/unset SCE_NLA_EDIT_ON flag on the + * scene which is used to make polling tests faster, but this flag is weak + * and can easily break e.g. by changing layer visibility. This needs to be + * dealt with at some point. */ + + if (value) { + BKE_nla_tweakmode_enter(adt); + } + else { + BKE_nla_tweakmode_exit(adt); + } +} + /* ****************************** */ /* wrapper for poll callback */ @@ -1041,6 +1058,12 @@ static void rna_def_animdata(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADT_NLA_EVAL_OFF); RNA_def_property_ui_text(prop, "NLA Evaluation Enabled", "NLA stack is evaluated when evaluating this block"); RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); /* this will do? */ + + prop = RNA_def_property(srna, "use_tweak_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", ADT_NLA_EDIT_ON); + RNA_def_property_boolean_funcs(prop, NULL, "rna_AnimData_tweakmode_set"); + RNA_def_property_ui_text(prop, "Use NLA Tweak Mode", "Whether to enable or disable tweak mode in NLA"); + RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, NULL); } /* --- */ -- cgit v1.2.3