diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-12-24 04:20:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-12-24 04:20:34 +0300 |
commit | af2be110c31e9cd71a07fbea516c6bf14fa26179 (patch) | |
tree | f9c0529fab6533ca7f40f520bd78882cf61d8fc9 /extern/curve_fit_nd/intern | |
parent | b450ba84d9dd51fe0e91fc848c312c7e92fcd176 (diff) |
Fix T72402: Decimate f-curves fails with co-linear key-frames
Diffstat (limited to 'extern/curve_fit_nd/intern')
-rw-r--r-- | extern/curve_fit_nd/intern/curve_fit_cubic.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/extern/curve_fit_nd/intern/curve_fit_cubic.c b/extern/curve_fit_nd/intern/curve_fit_cubic.c index 0005cbe5a93..47c5344c821 100644 --- a/extern/curve_fit_nd/intern/curve_fit_cubic.c +++ b/extern/curve_fit_nd/intern/curve_fit_cubic.c @@ -611,13 +611,26 @@ static void cubic_from_points_offset_fallback( } } + /* The value of 'dists[..] / 0.75' is the length to use when the tangents + * are perpendicular to the direction defined by the two points. + * + * Project tangents onto these perpendicular lengths. + * Note that this can cause divide by zero in the case of co-linear tangents. + * The limits check afterwards accounts for this. + * + * The 'dists[..] + dir_dirs' limit is just a rough approximation. + * While a more exact value could be calculated, + * in this case the error values approach divide by zero (inf) + * so there is no need to be too precise when checking if limits have been exceeded. */ + double alpha_l = (dists[0] / 0.75) / fabs(dot_vnvn(tan_l, a[0], dims)); double alpha_r = (dists[1] / 0.75) / fabs(dot_vnvn(tan_r, a[1], dims)); - if (!(alpha_l > 0.0)) { + + if (!(alpha_l > 0.0) || (alpha_l > dists[0] + dir_dist)) { alpha_l = dir_dist / 3.0; } - if (!(alpha_r > 0.0)) { + if (!(alpha_r > 0.0) || (alpha_r > dists[1] + dir_dist)) { alpha_r = dir_dist / 3.0; } |