diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-09-29 15:53:06 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2021-09-29 15:54:05 +0200 |
commit | f18067ff83e8989f80c7f521c40e6fcb5fa8b451 (patch) | |
tree | 95195af79926dc3164fb3f07f52ceebcdd634b33 /spline | |
parent | 81e74c714f68d646009397ae7dca0bd3e7cd3fe5 (diff) |
spline: make sure zeros stay zeros
Issue: #1341
Diffstat (limited to 'spline')
-rw-r--r-- | spline/spline.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spline/spline.cpp b/spline/spline.cpp index 917300c2..7017c93e 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -249,6 +249,17 @@ void spline::update_interp_data() const last = data[i]; } + // make sure empty places stay empty (see #1341) + if (auto it = std::find_if(list.cbegin(), list.cend(), + [](QPointF x) { return x.x() >= 1e-6 && x.y() >= 1e-6; }); + it != list.cend() && it != list.cbegin()) + { + it--; + unsigned max = std::clamp((unsigned)iround(it->x() * c), 0u, value_count-1); + + for (unsigned x = 0; x < max; x++) + data[x] = 0; + } #ifdef __clang__ # pragma clang diagnostic pop #endif |