From 2f16098d208058dce7701d6e49ed9052445553f5 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 7 Jan 2015 22:25:33 +0100 Subject: Gooseberry animation request: Paste flipped pose in action and graph editor. This was a tricky commit that was not so straightforward to make work. The information for bones is not easy to come by in the animation curves, however we do have some string manipulation tricks to make it happen. Testing in gooseberry worked for the rigs there, commiting to master now --- source/blender/editors/space_graph/graph_edit.c | 11 ++++++++--- source/blender/editors/space_graph/graph_ops.c | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_graph') diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 583d4a04ce0..b87f80c4e62 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -697,7 +697,7 @@ static short copy_graph_keys(bAnimContext *ac) } static short paste_graph_keys(bAnimContext *ac, - const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) + const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip) { ListBase anim_data = {NULL, NULL}; int filter, ok = 0; @@ -714,7 +714,7 @@ static short paste_graph_keys(bAnimContext *ac, ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* paste keyframes */ - ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); + ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip); /* clean up */ ANIM_animdata_freelist(&anim_data); @@ -765,6 +765,7 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); + const bool flipped = RNA_boolean_get(op->ptr, "flipped"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -774,7 +775,7 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) ac.reports = op->reports; /* paste keyframes - non-zero return means an error occurred while trying to paste */ - if (paste_graph_keys(&ac, offset_mode, merge_mode)) { + if (paste_graph_keys(&ac, offset_mode, merge_mode, flipped)) { return OPERATOR_CANCELLED; } @@ -786,6 +787,8 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) void GRAPH_OT_paste(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Paste Keyframes"; ot->idname = "GRAPH_OT_paste"; @@ -802,6 +805,8 @@ void GRAPH_OT_paste(wmOperatorType *ot) /* props */ RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); + prop = RNA_def_boolean(ot->srna, "flipped", false, "Flipped", "Paste keyframes from mirrored bones if they exist"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } /* ******************** Duplicate Keyframes Operator ************************* */ diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index f06d738200a..da308d0b1f1 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -580,9 +580,13 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* copy/paste */ WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "flipped", true); #ifdef __APPLE__ WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_OSKEY | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "flipped", true); #endif /* auto-set range */ -- cgit v1.2.3