diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-03-24 09:33:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-03-24 09:34:52 +0300 |
commit | 17d0c1009618fa208d4ce21c3ce3ad3c55ea18be (patch) | |
tree | 0e8ec129d4efc7201c45d25b4c745cb49484d1cd /source/blender/editors/interface/interface_anim.c | |
parent | 0a3792a65b3ed039457f85c8538e822d6c5df222 (diff) |
Driver Keyframing: Some tweaks to make inserting keyframes on Driver F-Curves easier
Now, when trying to insert a keyframe on a driven property (using IKEY, or with
autokeying enabled), the keyframes will get created on the Driver's F-Curve
(instead of creating a new FCurve that goes into the active action, but will never
do anything). Furthermore, the x-value of the new keyframe will be the current
result of the driver expression.
Why/Motivations:
This way, it becomes easier to create corrective drivers, as you can position all
the targets the driver depends on, then adjust the driver value until it does what
you need, and then you keyframe that value to bake it into the Driver F-Curve
(in effect, "training" the computer how to behave in that case).
Usage Notes:
* In practice, that particular workflow is still quite clunky to achieve, due to some
quirks of how the driver system and the UI widgets interact. Specifically, you'll
need to disable/mute the driver before trying to edit the setting (to prevent the
driver from immediately resetting the value - before even autokey fires!). However,
if you're using the Graph Editor to preview/monitor/manage the keying process, you'll
then want to re-enable the driver before changing the targets, so that you can see
how much of a change you'll want to be applying!
* The warning about editing driver values may need to be disabled or selectively
knocked out. I had it disabled while testing this functionality, but it's actually
harmless in its current state (if just a bit annoying).
Diffstat (limited to 'source/blender/editors/interface/interface_anim.c')
-rw-r--r-- | source/blender/editors/interface/interface_anim.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 178fda043b6..46967742652 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -242,24 +242,41 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } } - else if (!driven) { + else if (driven) { + /* Driver - Try to insert keyframe using the driver's input as the frame, + * making it easier to set up corrective drivers + */ + if (IS_AUTOKEY_ON(scene)) { + ReportList *reports = CTX_wm_reports(C); + ToolSettings *ts = scene->toolsettings; + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + int index; + + UI_context_active_but_prop_get(C, &ptr, &prop, &index); + + insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, INSERTKEY_DRIVER); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + } + } + else { id = but->rnapoin.id.data; - + /* TODO: this should probably respect the keyingset only option for anim */ if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; short flag = ANIM_get_keyframing_flags(scene, 1); - + fcu->flag &= ~FCURVE_SELECTED; - + /* Note: We use but->rnaindex instead of fcu->array_index, * because a button may control all items of an array at once. * E.g., color wheels (see T42567). */ BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1)); insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, but->rnaindex, cfra, ts->keyframe_type, flag); - + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } } |