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
This commit is contained in:
Kévin Dietrich 2016-07-24 03:18:40 +02:00
parent e4efa16b00
commit f283aa61c5
2 changed files with 28 additions and 0 deletions

@ -155,6 +155,11 @@ def bake_action(frame_start,
atd = obj.animation_data_create()
if action is None:
action = bpy.data.actions.new("Action")
# Leave tweak mode before trying to modify the action (T48397)
if atd.use_tweak_mode:
atd.use_tweak_mode = False
atd.action = action
# -------------------------------------------------------------------------

@ -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);
}
/* --- */