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
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2020-11-28 14:44:10 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-11-28 15:54:17 +0300
commitb3f20eed6e85249d15724543743cb049e7991622 (patch)
tree1caf4ba3281419cabcee09eb1daf35b7af0b7889 /source/blender/blenlib/intern/math_solvers.c
parentf8553de2cdc66ca2744aebffe0f9d55b29787b92 (diff)
Fix T83023: incorrect shape of cyclic F-Curve with only two points.
The equation solver didn't handle the one unknown case correctly.
Diffstat (limited to 'source/blender/blenlib/intern/math_solvers.c')
-rw-r--r--source/blender/blenlib/intern/math_solvers.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/math_solvers.c b/source/blender/blenlib/intern/math_solvers.c
index cda3d9b66a2..e366d834fc4 100644
--- a/source/blender/blenlib/intern/math_solvers.c
+++ b/source/blender/blenlib/intern/math_solvers.c
@@ -137,9 +137,24 @@ bool BLI_tridiagonal_solve_cyclic(
return false;
}
+ /* Degenerate case not handled correctly by the generic formula. */
+ if (count == 1) {
+ r_x[0] = d[0] / (a[0] + b[0] + c[0]);
+
+ return isfinite(r_x[0]);
+ }
+
+ /* Degenerate case that works but can be simplified. */
+ if (count == 2) {
+ float a2[2] = {0, a[1] + c[1]};
+ float c2[2] = {a[0] + c[0], 0};
+
+ return BLI_tridiagonal_solve(a2, b, c2, d, r_x, count);
+ }
+
+ /* If not really cyclic, fall back to the simple solver. */
float a0 = a[0], cN = c[count - 1];
- /* if not really cyclic, fall back to the simple solver */
if (a0 == 0.0f && cN == 0.0f) {
return BLI_tridiagonal_solve(a, b, c, d, r_x, count);
}