Commit: 6891f1c9e05bd67eb98c37fb05157775590e6eac
Author: Bastien Montagne
Date:   Tue Aug 26 19:30:38 2014 +0200
Branches: master
https://developer.blender.org/rB6891f1c9e05bd67eb98c37fb05157775590e6eac

Fix T41266: Copy and paste operation on f-curves do not respect keyframe 
tangent handles...

Added an extra option to `insert_bezt_fcurve()`, to allow full override of 
existing
keyframes when pasting (in this case, we do not want to inherit handles from 
existing
curve!).

===================================================================

M       source/blender/editors/animation/keyframes_general.c
M       source/blender/editors/animation/keyframing.c
M       source/blender/makesdna/DNA_anim_types.h

===================================================================

diff --git a/source/blender/editors/animation/keyframes_general.c 
b/source/blender/editors/animation/keyframes_general.c
index 8f5510a..56165c3 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 a68751e..4c2d901 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 390233a..3d0d6b8 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;
 
 /* ************************************************ */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to