Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-25 20:44:55 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-28 11:46:06 +0400
commit2aa9d33404ca96e6bd42224ebac19696e03550f8 (patch)
treeebaf3912a1b8802cf479a345a7708ad86f2eef9b
parente44018220ab0b0bf63970861b0a718144afc2a56 (diff)
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
-rw-r--r--source/blender/editors/animation/keyframing.c16
-rw-r--r--source/blender/editors/animation/keyingsets.c10
-rw-r--r--source/blender/editors/include/ED_keyframing.h3
3 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index a17fec52a1c..9008d330c21 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 dd8433f7770..28b2d26e59b 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 7543e170c9d..5c7b3c531be 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);