Ignore user-preferences when inserting keys from Python

This commit is contained in:
Campbell Barton 2014-04-29 07:34:09 +10:00
parent 5d51de3bea
commit a91c4ac99f
4 changed files with 21 additions and 8 deletions

@ -396,11 +396,18 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag)
beztr.vec[2][0] = x + 1.0f;
beztr.vec[2][1] = y;
beztr.f1 = beztr.f2 = beztr.f3 = SELECT;
beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
//BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
/* use default interpolation mode, with exceptions for int/discrete values */
beztr.ipo = U.ipo_new;
if (flag & INSERTKEY_NO_USERPREF) {
beztr.h1 = beztr.h2 = HD_AUTO_ANIM;
beztr.ipo = BEZT_IPO_BEZ;
}
else {
beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */
//BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */
/* use default interpolation mode, with exceptions for int/discrete values */
beztr.ipo = U.ipo_new;
}
if (fcu->flag & FCURVE_DISCRETE_VALUES)
beztr.ipo = BEZT_IPO_CONST;

@ -791,7 +791,8 @@ typedef enum eInsertKeyFlags {
INSERTKEY_FAST = (1<<2), /* don't recalculate handles,etc. after adding key */
INSERTKEY_FASTR = (1<<3), /* don't realloc mem (or increase count, as array has already been set out) */
INSERTKEY_REPLACE = (1<<4), /* only replace an existing keyframe (this overrides INSERTKEY_NEEDED) */
INSERTKEY_XYZ2RGB = (1<<5) /* transform F-Curves should have XYZ->RGB color mode */
INSERTKEY_XYZ2RGB = (1<<5), /* transform F-Curves should have XYZ->RGB color mode */
INSERTKEY_NO_USERPREF = (1 << 6), /* ignore user-prefs (needed for predictable API use) */
} eInsertKeyFlags;
/* ************************************************ */

@ -738,7 +738,7 @@ static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, fl
static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
{
int index = insert_vert_fcurve(fcu, frame, value, flag);
int index = insert_vert_fcurve(fcu, frame, value, flag | INSERTKEY_NO_USERPREF);
return ((fcu->bezt) && (index >= 0)) ? (fcu->bezt + index) : NULL;
}

@ -168,8 +168,13 @@ static int pyrna_struct_keyframe_parse(
*cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
/* flag may be null (no option currently for remove keyframes e.g.). */
if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1))
return -1;
if (options) {
if (pyoptions && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1)) {
return -1;
}
*options |= INSERTKEY_NO_USERPREF;
}
return 0; /* success */
}