Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/extern
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-12-24 04:20:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-12-24 04:20:34 +0300
commitaf2be110c31e9cd71a07fbea516c6bf14fa26179 (patch)
treef9c0529fab6533ca7f40f520bd78882cf61d8fc9 /extern
parentb450ba84d9dd51fe0e91fc848c312c7e92fcd176 (diff)
Fix T72402: Decimate f-curves fails with co-linear key-frames
Diffstat (limited to 'extern')
-rw-r--r--extern/curve_fit_nd/intern/curve_fit_cubic.c17
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;
}