summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-09 17:14:02 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-10 03:18:58 +0100
commit7d101a1c2827b5e7a373fb0d0a68099fb692e55a (patch)
tree3489a2988806a02a9ef31760116de104f94582c6
parent674c8a9f1a42b36940551a6ebaf953ad96d379d0 (diff)
many: spring cleanup
-rw-r--r--cmake/opentrack-platform.cmake2
-rw-r--r--compat/macros.hpp10
-rw-r--r--compat/simple-mat.hpp57
-rw-r--r--cv/numeric.hpp8
-rw-r--r--ext-falcon-bms-linear-acc/falcon-bms-metadata.cpp2
-rw-r--r--filter-ewma2/ftnoir_filter_ewma2_dialog.cpp6
-rw-r--r--logic/shortcuts.cpp3
-rw-r--r--logic/win32-shortcuts.cpp5
-rw-r--r--logic/win32-shortcuts.h6
-rw-r--r--pose-widget/export.hpp11
-rw-r--r--pose-widget/pose-widget.cpp10
-rw-r--r--pose-widget/pose-widget.hpp13
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.cpp7
13 files changed, 69 insertions, 71 deletions
diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake
index 4aa4d49e..f927a9ea 100644
--- a/cmake/opentrack-platform.cmake
+++ b/cmake/opentrack-platform.cmake
@@ -68,7 +68,7 @@ if(MSVC)
if(NOT CMAKE_COMPILER_IS_CLANG)
if(MSVC_VERSION GREATER 1909) # visual studio 2017
- set(__stuff "-permissive- -Qvec-report:1")
+ set(__stuff "-permissive-")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__stuff}")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${__stuff}")
endif()
diff --git a/compat/macros.hpp b/compat/macros.hpp
index 8f807bf0..ed0bd8da 100644
--- a/compat/macros.hpp
+++ b/compat/macros.hpp
@@ -45,18 +45,24 @@
#ifdef Q_CREATOR_RUN
# define warn_result_unused
-#elif defined(_MSC_VER)
+#elif defined _MSC_VER
# define warn_result_unused _Check_return_
#else
# define warn_result_unused __attribute__((warn_unused_result))
#endif
-#if defined(__GNUG__)
+#if defined __GNUG__
# define unused(t, i) t __attribute__((unused)) i
#else
# define unused(t, i) t
#endif
+#if defined _MSC_VER
+# define aligned_struct(x) struct __declspec(align(x))
+#else
+# define aligned_struct(x) struct __attribute__((__aligned__(x)))
+#endif
+
#if defined __GNUC__
# define likely(x) __builtin_expect(!!(x),1)
# define unlikely(x) __builtin_expect(!!(x),0)
diff --git a/compat/simple-mat.hpp b/compat/simple-mat.hpp
index a806448b..c8c9f48b 100644
--- a/compat/simple-mat.hpp
+++ b/compat/simple-mat.hpp
@@ -21,11 +21,18 @@ namespace simple_mat_detail {
{
enum { value = i == j };
};
- template<int i, int j, int min>
+ template<int i, int j, int min, int max>
struct maybe_add_swizzle
{
- enum { value = (i == 1 || j == 1) && (i >= min || j >= min) };
+ enum { value = (i == 1 || j == 1) && (i >= min || j >= min) && (i <= max || j <= max) };
};
+
+ template<int j, int i>
+ struct is_vector
+ {
+ enum { value = j == 1 || i == 1 };
+ };
+
template<int i1, int j1, int i2, int j2>
struct is_vector_pair
{
@@ -58,18 +65,6 @@ class Mat
public:
template<int Q = w_> std::enable_if_t<equals<Q, 1, 0>::value, num>
- constexpr inline operator()(int i) const& { return data[i][0]; }
-
- template<int P = h_> std::enable_if_t<equals<P, 1, 1>::value, num>
- constexpr inline operator()(int i) const& { return data[0][i]; }
-
- template<int Q = w_> std::enable_if_t<equals<Q, 1, 2>::value, num&>
- constexpr inline operator()(int i) & { return data[i][0]; }
-
- template<int P = h_> std::enable_if_t<equals<P, 1, 3>::value, num&>
- constexpr inline operator()(int i) & { return data[0][i]; }
-
- template<int Q = w_> std::enable_if_t<equals<Q, 1, 0>::value, num>
constexpr inline operator()(unsigned i) const& { return data[i][0]; }
template<int P = h_> std::enable_if_t<equals<P, 1, 1>::value, num>
@@ -83,35 +78,37 @@ public:
#define OPENTRACK_ASSERT_SWIZZLE static_assert(P == h_ && Q == w_, "")
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 1>::value, num>
+ // const variants
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 1, 4>::value, num>
constexpr inline x() const& { OPENTRACK_ASSERT_SWIZZLE; return operator()(0); }
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 2>::value, num>
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 2, 4>::value, num>
constexpr inline y() const& { OPENTRACK_ASSERT_SWIZZLE; return operator()(1); }
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 3>::value, num>
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 3, 4>::value, num>
constexpr inline z() const& { OPENTRACK_ASSERT_SWIZZLE; return operator()(2); }
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 4>::value, num>
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 4, 4>::value, num>
constexpr inline w() const& { OPENTRACK_ASSERT_SWIZZLE; return operator()(3); }
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 1>::value, num&>
+ // mutable variants
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 1, 4>::value, num&>
constexpr inline x() & { OPENTRACK_ASSERT_SWIZZLE; return operator()(0); }
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 2>::value, num&>
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 2, 4>::value, num&>
constexpr inline y() & { OPENTRACK_ASSERT_SWIZZLE; return operator()(1); }
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 3>::value, num&>
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 3, 4>::value, num&>
constexpr inline z() & { OPENTRACK_ASSERT_SWIZZLE; return operator()(2); }
- template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 4>::value, num&>
+ template<int P = h_, int Q = w_> std::enable_if_t<maybe_add_swizzle<P, Q, 4, 4>::value, num&>
constexpr inline w() & { OPENTRACK_ASSERT_SWIZZLE; return operator()(3); }
// parameters w_ and h_ are rebound so that SFINAE occurs
// removing them causes a compile-time error -sh 20150811
- template<int R, int S, int P = h_, int Q = w_>
- std::enable_if_t<is_vector_pair<R, S, P, Q>::value, num>
+ template<int P = h_, int Q = w_>
+ std::enable_if_t<is_vector<P, Q>::value, num>
norm() const
{
static_assert(P == h_ && Q == w_, "");
@@ -167,7 +164,7 @@ public:
return ret;
}
- constexpr Mat<num, h_, w_> operator+(const num& other) const
+ constexpr Mat<num, h_, w_> operator+(const num other) const
{
Mat<num, h_, w_> ret;
for (int j = 0; j < h_; j++)
@@ -176,7 +173,7 @@ public:
return ret;
}
- constexpr Mat<num, h_, w_> operator-(const num& other) const
+ constexpr Mat<num, h_, w_> operator-(const num other) const
{
Mat<num, h_, w_> ret;
for (int j = 0; j < h_; j++)
@@ -210,11 +207,11 @@ public:
return ret;
}
- constexpr inline num operator()(int j, int i) const& { return data[j][i]; }
- constexpr inline num& operator()(int j, int i) & { return data[j][i]; }
+ template<typename t, typename u>
+ constexpr inline num operator()(t j, u i) const& { return data[(int) j][(int) i]; }
- constexpr inline num operator()(unsigned j, unsigned i) const& { return data[j][i]; }
- constexpr inline num& operator()(unsigned j, unsigned i) & { return data[j][i]; }
+ template<typename t, typename u>
+ constexpr inline num& operator()(t j, u i) & { return data[(int) j][(int) i]; }
#ifdef __GNUG__
# pragma GCC diagnostic push
diff --git a/cv/numeric.hpp b/cv/numeric.hpp
index 4761af1d..27287c1e 100644
--- a/cv/numeric.hpp
+++ b/cv/numeric.hpp
@@ -6,11 +6,9 @@
namespace types {
using f = double;
- struct constants final
- {
- constants() = delete;
- static constexpr f eps = f(1e-8);
- };
+ namespace constants {
+ static constexpr inline f eps = f(1e-8);
+ }
template<int n> using vec = cv::Vec<f, n>;
using vec2 = vec<2>;
diff --git a/ext-falcon-bms-linear-acc/falcon-bms-metadata.cpp b/ext-falcon-bms-linear-acc/falcon-bms-metadata.cpp
index fca82018..0ab80109 100644
--- a/ext-falcon-bms-linear-acc/falcon-bms-metadata.cpp
+++ b/ext-falcon-bms-linear-acc/falcon-bms-metadata.cpp
@@ -2,7 +2,7 @@
QString falcon_bms_acceleration_metadata::name()
{
- return QStringLiteral("Falcon BMS linaer acceleration display");
+ return "Falcon BMS linaer acceleration display"_qstr;
}
QIcon falcon_bms_acceleration_metadata::icon()
diff --git a/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp b/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
index da572ce4..966473cf 100644
--- a/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
+++ b/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
@@ -20,13 +20,13 @@ dialog_ewma::dialog_ewma()
tie_setting(s.kSmoothingScaleCurve, ui.powCurve);
tie_setting(s.kSmoothingScaleCurve, ui.curve_label,
- [](auto& x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2); });
+ [](double x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2); });
tie_setting(s.kMinSmoothing, ui.min_label,
- [](auto& x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2);});
+ [](double x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2);});
tie_setting(s.kMaxSmoothing, ui.max_label,
- [](auto& x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2);});
+ [](double x) { return QStringLiteral("%1%").arg(x * 100, 0, 'f', 2);});
connect(ui.minSmooth, &QSlider::valueChanged, this,
[&](int v) -> void { if (ui.maxSmooth->value() < v) ui.maxSmooth->setValue(v); });
diff --git a/logic/shortcuts.cpp b/logic/shortcuts.cpp
index 125d051f..c72ed690 100644
--- a/logic/shortcuts.cpp
+++ b/logic/shortcuts.cpp
@@ -8,6 +8,7 @@
#include "shortcuts.h"
#include "win32-shortcuts.h"
+#include "compat/string-literal-operator.hpp"
#include <QString>
@@ -72,7 +73,7 @@ void Shortcuts::bind_shortcut(K &key, const key_opts& k, bool held)
if (code != Qt::Key_unknown)
win_key::from_qt(code, idx, mods);
- key.guid = QStringLiteral("");
+ key.guid = ""_qstr;
key.keycode = idx;
key.held = held;
key.ctrl = !!(mods & Qt::ControlModifier);
diff --git a/logic/win32-shortcuts.cpp b/logic/win32-shortcuts.cpp
index 901d2c0a..2099ce09 100644
--- a/logic/win32-shortcuts.cpp
+++ b/logic/win32-shortcuts.cpp
@@ -12,11 +12,10 @@
# include <dinput.h>
#include "win32-shortcuts.h"
-#include <QList>
#include <QVariant>
#include <QDebug>
-QList<win_key> windows_key_mods {
+win_key const windows_key_mods[] {
{DIK_LCONTROL, Qt::Key_Control},
{DIK_RCONTROL, Qt::Key_Control},
{DIK_LALT, Qt::Key_Alt},
@@ -27,7 +26,7 @@ QList<win_key> windows_key_mods {
{DIK_RWIN, Qt::Key_Super_R},
};
-QList<win_key> windows_key_sequences {
+static const win_key windows_key_sequences[] {
{ DIK_F1, Qt::Key_F1 },
{ DIK_F2, Qt::Key_F2 },
{ DIK_F3, Qt::Key_F3 },
diff --git a/logic/win32-shortcuts.h b/logic/win32-shortcuts.h
index 4e32c9ea..8cd6bdc9 100644
--- a/logic/win32-shortcuts.h
+++ b/logic/win32-shortcuts.h
@@ -2,14 +2,10 @@
#ifdef _WIN32
+#include <Qt>
#include <QKeySequence>
#include "shortcuts.h"
-struct win_key;
-
-extern QList<win_key> windows_key_mods;
-extern QList<win_key> windows_key_sequences;
-
#include "export.hpp"
struct OTR_LOGIC_EXPORT win_key
diff --git a/pose-widget/export.hpp b/pose-widget/export.hpp
new file mode 100644
index 00000000..bfe55138
--- /dev/null
+++ b/pose-widget/export.hpp
@@ -0,0 +1,11 @@
+// generates export.hpp for each module from compat/linkage.hpp
+
+#pragma once
+
+#include "compat/linkage-macros.hpp"
+
+#ifdef BUILD_POSE_WIDGET
+# define OTR_POSE_WIDGET_EXPORT OTR_GENERIC_EXPORT
+#else
+# define OTR_POSE_WIDGET_EXPORT OTR_GENERIC_IMPORT
+#endif
diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp
index 50606c00..c25ad3eb 100644
--- a/pose-widget/pose-widget.cpp
+++ b/pose-widget/pose-widget.cpp
@@ -12,13 +12,15 @@
#include "compat/check-visible.hpp"
#include <cmath>
#include <algorithm>
+
#include <QPainter>
#include <QPaintEvent>
-#include <QPalette>
-#include <QGroupBox>
#include <QDebug>
+// XXX this needs rewriting in terms of scanline rendering -sh 20180105
+// see: <https://mikro.naprvyraz.sk/docs/Coding/2/TEXTURE4.TXT>
+
using namespace pose_widget_impl;
pose_transform::pose_transform(QWidget* dst) :
@@ -279,8 +281,8 @@ void pose_transform::project_quad_texture()
const unsigned orig_pitch = tex.bytesPerLine();
const unsigned dest_pitch = image.bytesPerLine();
- unsigned char const* const restrict_ptr orig = tex.constBits();
- unsigned char* const restrict_ptr dest = image.bits();
+ unsigned char const* restrict_ptr orig = tex.constBits();
+ unsigned char* restrict_ptr dest = image.bits();
const int orig_depth = tex.depth() / 8;
const int dest_depth = image.depth() / 8;
diff --git a/pose-widget/pose-widget.hpp b/pose-widget/pose-widget.hpp
index cdbcdeb8..9b280afc 100644
--- a/pose-widget/pose-widget.hpp
+++ b/pose-widget/pose-widget.hpp
@@ -10,21 +10,16 @@
#include "api/plugin-api.hpp"
#include "compat/euler.hpp"
+#include "export.hpp"
+
#include <tuple>
#include <mutex>
#include <atomic>
#include <vector>
-#include <QtGlobal>
#include <QWidget>
#include <QThread>
-#include <QPixmap>
-
-#ifdef BUILD_POSE_WIDGET
-# define POSE_WIDGET_EXPORT Q_DECL_EXPORT
-#else
-# define POSE_WIDGET_EXPORT Q_DECL_IMPORT
-#endif
+#include <QImage>
namespace pose_widget_impl {
@@ -94,7 +89,7 @@ struct pose_transform final : QThread
static constexpr int w = 320, h = 240;
};
-class POSE_WIDGET_EXPORT pose_widget final : public QWidget
+class OTR_POSE_WIDGET_EXPORT pose_widget final : public QWidget
{
public:
pose_widget(QWidget *parent = nullptr);
diff --git a/tracker-pt/ftnoir_tracker_pt_settings.cpp b/tracker-pt/ftnoir_tracker_pt_settings.cpp
deleted file mode 100644
index 234c4d74..00000000
--- a/tracker-pt/ftnoir_tracker_pt_settings.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "cv/numeric.hpp"
-
-namespace types {
-
-constexpr f constants::eps;
-
-}