Tweak/Fix for T54106 - Moving multiple selected keyframes on top of an unselected...
authorJoshua Leung <aligorith@gmail.com>
Wed, 21 Feb 2018 06:14:33 +0000 (19:14 +1300)
committerJoshua Leung <aligorith@gmail.com>
Wed, 21 Feb 2018 12:46:09 +0000 (01:46 +1300)
This commit removes an earlier attempt at optimising the lookups
for duplicates of a particular tRetainedKeyframe once we'd already
deleted all the selected copies. The problem was that now, instead
of getting rid of the unselected keys (i.e. the basic function here),
we were only getting rid of the selected duplicates.

With this fix, unselected keyframes will now get removed (as expected)
again. However, we currently don't take their values into account
when merging keyframes, since it is assumed that we don't care so much
about their values when overriding.

source/blender/editors/transform/transform_conversions.c

index 3693c3e40fb01cd9fb548d69c8761c52a387a8fa..35fa373854a790f514a4c32acc40b5b1f2f25da5 100644 (file)
@@ -3529,7 +3529,6 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
 {
        /* NOTE: We assume that all keys are sorted */
        ListBase retained_keys = {NULL, NULL};
-       tRetainedKeyframe *last_rk = NULL;
        
        /* sanity checks */
        if ((fcu->totvert == 0) || (fcu->bezt == NULL))
@@ -3587,9 +3586,6 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
                        printf("   %d: f = %f, v = %f (n = %d)\n", rk_index, rk->frame, rk->val, rk->tot_count);
                        rk_index++;
                }
-               
-               /* "last_rk" is the last one we need to search (assuming everything is sorted) */
-               last_rk = retained_keys.last;
        }
        
        /* 2) Delete all keyframes duplicating the "retained keys" found above
@@ -3602,8 +3598,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
                
                /* Is this a candidate for deletion? */
                // TODO: Replace loop with an O(1) lookup instead
-               // TODO: update last_rk on each deletion
-               for (tRetainedKeyframe *rk = last_rk; rk; rk = rk->prev) {
+               for (tRetainedKeyframe *rk = retained_keys.last; rk; rk = rk->prev) {
                        if (IS_EQT(bezt->vec[1][0], rk->frame, BEZT_BINARYSEARCH_THRESH)) {
                                /* Delete this keyframe, unless it's the last selected one on this frame,
                                 * in which case, we'll update its value instead
@@ -3612,9 +3607,6 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
                                        /* Update keyframe */
                                        // XXX: update handles too...
                                        bezt->vec[1][1] = rk->val;
-                                       
-                                       /* Adjust last_rk, since we don't need to use this one anymore */
-                                       last_rk = rk->prev;
                                }
                                else {
                                        /* Delete keyframe */
@@ -3625,10 +3617,6 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
                                rk->del_count++;
                                break;
                        }
-                       else if (rk->frame < bezt->vec[1][0]) {
-                               /* Terminate search early - There shouldn't be anything */
-                               break;
-                       }
                }
        }