Python API: expose more keyframing flags for use in keyframe_insert.
Expose REPLACE and CYCLE_AWARE, and add AVAILABLE for completeness. These flags are generic and safe to use, and necessary to match the behavior of certain UI options.
This commit is contained in:
parent
83d35c25d0
commit
ebc44aae98
Notes:
blender-bot
2023-02-14 08:10:06 +01:00
Referenced by issue #64566, Blender 2.8 crash Referenced by issue #64527, eevee volume not showing on coordinated + mapping gradient Referenced by issue #64512, Crash with bones with custom shapes AND being in a shading type that is NOT wireframe. Referenced by issue #64515, Crashing During Render View and Render Referenced by issue #64506, Weight paint mode with close up mesh, auto depth active, "show whole scene as transparent" shut down blender 2.8 Referenced by issue #60462, Blender 2.8 (various versions) crashes in GPU animation rendering (many card types), both eevee and cycles
|
@ -1307,8 +1307,8 @@ static bool insert_keyframe_fcurve_value(Main *bmain,
|
|||
* - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet
|
||||
* but still try to get the F-Curve if it exists...
|
||||
*/
|
||||
FCurve *fcu = verify_fcurve(
|
||||
bmain, act, group, ptr, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0);
|
||||
bool can_create_curve = (flag & (INSERTKEY_REPLACE | INSERTKEY_AVAILABLE)) == 0;
|
||||
FCurve *fcu = verify_fcurve(bmain, act, group, ptr, rna_path, array_index, can_create_curve);
|
||||
|
||||
/* we may not have a F-Curve when we're replacing only... */
|
||||
if (fcu) {
|
||||
|
@ -1432,7 +1432,7 @@ short insert_keyframe(Main *bmain,
|
|||
/* Key the entire array. */
|
||||
if (array_index == -1 || force_all) {
|
||||
/* In force mode, if any of the curves succeeds, drop the replace mode and restart. */
|
||||
if (force_all && (flag & INSERTKEY_REPLACE) != 0) {
|
||||
if (force_all && (flag & (INSERTKEY_REPLACE | INSERTKEY_AVAILABLE)) != 0) {
|
||||
int exclude = -1;
|
||||
|
||||
for (array_index = 0; array_index < value_count; array_index++) {
|
||||
|
@ -1455,7 +1455,7 @@ short insert_keyframe(Main *bmain,
|
|||
}
|
||||
|
||||
if (exclude != -1) {
|
||||
flag &= ~INSERTKEY_REPLACE;
|
||||
flag &= ~(INSERTKEY_REPLACE | INSERTKEY_AVAILABLE);
|
||||
|
||||
for (array_index = 0; array_index < value_count; array_index++) {
|
||||
if (array_index != exclude) {
|
||||
|
|
|
@ -970,6 +970,8 @@ typedef enum eInsertKeyFlags {
|
|||
INSERTKEY_DRIVER = (1 << 8),
|
||||
/** for cyclic FCurves, adjust key timing to preserve the cycle period and flow */
|
||||
INSERTKEY_CYCLE_AWARE = (1 << 9),
|
||||
/** don't create new F-Curves (implied by INSERTKEY_REPLACE) */
|
||||
INSERTKEY_AVAILABLE = (1 << 10),
|
||||
} eInsertKeyFlags;
|
||||
|
||||
/* ************************************************ */
|
||||
|
|
|
@ -96,6 +96,7 @@ extern const EnumPropertyItem rna_enum_keyblock_type_items[];
|
|||
|
||||
extern const EnumPropertyItem rna_enum_keyingset_path_grouping_items[];
|
||||
extern const EnumPropertyItem rna_enum_keying_flag_items[];
|
||||
extern const EnumPropertyItem rna_enum_keying_flag_items_api[];
|
||||
|
||||
extern const EnumPropertyItem rna_enum_keyframe_paste_offset_items[];
|
||||
extern const EnumPropertyItem rna_enum_keyframe_paste_merge_items[];
|
||||
|
|
|
@ -72,6 +72,43 @@ const EnumPropertyItem rna_enum_keying_flag_items[] = {
|
|||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
/* Contains additional flags suitable for use in Python API functions. */
|
||||
const EnumPropertyItem rna_enum_keying_flag_items_api[] = {
|
||||
{INSERTKEY_NEEDED,
|
||||
"INSERTKEY_NEEDED",
|
||||
0,
|
||||
"Only Needed",
|
||||
"Only insert keyframes where they're needed in the relevant F-Curves"},
|
||||
{INSERTKEY_MATRIX,
|
||||
"INSERTKEY_VISUAL",
|
||||
0,
|
||||
"Visual Keying",
|
||||
"Insert keyframes based on 'visual transforms'"},
|
||||
{INSERTKEY_XYZ2RGB,
|
||||
"INSERTKEY_XYZ_TO_RGB",
|
||||
0,
|
||||
"XYZ=RGB Colors",
|
||||
"Color for newly added transformation F-Curves (Location, Rotation, Scale) "
|
||||
"and also Color is based on the transform axis"},
|
||||
{INSERTKEY_REPLACE,
|
||||
"INSERTKEY_REPLACE",
|
||||
0,
|
||||
"Replace Existing",
|
||||
"Only replace existing keyframes"},
|
||||
{INSERTKEY_AVAILABLE,
|
||||
"INSERTKEY_AVAILABLE",
|
||||
0,
|
||||
"Only Available",
|
||||
"Don't create F-Curves when they don't already exist"},
|
||||
{INSERTKEY_CYCLE_AWARE,
|
||||
"INSERTKEY_CYCLE_AWARE",
|
||||
0,
|
||||
"Cycle Aware Keying",
|
||||
"When inserting into a curve with cyclic extrapolation, remap the keyframe inside "
|
||||
"the cycle time range, and if changing an end key, also update the other one"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
# include "BLI_math_base.h"
|
||||
|
|
|
@ -263,8 +263,9 @@ static int pyrna_struct_keyframe_parse(PointerRNA *ptr,
|
|||
|
||||
/* flag may be null (no option currently for remove keyframes e.g.). */
|
||||
if (r_options) {
|
||||
if (pyoptions && (pyrna_set_to_enum_bitfield(
|
||||
rna_enum_keying_flag_items, pyoptions, r_options, error_prefix) == -1)) {
|
||||
if (pyoptions &&
|
||||
(pyrna_set_to_enum_bitfield(
|
||||
rna_enum_keying_flag_items_api, pyoptions, r_options, error_prefix) == -1)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -299,8 +300,11 @@ char pyrna_struct_keyframe_insert_doc[] =
|
|||
"F-Curves.\n"
|
||||
" - ``INSERTKEY_VISUAL`` Insert keyframes based on 'visual transforms'.\n"
|
||||
" - ``INSERTKEY_XYZ_TO_RGB`` Color for newly added transformation F-Curves (Location, "
|
||||
"Rotation, Scale)\n"
|
||||
" and also Color is based on the transform axis.\n"
|
||||
"Rotation, Scale) is based on the transform axis.\n"
|
||||
" - ``INSERTKEY_REPLACE`` Only replace already exising keyframes.\n"
|
||||
" - ``INSERTKEY_AVAILABLE`` Only insert into already existing F-Curves.\n"
|
||||
" - ``INSERTKEY_CYCLE_AWARE`` Take cyclic extrapolation into account "
|
||||
"(Cycle-Aware Keying option).\n"
|
||||
" :type flag: set\n"
|
||||
" :return: Success of keyframe insertion.\n"
|
||||
" :rtype: boolean\n";
|
||||
|
|
Loading…
Reference in New Issue