[Bf-blender-cvs] [2aa9d33] master: Fix T39902: Keyframe insertion by a Keying Set fails in the edit mode when keyframing object data properties.

Tamito Kajiyama noreply at git.blender.org
Mon Apr 28 09:46:38 CEST 2014


Commit: 2aa9d33404ca96e6bd42224ebac19696e03550f8
Author: Tamito Kajiyama
Date:   Sat Apr 26 01:44:55 2014 +0900
https://developer.blender.org/rB2aa9d33404ca96e6bd42224ebac19696e03550f8

Fix T39902: Keyframe insertion by a Keying Set fails in the edit mode when keyframing object data properties.

Reviewers: aligorith

Reviewed By: aligorith

Differential Revision: https://developer.blender.org/D484

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

M	source/blender/editors/animation/keyframing.c
M	source/blender/editors/animation/keyingsets.c
M	source/blender/editors/include/ED_keyframing.h

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

diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index a17fec5..9008d33 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -72,6 +72,7 @@
 #include "ED_keyframing.h"
 #include "ED_keyframes_edit.h"
 #include "ED_screen.h"
+#include "ED_object.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -1265,6 +1266,8 @@ static int modify_key_op_poll(bContext *C)
 static int insert_key_exec(bContext *C, wmOperator *op)
 {
 	Scene *scene = CTX_data_scene(C);
+	Object *ob = CTX_data_active_object(C);
+	bool ob_edit_mode = false;
 	KeyingSet *ks = NULL;
 	int type = RNA_enum_get(op->ptr, "type");
 	float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
@@ -1287,12 +1290,25 @@ static int insert_key_exec(bContext *C, wmOperator *op)
 		BKE_report(op->reports, RPT_ERROR, "No active keying set");
 		return OPERATOR_CANCELLED;
 	}
+
+	/* exit the edit mode to make sure that those object data properties that have been
+	 * updated since the last switching to the edit mode will be keyframed correctly
+	 */
+	if (ob && (ob->mode & OB_MODE_EDIT) != 0 && ANIM_keyingset_find_id(ks, (ID *)ob->data)) {
+		ED_object_toggle_modes(C, OB_MODE_EDIT);
+		ob_edit_mode = true;
+	}
 	
 	/* try to insert keyframes for the channels specified by KeyingSet */
 	success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
 	if (G.debug & G_DEBUG)
 		BKE_reportf(op->reports, RPT_INFO, "Keying set '%s' - successfully added %d keyframes", ks->name, success);
 	
+	/* restore the edit mode if necessary */
+	if (ob_edit_mode) {
+		ED_object_toggle_modes(C, OB_MODE_EDIT);
+	}
+
 	/* report failure or do updates? */
 	if (success == MODIFYKEY_INVALID_CONTEXT) {
 		BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set");
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index dd8433f..28b2d26 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -641,6 +641,16 @@ void ANIM_keyingset_infos_exit(void)
 	BKE_keyingsets_free(&builtin_keyingsets);
 }
 
+/* Check if the ID appears in the paths specified by the KeyingSet */
+bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
+{
+	/* sanity checks */
+	if (ELEM(NULL, ks, id))
+		return false;
+
+	return BLI_findptr(&ks->paths, id, offsetof(KS_Path, id)) != NULL;
+}
+
 /* ******************************************* */
 /* KEYING SETS API (for UI) */
 
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 7543e17..5c7b3c5 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -202,6 +202,9 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, con
 /* Find KeyingSet type info given a name */
 KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]);
 
+/* Find a given ID in the KeyingSet */
+bool ANIM_keyingset_find_id(struct KeyingSet *ks, ID *id);
+
 /* for RNA type registrations... */
 void ANIM_keyingset_info_register(KeyingSetInfo *ksi);
 void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi);




More information about the Bf-blender-cvs mailing list