Anim: Separate keying flags #115525

Merged
Christoph Lendenfeld merged 31 commits from ChrisLend/blender:autokey_separate_flags into main 2024-01-19 16:26:19 +01:00
24 changed files with 127 additions and 90 deletions

View File

@ -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,

View File

@ -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"),

View File

@ -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):

View File

@ -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);
nathanvegdahl marked this conversation as resolved Outdated

Should we change this function's name to not reference autokeying? is_autokey_flag makes me think that it's specific to flags that only apply to autokeying. But reading further into the PR it looks like it's used in non-autokeying contexts for non-autokeying-specific flags as well.

But maybe I'm confused.

Should we change this function's name to not reference autokeying? `is_autokey_flag` makes me think that it's specific to flags that only apply to autokeying. But reading further into the PR it looks like it's used in non-autokeying contexts for non-autokeying-specific flags as well. But maybe I'm confused.

That's a good point. I've renamed the function to is_keying_flag
and moved the implementation to keyframing.cc

That's a good point. I've renamed the function to `is_keying_flag` and moved the implementation to `keyframing.cc`
/**
* Auto-keyframing feature - checks for whether anything should be done for the current frame.

View File

@ -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.
*/

View File

@ -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)
{

View File

@ -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<std::string
depsgraph, BKE_scene_frame_get(scene));
/* Get flags used for inserting keyframes. */
const eInsertKeyFlags flag = ANIM_get_keyframing_flags(scene, true);
const eInsertKeyFlags flag = get_autokey_flags(scene);
/* Add data-source override for the object. */
blender::Vector<PointerRNA> 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, Span<std::string
return;
}
if (is_autokey_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE)) {
if (is_keying_flag(scene, AUTOKEY_FLAG_INSERTAVAILABLE)) {
/* Only key on available channels. */
AnimData *adt = ob->adt;
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) {

View File

@ -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.

View File

@ -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. */

View File

@ -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 */

View File

@ -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 */

View File

@ -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);
/* -------- */

View File

@ -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) {

View File

@ -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);

View File

@ -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)) {

View File

@ -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 */

View File

@ -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);
}

View File

@ -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);
}

View File

@ -1614,9 +1614,9 @@ typedef struct ToolSettings {
/** Select Group Threshold. */
float select_thresh;
/* Auto-Keying Mode. */
/* Keying Settings. */
nathanvegdahl marked this conversation as resolved Outdated

Should this comment change now that autokey_flag has been changed to keying_flag?

Should this comment change now that `autokey_flag` has been changed to `keying_flag`?

Yep, changed

Yep, changed
/** 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;

View File

@ -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;
nathanvegdahl marked this conversation as resolved
Review

If I understand DNA correctly, this rename means (from DNA's perspective) that autokey_flag has disappeared and a separate unrelated field keying_flag has been added. Which means the flags in autokey_flag from old files will simply be discarded by DNA on load.

That's totally fine if we're okay with the flags from older files getting lost. But if we want to migrate them over we either need to:

  • Keep autokey_flag alongside keying_flag, and manually copy the flags over in the versioning code, OR
  • Add the rename to dna_rename_defs.h so that DNA knows it's a rename, and thus will copy the data over for us.
If I understand DNA correctly, this rename means (from DNA's perspective) that `autokey_flag` has disappeared and a separate unrelated field `keying_flag` has been added. Which means the flags in `autokey_flag` from old files will simply be discarded by DNA on load. That's totally fine if we're okay with the flags from older files getting lost. But if we want to migrate them over we either need to: - Keep `autokey_flag` alongside `keying_flag`, and manually copy the flags over in the versioning code, OR - Add the rename to dna_rename_defs.h so that DNA knows it's a rename, and thus will copy the data over for us.

thanks for pointing that out. Wasn't aware such a file existed
tested it now and the user preferences seem to version up properly

thanks for pointing that out. Wasn't aware such a file existed tested it now and the user preferences seem to version up properly
Review

Yeah, I also wasn't aware of it until relatively recently, when working on the bone collections code. Lots of hidden things in Blender like this...

Yeah, I also wasn't aware of it until relatively recently, when working on the bone collections code. Lots of hidden things in Blender like this...
/** 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),

View File

@ -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

View File

@ -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",

View File

@ -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",

View File

@ -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()