summaryrefslogtreecommitdiffhomepage
path: root/qfunctionconfigurator/functionconfig.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-26 10:53:33 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-26 10:57:52 +0200
commitff290993484e6708ec57fbc4c4d4eeaaae379c4f (patch)
tree04e77efa8abca30792d92b69c77cf6030c3848b9 /qfunctionconfigurator/functionconfig.h
parentb34bb2dc35e2d11bd6473a75356a49303bbeb556 (diff)
qfc: use integers as storage, not floats
Float mantissa has 23 bits. 9 bits get wasted per value. Instead, use uint16_t that doesn't lose much precision, but saves half the space.
Diffstat (limited to 'qfunctionconfigurator/functionconfig.h')
-rw-r--r--qfunctionconfigurator/functionconfig.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h
index 446c73ac..68ec2869 100644
--- a/qfunctionconfigurator/functionconfig.h
+++ b/qfunctionconfigurator/functionconfig.h
@@ -14,16 +14,19 @@
#include <QSettings>
#include <QMutex>
#include <vector>
+#include <limits>
#include "opentrack-compat/qcopyable-mutex.hpp"
class Map {
private:
static constexpr int value_count = 5000;
using num = float;
+ using integral = std::uint16_t;
+ static constexpr integral integral_max = std::numeric_limits<integral>::max();
struct State {
QList<QPointF> input;
- std::vector<num> data;
+ std::vector<integral> data;
};
int precision() const;
@@ -45,6 +48,7 @@ public:
{
setMaxInput(maxx);
setMaxOutput(maxy);
+ reload();
}
num getValue(num x);