diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2022-05-25 14:00:18 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2022-06-07 10:53:11 +0300 |
commit | 9ccc21dde372d57fa841a494d72527b30d2948d2 (patch) | |
tree | bef0482f2522fcb7dc61a2a7ffa59e6e1876a6ce /source/blender/editors/animation/keyframing.c | |
parent | 4580c18c56f62b1e1dbe35dd50925a21db36e506 (diff) |
VSE preview transform autokeying improvements
NOTE: this patch originated in T98015 which was split into multiple
reports. While it could be split into multiple patches these are very
much related so keeping as one for now
This patch fixes the following issues:
[1] autokeying transforms in preview only creates keyframes if there is
an FCurve already
[2] autokeying transforms in preview only creates keyframes for
rotation/scale if rotating/scaling around cursor (should keyframe
position as well)
[3] autokeying transforms in preview does not work during animation
playback
For [1], a param was added to `ED_autokeyframe_property` which can tweak
its default behavior of only creating keyframes on already keyed
properties (which was fine because this is mostly called from buttons
where this behavior is desired). Callers such as gizmos (or the VSE in
our case) can use this additional param so that keyframes are also
created on "not-yet-keyframed" properties.
For [2], the pivot is checked and position properties also keyed if
necessary (which is also consistent with the way objects are keyed in
the 3DView)
For [3], `animrecord_check_state` was changed to be able to work on
scenes as well and the transform system in the VSE preview was made
aware of the screen's `animtimer`.
NOTE: there are still things to be improved for keyframing in the VSE,
the most obvious is probably a `keyframe_insert` operator (with
keyingsets)
Fixes T98429, T98430, T98431
Maniphest Tasks: T98015, T98431, T98430, T98429
Differential Revision: https://developer.blender.org/D15047
Diffstat (limited to 'source/blender/editors/animation/keyframing.c')
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 941125b9ad5..9200a730072 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -3094,8 +3094,13 @@ bool ED_autokeyframe_pchan( return false; } -bool ED_autokeyframe_property( - bContext *C, Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra) +bool ED_autokeyframe_property(bContext *C, + Scene *scene, + PointerRNA *ptr, + PropertyRNA *prop, + int rnaindex, + float cfra, + const bool only_if_property_keyed) { Main *bmain = CTX_data_main(C); Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); @@ -3114,7 +3119,8 @@ bool ED_autokeyframe_property( fcu = BKE_fcurve_find_by_rna_context_ui( C, ptr, prop, rnaindex_check, NULL, &action, &driven, &special); - if (fcu == NULL) { + /* Only early out when we actually want an existing fcurve already (e.g. auto-keyframing from buttons). */ + if (fcu == NULL && (driven || special || only_if_property_keyed)) { return changed; } @@ -3150,23 +3156,28 @@ bool ED_autokeyframe_property( ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; const eInsertKeyFlags flag = ANIM_get_keyframing_flags(scene, true); + char *path = RNA_path_from_ID_to_property(ptr, prop); - /* NOTE: We use 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 == rnaindex) || (rnaindex == -1)); + if (only_if_property_keyed) { + /* NOTE: We use 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 == rnaindex) || (rnaindex == -1)); + } changed = insert_keyframe(bmain, reports, id, action, - ((fcu->grp) ? (fcu->grp->name) : (NULL)), - fcu->rna_path, + (fcu && fcu->grp) ? fcu->grp->name : NULL, + fcu ? fcu->rna_path : path, rnaindex, &anim_eval_context, ts->keyframe_type, NULL, flag) != 0; - + if (path) { + MEM_freeN(path); + } WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } } |