diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index 2fd273fa29f..bf6addd41bf 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -164,7 +164,7 @@ const UserDef U_default = { .image_draw_method = IMAGE_DRAW_METHOD_AUTO, .glalphaclip = 0.004, .autokey_mode = (AUTOKEY_MODE_NORMAL & ~AUTOKEY_ON), - .autokey_flag = AUTOKEY_FLAG_XYZ2RGB, + .keying_flag = KEYING_FLAG_XYZ2RGB | AUTOKEY_FLAG_INSERTNEEDED, .key_insert_channels = (USER_ANIM_KEY_CHANNEL_LOCATION | USER_ANIM_KEY_CHANNEL_ROTATION | USER_ANIM_KEY_CHANNEL_SCALE | USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES), .animation_flag = USER_ANIM_HIGH_QUALITY_DRAWING, diff --git a/scripts/startup/bl_ui/properties_scene.py b/scripts/startup/bl_ui/properties_scene.py index 4598804d884..01c4a8cd20d 100644 --- a/scripts/startup/bl_ui/properties_scene.py +++ b/scripts/startup/bl_ui/properties_scene.py @@ -88,7 +88,7 @@ class SceneKeyingSetsPanel: SceneKeyingSetsPanel._draw_keyframing_setting( context, layout, ks, ksp, iface_("Needed"), "use_insertkey_override_needed", "use_insertkey_needed", - userpref_fallback="use_keyframe_insert_needed", + userpref_fallback="use_auto_keyframe_insert_needed", ) SceneKeyingSetsPanel._draw_keyframing_setting( context, layout, ks, ksp, iface_("Visual"), diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index bb2e4420778..9dcfc875e8f 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -582,14 +582,17 @@ class USERPREF_PT_animation_keyframes(AnimationPanel, CenterAlignMixIn, Panel): layout.prop(edit, "key_insert_channels", expand=True) - col = layout.column() + row = layout.row(align=True, heading="Only Insert Needed") + row.prop(edit, "use_keyframe_insert_needed", text="Manual", toggle=1) + row.prop(edit, "use_auto_keyframe_insert_needed", text="Auto", toggle=1) + + col = layout.column(heading="Keyframing") col.prop(edit, "use_visual_keying") - col.prop(edit, "use_keyframe_insert_needed", text="Only Insert Needed") col = layout.column(heading="Auto-Keyframing") + col.prop(edit, "use_auto_keying", text="Enable in New Scenes") col.prop(edit, "use_auto_keying_warning", text="Show Warning") col.prop(edit, "use_keyframe_insert_available", text="Only Insert Available") - col.prop(edit, "use_auto_keying", text="Enable in New Scenes") class USERPREF_PT_animation_fcurves(AnimationPanel, CenterAlignMixIn, Panel): diff --git a/source/blender/animrig/ANIM_keyframing.hh b/source/blender/animrig/ANIM_keyframing.hh index 17441b77d2e..972cdc35560 100644 --- a/source/blender/animrig/ANIM_keyframing.hh +++ b/source/blender/animrig/ANIM_keyframing.hh @@ -134,8 +134,8 @@ bool is_autokey_on(const Scene *scene); /** Check the mode for auto-keyframing (per scene takes precedence). */ bool is_autokey_mode(const Scene *scene, eAutokey_Mode mode); -/** Check if a flag is set for auto-key-framing (per scene takes precedence). */ -bool is_autokey_flag(const Scene *scene, eKeyInsert_Flag flag); +/** Check if a flag is set for keyframing (per scene takes precedence). */ +bool is_keying_flag(const Scene *scene, eKeying_Flag flag); /** * Auto-keyframing feature - checks for whether anything should be done for the current frame. diff --git a/source/blender/animrig/intern/action.cc b/source/blender/animrig/intern/action.cc index 80c571a8367..75e2cb331ac 100644 --- a/source/blender/animrig/intern/action.cc +++ b/source/blender/animrig/intern/action.cc @@ -60,7 +60,7 @@ FCurve *action_fcurve_ensure(Main *bmain, fcu->rna_path = BLI_strdup(rna_path); fcu->array_index = array_index; - if (U.autokey_flag & AUTOKEY_FLAG_XYZ2RGB && ptr != nullptr) { + if (U.keying_flag & KEYING_FLAG_XYZ2RGB && ptr != nullptr) { /* For Loc/Rot/Scale and also Color F-Curves, the color of the F-Curve in the Graph Editor, * is determined by the array index for the F-Curve. */ diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index 830c02da946..f621a48f12e 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -26,6 +26,8 @@ #include "BKE_nla.h" #include "BKE_report.h" +#include "DNA_scene_types.h" + #include "BLI_dynstr.h" #include "BLI_math_base.h" #include "BLI_utildefines.h" @@ -66,6 +68,14 @@ void update_autoflags_fcurve_direct(FCurve *fcu, PropertyRNA *prop) } } +bool is_keying_flag(const Scene *scene, const eKeying_Flag flag) +{ + if (scene) { + return (scene->toolsettings->keying_flag & flag) || (U.keying_flag & flag); + } + return U.keying_flag & flag; +} + /** Used to make curves newly added to a cyclic Action cycle with the correct period. */ static void make_new_fcurve_cyclic(FCurve *fcu, const blender::float2 &action_range) { diff --git a/source/blender/animrig/intern/keyframing_auto.cc b/source/blender/animrig/intern/keyframing_auto.cc index 787c1bb7807..3d5b8716698 100644 --- a/source/blender/animrig/intern/keyframing_auto.cc +++ b/source/blender/animrig/intern/keyframing_auto.cc @@ -33,6 +33,33 @@ namespace blender::animrig { +static eInsertKeyFlags get_autokey_flags(Scene *scene) +{ + eInsertKeyFlags flag = INSERTKEY_NOFLAGS; + + /* Visual keying. */ + if (is_keying_flag(scene, KEYING_FLAG_VISUALKEY)) { + flag |= INSERTKEY_MATRIX; + } + + /* Only needed. */ + if (is_keying_flag(scene, AUTOKEY_FLAG_INSERTNEEDED)) { + flag |= INSERTKEY_NEEDED; + } + + /* Keyframing mode - only replace existing keyframes. */ + if (is_autokey_mode(scene, AUTOKEY_MODE_EDITKEYS)) { + flag |= INSERTKEY_REPLACE; + } + + /* Cycle-aware keyframe insertion - preserve cycle period and flow. */ + if (is_keying_flag(scene, KEYING_FLAG_CYCLEAWARE)) { + flag |= INSERTKEY_CYCLE_AWARE; + } + + return flag; +} + bool is_autokey_on(const Scene *scene) { if (scene) { @@ -49,14 +76,6 @@ bool is_autokey_mode(const Scene *scene, const eAutokey_Mode mode) return U.autokey_mode == mode; } -bool is_autokey_flag(const Scene *scene, const eKeyInsert_Flag flag) -{ - if (scene) { - return (scene->toolsettings->autokey_flag & flag) || (U.autokey_flag & flag); - } - return U.autokey_flag & flag; -} - bool autokeyframe_cfra_can_key(const Scene *scene, ID *id) { /* Only filter if auto-key mode requires this. */ @@ -97,13 +116,13 @@ void autokeyframe_object(bContext *C, Scene *scene, Object *ob, Span sources; ANIM_relative_keyingset_add_source(sources, id); - if (is_autokey_flag(scene, AUTOKEY_FLAG_ONLYKEYINGSET) && (active_ks)) { + if (is_keying_flag(scene, AUTOKEY_FLAG_ONLYKEYINGSET) && (active_ks)) { /* Only insert into active keyingset * NOTE: we assume here that the active Keying Set * does not need to have its iterator overridden. @@ -113,7 +132,7 @@ void autokeyframe_object(bContext *C, Scene *scene, Object *ob, Spanadt; ToolSettings *ts = scene->toolsettings; @@ -215,7 +234,7 @@ void autokeyframe_pose_channel(bContext *C, * visual keyframes even if flag not set, as it's not that useful otherwise * (for quick animation recording) */ - eInsertKeyFlags flag = ANIM_get_keyframing_flags(scene, true); + eInsertKeyFlags flag = get_autokey_flags(scene); if (targetless_ik) { flag |= INSERTKEY_MATRIX; @@ -226,7 +245,7 @@ void autokeyframe_pose_channel(bContext *C, ANIM_relative_keyingset_add_source(sources, id, &RNA_PoseBone, pose_channel); /* only insert into active keyingset? */ - if (blender::animrig::is_autokey_flag(scene, AUTOKEY_FLAG_ONLYKEYINGSET) && (active_ks)) { + if (blender::animrig::is_keying_flag(scene, AUTOKEY_FLAG_ONLYKEYINGSET) && (active_ks)) { /* Run the active Keying Set on the current data-source. */ ANIM_apply_keyingset( C, &sources, active_ks, MODIFYKEY_MODE_INSERT, anim_eval_context.eval_time); @@ -234,7 +253,7 @@ void autokeyframe_pose_channel(bContext *C, } /* only insert into available channels? */ - if (blender::animrig::is_autokey_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE)) { + if (blender::animrig::is_keying_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE)) { if (!act) { return; } @@ -333,7 +352,7 @@ bool autokeyframe_property(bContext *C, if (autokeyframe_cfra_can_key(scene, id)) { ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; - const eInsertKeyFlags flag = ANIM_get_keyframing_flags(scene, true); + const eInsertKeyFlags flag = get_autokey_flags(scene); char *path = RNA_path_from_ID_to_property(ptr, prop); if (only_if_property_keyed) { diff --git a/source/blender/blenloader/intern/versioning_userdef.cc b/source/blender/blenloader/intern/versioning_userdef.cc index 884b0dce164..e523ff566ad 100644 --- a/source/blender/blenloader/intern/versioning_userdef.cc +++ b/source/blender/blenloader/intern/versioning_userdef.cc @@ -415,7 +415,7 @@ void blo_do_versions_userdef(UserDef *userdef) if (!USER_VERSION_ATLEAST(257, 0)) { /* Clear #AUTOKEY_FLAG_ONLYKEYINGSET flag from user-preferences, * so that it doesn't linger around from old configurations like a ghost. */ - userdef->autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET; + userdef->keying_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET; } if (!USER_VERSION_ATLEAST(260, 3)) { @@ -908,6 +908,13 @@ void blo_do_versions_userdef(UserDef *userdef) USER_ANIM_KEY_CHANNEL_CUSTOM_PROPERTIES); } + if (!USER_VERSION_ATLEAST(401, 13)) { + if (userdef->keying_flag & AUTOKEY_FLAG_INSERTNEEDED) { + userdef->keying_flag |= MANUALKEY_FLAG_INSERTNEEDED; + } + userdef->keying_flag |= AUTOKEY_FLAG_INSERTNEEDED; + } + /** * Always bump subversion in BKE_blender_version.h when adding versioning * code here, and wrap it inside a USER_VERSION_ATLEAST check. diff --git a/source/blender/editors/animation/anim_channels_defines.cc b/source/blender/editors/animation/anim_channels_defines.cc index 56a498f5278..88e92b18608 100644 --- a/source/blender/editors/animation/anim_channels_defines.cc +++ b/source/blender/editors/animation/anim_channels_defines.cc @@ -5043,7 +5043,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi cfra = BKE_nla_tweakedit_remap(adt, float(scene->r.cfra), NLATIME_CONVERT_UNMAP); /* Get flags for keyframing. */ - flag = ANIM_get_keyframing_flags(scene, true); + flag = ANIM_get_keyframing_flags(scene); /* try to resolve the path stored in the F-Curve */ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { @@ -5106,7 +5106,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi key->adt, anim_eval_context.eval_time, NLATIME_CONVERT_UNMAP); /* get flags for keyframing */ - flag = ANIM_get_keyframing_flags(scene, true); + flag = ANIM_get_keyframing_flags(scene); /* try to resolve the path stored in the F-Curve */ if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) { @@ -5166,7 +5166,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, void * /*id_poin*/ cfra = float(scene->r.cfra); /* get flags for keyframing */ - flag = ANIM_get_keyframing_flags(scene, true); + flag = ANIM_get_keyframing_flags(scene); /* Get pointer and property from the slider - * this should all match up with the NlaStrip required. */ diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index 37fea96159a..e03d80a375d 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -76,38 +76,23 @@ static int delete_key_using_keying_set(bContext *C, wmOperator *op, KeyingSet *k /* ************************************************** */ /* Keyframing Setting Wrangling */ -eInsertKeyFlags ANIM_get_keyframing_flags(Scene *scene, const bool use_autokey_mode) +eInsertKeyFlags ANIM_get_keyframing_flags(Scene *scene) { using namespace blender::animrig; eInsertKeyFlags flag = INSERTKEY_NOFLAGS; - /* standard flags */ - { - /* visual keying */ - if (is_autokey_flag(scene, AUTOKEY_FLAG_VISUALKEY)) { - flag |= INSERTKEY_MATRIX; - } - - /* only needed */ - if (is_autokey_flag(scene, AUTOKEY_FLAG_INSERTNEEDED)) { - flag |= INSERTKEY_NEEDED; - } + /* Visual keying. */ + if (is_keying_flag(scene, KEYING_FLAG_VISUALKEY)) { + flag |= INSERTKEY_MATRIX; } - /* only if including settings from the autokeying mode... */ - /* TODO: The fact that this flag needs to be passed as true is confusing because it is not clear - * why those two flags would be exclusive to autokeying. Refactor flags so they are separate - * between normal keying and autokeying. */ - if (use_autokey_mode) { - /* keyframing mode - only replace existing keyframes */ - if (is_autokey_mode(scene, AUTOKEY_MODE_EDITKEYS)) { - flag |= INSERTKEY_REPLACE; - } + /* Cycle-aware keyframe insertion - preserve cycle period and flow. */ + if (is_keying_flag(scene, KEYING_FLAG_CYCLEAWARE)) { + flag |= INSERTKEY_CYCLE_AWARE; + } - /* cycle-aware keyframe insertion - preserve cycle period and flow */ - if (is_autokey_flag(scene, AUTOKEY_FLAG_CYCLEAWARE)) { - flag |= INSERTKEY_CYCLE_AWARE; - } + if (is_keying_flag(scene, MANUALKEY_FLAG_INSERTNEEDED)) { + flag |= INSERTKEY_NEEDED; } return flag; @@ -362,9 +347,7 @@ static int insert_key(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); const float scene_frame = BKE_scene_frame_get(scene); - /* Passing autokey mode as true because that is needed to get the cycle aware keying flag. */ - const bool use_autokey_mode = true; - const eInsertKeyFlags insert_key_flags = ANIM_get_keyframing_flags(scene, use_autokey_mode); + const eInsertKeyFlags insert_key_flags = ANIM_get_keyframing_flags(scene); const eBezTriple_KeyframeType key_type = eBezTriple_KeyframeType( scene->toolsettings->keyframe_type); @@ -896,8 +879,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) const bool all = RNA_boolean_get(op->ptr, "all"); eInsertKeyFlags flag = INSERTKEY_NOFLAGS; - /* flags for inserting keyframes */ - flag = ANIM_get_keyframing_flags(scene, true); + flag = ANIM_get_keyframing_flags(scene); if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { /* pass event on if no active button found */ diff --git a/source/blender/editors/animation/keyingsets.cc b/source/blender/editors/animation/keyingsets.cc index d69be65fc1a..ccb0dcc09ff 100644 --- a/source/blender/editors/animation/keyingsets.cc +++ b/source/blender/editors/animation/keyingsets.cc @@ -101,7 +101,7 @@ static int add_default_keyingset_exec(bContext *C, wmOperator * /*op*/) */ const eKS_Settings flag = KEYINGSET_ABSOLUTE; - const eInsertKeyFlags keyingflag = ANIM_get_keyframing_flags(scene, false); + const eInsertKeyFlags keyingflag = ANIM_get_keyframing_flags(scene); /* Call the API func, and set the active keyingset index. */ BKE_keyingset_add(&scene->keyingsets, nullptr, nullptr, flag, keyingflag); @@ -285,7 +285,7 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) */ const eKS_Settings flag = KEYINGSET_ABSOLUTE; - const eInsertKeyFlags keyingflag = ANIM_get_keyframing_flags(scene, false); + const eInsertKeyFlags keyingflag = ANIM_get_keyframing_flags(scene); /* Call the API func, and set the active keyingset index. */ keyingset = BKE_keyingset_add( @@ -741,13 +741,13 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(const Scene *scene, const char *tra * - use the active KeyingSet if defined (and user wants to use it for all autokeying), * or otherwise key transforms only */ - if (blender::animrig::is_autokey_flag(scene, AUTOKEY_FLAG_ONLYKEYINGSET) && + if (blender::animrig::is_keying_flag(scene, AUTOKEY_FLAG_ONLYKEYINGSET) && (scene->active_keyingset)) { return ANIM_scene_get_active_keyingset(scene); } - if (blender::animrig::is_autokey_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE)) { + if (blender::animrig::is_keying_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE)) { return ANIM_builtin_keyingset_get_named(ANIM_KS_AVAILABLE_ID); } @@ -1139,7 +1139,7 @@ int ANIM_apply_keyingset(bContext *C, } Scene *scene = CTX_data_scene(C); - const eInsertKeyFlags base_kflags = ANIM_get_keyframing_flags(scene, true); + const eInsertKeyFlags base_kflags = ANIM_get_keyframing_flags(scene); eInsertKeyFlags kflag = INSERTKEY_NOFLAGS; if (mode == MODIFYKEY_MODE_INSERT) { /* use context settings as base */ diff --git a/source/blender/editors/include/ED_keyframing.hh b/source/blender/editors/include/ED_keyframing.hh index 53173aed5e9..765c7cd121f 100644 --- a/source/blender/editors/include/ED_keyframing.hh +++ b/source/blender/editors/include/ED_keyframing.hh @@ -44,7 +44,7 @@ struct NlaKeyframingContext; * \param use_autokey_mode: include settings from key-framing mode in the result * (i.e. replace only). */ -eInsertKeyFlags ANIM_get_keyframing_flags(Scene *scene, bool use_autokey_mode); +eInsertKeyFlags ANIM_get_keyframing_flags(Scene *scene); /* -------- */ diff --git a/source/blender/editors/space_action/action_edit.cc b/source/blender/editors/space_action/action_edit.cc index dbec46f9771..b6c0e936028 100644 --- a/source/blender/editors/space_action/action_edit.cc +++ b/source/blender/editors/space_action/action_edit.cc @@ -897,7 +897,7 @@ static void insert_action_keys(bAnimContext *ac, short mode) ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype)); /* Init keyframing flag. */ - flag = ANIM_get_keyframing_flags(scene, true); + flag = ANIM_get_keyframing_flags(scene); /* GPLayers specific flags */ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) { diff --git a/source/blender/editors/space_graph/graph_edit.cc b/source/blender/editors/space_graph/graph_edit.cc index 6c7d414d0c0..dea2b636a1b 100644 --- a/source/blender/editors/space_graph/graph_edit.cc +++ b/source/blender/editors/space_graph/graph_edit.cc @@ -147,7 +147,7 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) } /* Init key-framing flag. */ - flag = ANIM_get_keyframing_flags(scene, true); + flag = ANIM_get_keyframing_flags(scene); KeyframeSettings settings = get_keyframe_settings(true); settings.keyframe_type = eBezTriple_KeyframeType(ts->keyframe_type); diff --git a/source/blender/editors/transform/transform.cc b/source/blender/editors/transform/transform.cc index b64fd8b3700..cdfd646adbc 100644 --- a/source/blender/editors/transform/transform.cc +++ b/source/blender/editors/transform/transform.cc @@ -1592,7 +1592,7 @@ static void drawTransformPixel(const bContext * /*C*/, ARegion *region, void *ar * for objects that will be auto-keyframed (no point otherwise), * AND only for the active region (as showing all is too overwhelming) */ - if ((U.autokey_flag & AUTOKEY_FLAG_NOWARNING) == 0) { + if ((U.keying_flag & AUTOKEY_FLAG_NOWARNING) == 0) { if (region == t->region) { if (t->options & (CTX_OBJECT | CTX_POSE_BONE)) { if (ob && blender::animrig::autokeyframe_cfra_can_key(scene, &ob->id)) { diff --git a/source/blender/editors/transform/transform_convert.cc b/source/blender/editors/transform/transform_convert.cc index b28c45cc7a8..ae8a75fa8bd 100644 --- a/source/blender/editors/transform/transform_convert.cc +++ b/source/blender/editors/transform/transform_convert.cc @@ -1203,8 +1203,8 @@ void animrecord_check_state(TransInfo *t, ID *id) * - we're not only keying for available channels * - the option to add new actions for each round is not enabled */ - if (blender::animrig::is_autokey_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE) == 0 && - (scene->toolsettings->autokey_flag & AUTOKEY_FLAG_LAYERED_RECORD)) + if (blender::animrig::is_keying_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE) == 0 && + (scene->toolsettings->keying_flag & AUTOKEY_FLAG_LAYERED_RECORD)) { /* if playback has just looped around, * we need to add a new NLA track+strip to allow a clean pass to occur */ diff --git a/source/blender/editors/transform/transform_convert_armature.cc b/source/blender/editors/transform/transform_convert_armature.cc index 64264d82018..a67ae001fc8 100644 --- a/source/blender/editors/transform/transform_convert_armature.cc +++ b/source/blender/editors/transform/transform_convert_armature.cc @@ -1330,7 +1330,7 @@ static void autokeyframe_pose( const blender::StringRef rotation_path = blender::animrig::get_rotation_mode_path( eRotationModes(pchan->rotmode)); - if (blender::animrig::is_autokey_flag(scene, AUTOKEY_FLAG_INSERTNEEDED)) { + if (blender::animrig::is_keying_flag(scene, AUTOKEY_FLAG_INSERTNEEDED)) { rna_paths = get_affected_rna_paths_from_transform_mode( tmode, scene->toolsettings, rotation_path, targetless_ik); } diff --git a/source/blender/editors/transform/transform_convert_object.cc b/source/blender/editors/transform/transform_convert_object.cc index 9f005427aeb..053b8b45caf 100644 --- a/source/blender/editors/transform/transform_convert_object.cc +++ b/source/blender/editors/transform/transform_convert_object.cc @@ -818,7 +818,7 @@ static void autokeyframe_object(bContext *C, Scene *scene, Object *ob, const eTf const blender::StringRef rotation_path = blender::animrig::get_rotation_mode_path( eRotationModes(ob->rotmode)); - if (blender::animrig::is_autokey_flag(scene, AUTOKEY_FLAG_INSERTNEEDED)) { + if (blender::animrig::is_keying_flag(scene, AUTOKEY_FLAG_INSERTNEEDED)) { rna_paths = get_affected_rna_paths_from_transform_mode( tmode, scene, view_layer, ob, rotation_path); } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 6f99a40d51a..c156de3df39 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1614,9 +1614,9 @@ typedef struct ToolSettings { /** Select Group Threshold. */ float select_thresh; - /* Auto-Keying Mode. */ + /* Keying Settings. */ /** Defines in DNA_userdef_types.h. */ - short autokey_flag; + short keying_flag; char autokey_mode; /** Keyframe type (see DNA_curve_types.h). */ char keyframe_type; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 15eeac0be6e..d4767b37ca6 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -956,8 +956,8 @@ typedef struct UserDef { /** #eAutokey_Mode, auto-keying mode. */ short autokey_mode; - /** Flags for autokeying. */ - short autokey_flag; + /** Flags for inserting keyframes. */ + short keying_flag; /** Flags for which channels to insert keys at. */ short key_insert_channels; // eKeyInsertChannels char _pad15[6]; @@ -1286,19 +1286,25 @@ typedef enum eZoomFrame_Mode { /** * Defines how keyframes are inserted. * Used for regular keying and auto-keying. + * Not all of those flags are stored in the user preferences (U.keying_flag). + * Some are stored on the scene (toolsettings.keying_flag). */ -typedef enum eKeyInsert_Flag { +typedef enum eKeying_Flag { + /* Settings used across manual and auto-keying. */ + KEYING_FLAG_VISUALKEY = (1 << 2), + KEYING_FLAG_XYZ2RGB = (1 << 3), + KEYING_FLAG_CYCLEAWARE = (1 << 8), + + /* Autokey options. */ AUTOKEY_FLAG_INSERTAVAILABLE = (1 << 0), AUTOKEY_FLAG_INSERTNEEDED = (1 << 1), - AUTOKEY_FLAG_VISUALKEY = (1 << 2), - AUTOKEY_FLAG_XYZ2RGB = (1 << 3), - - /* toolsettings->autokey_flag */ AUTOKEY_FLAG_ONLYKEYINGSET = (1 << 6), AUTOKEY_FLAG_NOWARNING = (1 << 7), - AUTOKEY_FLAG_CYCLEAWARE = (1 << 8), AUTOKEY_FLAG_LAYERED_RECORD = (1 << 10), -} eKeyInsert_Flag; + + /* Manual Keying options. */ + MANUALKEY_FLAG_INSERTNEEDED = (1 << 11), +} eKeying_Flag; typedef enum eKeyInsertChannels { USER_ANIM_KEY_CHANNEL_LOCATION = (1 << 0), @@ -1311,7 +1317,7 @@ typedef enum eKeyInsertChannels { /** * Animation flags * #UserDef.animation_flag, used for animation flags that aren't covered by more specific flags - * (like eKeyInsert_Flag). + * (like eKeying_Flag). */ typedef enum eUserpref_Anim_Flags { USER_ANIM_SHOW_CHANNEL_GROUP_COLORS = (1 << 0), diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index f5df8777238..416ac7978e1 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -219,6 +219,7 @@ DNA_STRUCT_RENAME_ELEM(bTheme, ttopbar, space_topbar) DNA_STRUCT_RENAME_ELEM(bTheme, tuserpref, space_preferences) DNA_STRUCT_RENAME_ELEM(bTheme, tv3d, space_view3d) DNA_STRUCT_RENAME_ELEM(bUserAssetLibrary, path, dirpath) +DNA_STRUCT_RENAME_ELEM(UserDef, autokey_flag, keying_flag) /* NOTE: Keep sorted! */ /* Write with a different name, old Blender versions crash loading files with non-NULL diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index b41c2376905..73b6268294a 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -3842,7 +3842,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) "Mode of automatic keyframe insertion for Objects, Bones and Masks"); prop = RNA_def_property(srna, "use_record_with_nla", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_LAYERED_RECORD); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", AUTOKEY_FLAG_LAYERED_RECORD); RNA_def_property_ui_text( prop, "Layered", @@ -3850,14 +3850,14 @@ static void rna_def_tool_settings(BlenderRNA *brna) "to allow non-destructive tweaking"); prop = RNA_def_property(srna, "use_keyframe_insert_keyingset", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_ONLYKEYINGSET); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", AUTOKEY_FLAG_ONLYKEYINGSET); RNA_def_property_ui_text(prop, "Auto Keyframe Insert Keying Set", "Automatic keyframe insertion using active Keying Set only"); RNA_def_property_ui_icon(prop, ICON_KEYINGSET, 0); prop = RNA_def_property(srna, "use_keyframe_cycle_aware", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_CYCLEAWARE); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", KEYING_FLAG_CYCLEAWARE); RNA_def_property_ui_text( prop, "Cycle-Aware Keying", diff --git a/source/blender/makesrna/intern/rna_userdef.cc b/source/blender/makesrna/intern/rna_userdef.cc index d04d9f5d4f6..653aabda14b 100644 --- a/source/blender/makesrna/intern/rna_userdef.cc +++ b/source/blender/makesrna/intern/rna_userdef.cc @@ -5422,13 +5422,13 @@ static void rna_def_userdef_edit(BlenderRNA *brna) "(default setting used for new Scenes)"); prop = RNA_def_property(srna, "use_keyframe_insert_available", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_INSERTAVAILABLE); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", AUTOKEY_FLAG_INSERTAVAILABLE); RNA_def_property_ui_text(prop, "Auto Keyframe Insert Available", "Automatic keyframe insertion in available F-Curves"); prop = RNA_def_property(srna, "use_auto_keying_warning", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_NOWARNING); + RNA_def_property_boolean_negative_sdna(prop, nullptr, "keying_flag", AUTOKEY_FLAG_NOWARNING); RNA_def_property_ui_text( prop, "Show Auto Keying Warning", @@ -5443,18 +5443,23 @@ static void rna_def_userdef_edit(BlenderRNA *brna) "Default Key Channels", "Which channels to insert keys at when no keying set is active"); + prop = RNA_def_property(srna, "use_auto_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", AUTOKEY_FLAG_INSERTNEEDED); + RNA_def_property_ui_text( + prop, "Autokey Insert Needed", "Auto-Keyframe insertion only when keyframe needed"); + prop = RNA_def_property(srna, "use_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_INSERTNEEDED); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", MANUALKEY_FLAG_INSERTNEEDED); RNA_def_property_ui_text( prop, "Keyframe Insert Needed", "Keyframe insertion only when keyframe needed"); prop = RNA_def_property(srna, "use_visual_keying", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_VISUALKEY); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", KEYING_FLAG_VISUALKEY); RNA_def_property_ui_text( prop, "Visual Keying", "Use Visual keying automatically for constrained objects"); prop = RNA_def_property(srna, "use_insertkey_xyz_to_rgb", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "autokey_flag", AUTOKEY_FLAG_XYZ2RGB); + RNA_def_property_boolean_sdna(prop, nullptr, "keying_flag", KEYING_FLAG_XYZ2RGB); RNA_def_property_ui_text( prop, "New F-Curve Colors - XYZ to RGB", diff --git a/tests/python/bl_animation_keyframing.py b/tests/python/bl_animation_keyframing.py index 47cb8459e52..2e1e138d88d 100644 --- a/tests/python/bl_animation_keyframing.py +++ b/tests/python/bl_animation_keyframing.py @@ -256,6 +256,7 @@ class AutoKeyframingTest(AbstractKeyframingTest, unittest.TestCase): bpy.context.scene.tool_settings.use_keyframe_insert_auto = True bpy.context.preferences.edit.use_keyframe_insert_available = False bpy.context.preferences.edit.use_keyframe_insert_needed = False + bpy.context.preferences.edit.use_auto_keyframe_insert_needed = False def tearDown(self): super().tearDown() @@ -291,6 +292,7 @@ class InsertAvailableTest(AbstractKeyframingTest, unittest.TestCase): bpy.context.scene.tool_settings.use_keyframe_insert_auto = True bpy.context.preferences.edit.use_keyframe_insert_available = True bpy.context.preferences.edit.use_keyframe_insert_needed = False + bpy.context.preferences.edit.use_auto_keyframe_insert_needed = False def tearDown(self): super().tearDown() @@ -385,12 +387,14 @@ class InsertNeededTest(AbstractKeyframingTest, unittest.TestCase): super().setUp() bpy.context.scene.tool_settings.use_keyframe_insert_auto = True bpy.context.preferences.edit.use_keyframe_insert_needed = True + bpy.context.preferences.edit.use_auto_keyframe_insert_needed = True bpy.context.preferences.edit.use_keyframe_insert_available = False def tearDown(self): super().tearDown() bpy.context.scene.tool_settings.use_keyframe_insert_auto = False bpy.context.preferences.edit.use_keyframe_insert_needed = False + bpy.context.preferences.edit.use_auto_keyframe_insert_needed = False def test_insert_needed_object(self): keyed_object = _create_animation_object()