From b3f20eed6e85249d15724543743cb049e7991622 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 28 Nov 2020 14:44:10 +0300 Subject: Fix T83023: incorrect shape of cyclic F-Curve with only two points. The equation solver didn't handle the one unknown case correctly. --- source/blender/blenlib/intern/math_solvers.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source/blender/blenlib/intern') 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); } -- cgit v1.2.3