Fix: Return back to conventional way of averaging points for keyframe de-dup

The other approach was causing too much error in some cases (e.g. favouring
the lower-valued keyframes). This fix should make the resulting curves less
bumpy/jagged.
This commit is contained in:
Joshua Leung 2018-02-22 00:44:03 +13:00
parent 915d120c36
commit cab608066a
1 changed files with 7 additions and 1 deletions

View File

@ -3548,7 +3548,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
/* If there's another selected frame here, merge it */
for (tRetainedKeyframe *rk = retained_keys.last; rk; rk = rk->prev) {
if (IS_EQT(rk->frame, bezt->vec[1][0], BEZT_BINARYSEARCH_THRESH)) {
rk->val += (bezt->vec[1][1] - rk->val) / ((float)rk->tot_count);
rk->val += bezt->vec[1][1];
rk->tot_count++;
found = true;
@ -3580,6 +3580,12 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
}
return;
}
else {
/* Compute the average values for each retained keyframe */
for (tRetainedKeyframe *rk = retained_keys.first; rk; rk = rk->next) {
rk->val = rk->val / (float)rk->tot_count;
}
}
/* 2) Delete all keyframes duplicating the "retained keys" found above
* - Most of these will be unselected keyframes