[Bf-blender-cvs] [f283aa6] master: Fix T48397: Can not bake tweaked NLA

Kévin Dietrich noreply at git.blender.org
Sun Jul 24 03:18:56 CEST 2016


Commit: f283aa61c5a5f7b0ff9869dc32519806237f8965
Author: Kévin Dietrich
Date:   Sun Jul 24 03:18:40 2016 +0200
Branches: master
https://developer.blender.org/rBf283aa61c5a5f7b0ff9869dc32519806237f8965

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

===================================================================

M	release/scripts/modules/bpy_extras/anim_utils.py
M	source/blender/makesrna/intern/rna_animation.c

===================================================================

diff --git a/release/scripts/modules/bpy_extras/anim_utils.py b/release/scripts/modules/bpy_extras/anim_utils.py
index 021a8bb..0cc6462 100644
--- a/release/scripts/modules/bpy_extras/anim_utils.py
+++ b/release/scripts/modules/bpy_extras/anim_utils.py
@@ -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
 
     # -------------------------------------------------------------------------
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index c3d1070..7a19540 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);
 }
 
 /* --- */




More information about the Bf-blender-cvs mailing list