diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-07 12:45:22 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-07 13:12:27 +0200 |
commit | 7f18b823af6998b18e041fc01ef2d5ee3c189056 (patch) | |
tree | a592a007bcb186a67bfc11c9913ec4183e286e96 | |
parent | 74c317a64c4aa152f1ba988d3e5d4d48d4a8e33e (diff) |
qfc: use float intermediates, and consistently
-rw-r--r-- | qfunctionconfigurator/functionconfig.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index e75e99b0..6d1a48b4 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -98,25 +98,28 @@ void Map::reload() { QPointF p1 = ensureInBounds(input, i); QPointF p2 = ensureInBounds(input, i + 1); QPointF p3 = ensureInBounds(input, i + 2); + + const float p0_x = p0.x(), p1_x = p1.x(), p2_x = p2.x(), p3_x = p3.x(); + const float p0_y = p0.y(), p1_y = p1.y(), p2_y = p2.y(), p3_y = p3.y(); int end = std::min<int>(sz, p2.x() * mult); int start = p1.x() * mult; for (int j = start; j < end; j++) { - double t = (j - start) / (double) (end - start); - double t2 = t*t; - double t3 = t*t*t; - - int x = .5 * ((2. * p1.x()) + - (-p0.x() + p2.x()) * t + - (2. * p0.x() - 5. * p1.x() + 4. * p2.x() - p3.x()) * t2 + - (-p0.x() + 3. * p1.x() - 3. * p2.x() + p3.x()) * t3) + float t = (j - start) / (float) (end - start); + float t2 = t*t; + float t3 = t*t*t; + + int x = .5 * ((2. * p1_x) + + (-p0_x + p2_x) * t + + (2. * p0_x - 5. * p1_x + 4. * p2_x - p3_x) * t2 + + (-p0_x + 3. * p1_x - 3. * p2_x + p3_x) * t3) * mult; - float y = .5 * ((2. * p1.y()) + - (-p0.y() + p2.y()) * t + - (2. * p0.y() - 5. * p1.y() + 4. * p2.y() - p3.y()) * t2 + - (-p0.y() + 3. * p1.y() - 3. * p2.y() + p3.y()) * t3); + float y = .5 * ((2. * p1_y) + + (-p0_y + p2_y) * t + + (2. * p0_y - 5. * p1_y + 4. * p2_y - p3_y) * t2 + + (-p0_y + 3. * p1_y - 3. * p2_y + p3_y) * t3); if (x >= 0 && x < sz) data[x] = y; @@ -126,7 +129,7 @@ void Map::reload() { float last = 0; for (int i = 0; i < sz; i++) { - if (data[i] <= 0) + if (data[i] < 0) data[i] = last; last = data[i]; } |