summaryrefslogtreecommitdiffhomepage
path: root/spline
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-06-15 10:18:47 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-06-18 18:48:42 +0200
commitd405b91787ecb332d4ecb8740c06ca84f7e8a6b3 (patch)
tree59c74789c3885b547b4818d3b7ac3a99f7bab56c /spline
parent9e58b8d50f4914e79c8165c71ab43eb6ce335173 (diff)
spline: workaround going over the max value
Diffstat (limited to 'spline')
-rw-r--r--spline/spline.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 1fb38014..624ab883 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -146,8 +146,11 @@ float spline::get_value_internal(int x)
const float sign = signum(x);
x = std::abs(x);
- const float ret = data[std::min(unsigned(x), unsigned(value_count)-1u)];
- return sign * std::fmax(0, ret);
+ const float ret_ = data[std::min(unsigned(x), unsigned(value_count)-1u)];
+ float ret = sign * std::fmax(0, ret_);
+ if (max_y > 0)
+ ret = fmin(max_y, ret);
+ return ret;
}
void spline::add_lone_point()