diff options
-rw-r--r-- | source/blender/editors/animation/keyframes_general.c | 4 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 33 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_anim_types.h | 3 |
3 files changed, 24 insertions, 16 deletions
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 8f5510a2273..56165c36efa 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -732,9 +732,9 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float bezt->vec[2][0] += offset; /* insert the keyframe - * NOTE: no special flags here for now + * NOTE: we do not want to inherit handles from existing keyframes in this case! */ - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, INSERTKEY_OVERWRITE_FULL); /* un-apply offset from src beztriple after copying */ bezt->vec[0][0] -= offset; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index a68751e9294..4c2d90179a7 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -310,20 +310,25 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ if ((i >= 0) && (i < fcu->totvert)) { - /* just change the values when replacing, so as to not overwrite handles */ - BezTriple *dst = (fcu->bezt + i); - float dy = bezt->vec[1][1] - dst->vec[1][1]; - - /* just apply delta value change to the handle values */ - dst->vec[0][1] += dy; - dst->vec[1][1] += dy; - dst->vec[2][1] += dy; - - dst->f1 = bezt->f1; - dst->f2 = bezt->f2; - dst->f3 = bezt->f3; - - /* TODO: perform some other operations? */ + if (flag & INSERTKEY_OVERWRITE_FULL) { + fcu->bezt[i] = *bezt; + } + else { + /* just change the values when replacing, so as to not overwrite handles */ + BezTriple *dst = (fcu->bezt + i); + float dy = bezt->vec[1][1] - dst->vec[1][1]; + + /* just apply delta value change to the handle values */ + dst->vec[0][1] += dy; + dst->vec[1][1] += dy; + dst->vec[2][1] += dy; + + dst->f1 = bezt->f1; + dst->f2 = bezt->f2; + dst->f3 = bezt->f3; + + /* TODO: perform some other operations? */ + } } } /* keyframing modes allow to not replace keyframe */ diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 390233a433d..3d0d6b820d7 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -793,6 +793,9 @@ typedef enum eInsertKeyFlags { 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_NO_USERPREF = (1 << 6), /* ignore user-prefs (needed for predictable API use) */ + /* Allow to make a full copy of new key into existing one, if any, instead of 'reusing' existing handles. + * Used by copy/paste code. */ + INSERTKEY_OVERWRITE_FULL = (1<<7), } eInsertKeyFlags; /* ************************************************ */ |