[Bf-blender-cvs] [af2be110c31] master: Fix T72402: Decimate f-curves fails with co-linear key-frames

Campbell Barton noreply at git.blender.org
Tue Dec 24 02:34:12 CET 2019


Commit: af2be110c31e9cd71a07fbea516c6bf14fa26179
Author: Campbell Barton
Date:   Tue Dec 24 12:20:34 2019 +1100
Branches: master
https://developer.blender.org/rBaf2be110c31e9cd71a07fbea516c6bf14fa26179

Fix T72402: Decimate f-curves fails with co-linear key-frames

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

M	extern/curve_fit_nd/intern/curve_fit_cubic.c

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

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;
 	}



More information about the Bf-blender-cvs mailing list