diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-06 08:05:57 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-06 08:11:01 +0100 |
commit | 3fd39cf892250545b4510065fe16e39d494faa44 (patch) | |
tree | 7f52c9a4a5257778cdd8cb3c46e038a368eb2768 | |
parent | 94600f2c5f234dddf826c9d6d9db91952832220a (diff) |
cruft only
-rw-r--r-- | cmake/opentrack-boilerplate.cmake | 13 | ||||
-rw-r--r-- | cmake/opentrack-platform.cmake | 1 | ||||
-rw-r--r-- | compat/macros.hpp | 5 | ||||
-rw-r--r-- | dinput/keybinding-worker.cpp | 14 | ||||
-rw-r--r-- | dinput/keybinding-worker.hpp | 2 | ||||
-rw-r--r-- | dinput/win32-joystick.cpp | 47 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 10 | ||||
-rw-r--r-- | installer/opentrack-installer.iss | 4 | ||||
-rw-r--r-- | logic/main-settings.cpp | 59 | ||||
-rw-r--r-- | logic/main-settings.hpp | 77 | ||||
-rw-r--r-- | logic/pipeline.cpp | 83 | ||||
-rw-r--r-- | logic/pipeline.hpp | 2 | ||||
-rw-r--r-- | spline/spline.cpp | 22 | ||||
-rw-r--r-- | tracker-pt/module/point_extractor.cpp | 2 | ||||
-rw-r--r-- | tracker-rs/ftnoir_tracker_rs_worker.cpp | 1 | ||||
-rw-r--r-- | tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp | 2 | ||||
-rw-r--r-- | tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h | 15 | ||||
-rw-r--r-- | tracker-udp/ftnoir_tracker_udp.cpp | 20 | ||||
-rw-r--r-- | tracker-wii/wiiyourself/wiimote.h | 1 |
19 files changed, 160 insertions, 220 deletions
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 84bd3a03..68017422 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -150,6 +150,12 @@ function(otr_module n_) set(arg_NO-COMPAT TRUE) endif() + if(NOT arg_NO-QT) + set_property(SOURCE ${${n}-moc} ${${n}-uih} PROPERTY GENERATED TRUE) + add_custom_target(moc-${n} DEPENDS ${${n}-moc} ${${n}-uih} ${${n}-rc} COMMENT "") + add_dependencies(moc "moc-${n}") + endif() + if(NOT WIN32) set(subsys "") elseif(arg_WIN32-CONSOLE) @@ -169,10 +175,6 @@ function(otr_module n_) set_property(TARGET "${n}" PROPERTY PREFIX "") endif() - set_property(SOURCE ${${n}-moc} ${${n}-uih} PROPERTY GENERATED TRUE) - add_custom_target(moc-${n} DEPENDS ${${n}-moc} ${${n}-uih} ${${n}-rc} COMMENT "") - add_dependencies(moc "moc-${n}") - if(NOT arg_RELINK) set_property(TARGET ${n} PROPERTY LINK_DEPENDS_NO_SHARED TRUE) else() @@ -201,6 +203,8 @@ function(otr_module n_) set(arg_NO-INSTALL TRUE) endif() + otr_compat(${n}) + if(NOT arg_NO-INSTALL) if(arg_BIN AND WIN32) install(TARGETS "${n}" RUNTIME DESTINATION . PERMISSIONS ${opentrack-perms-exec}) @@ -215,7 +219,6 @@ function(otr_module n_) endif() endif() - otr_compat(${n}) if(NOT arg_NO-QT) otr_i18n_for_target_directory(${n_}) endif() diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake index 4b7cde09..0cdb1d57 100644 --- a/cmake/opentrack-platform.cmake +++ b/cmake/opentrack-platform.cmake @@ -73,6 +73,7 @@ if(MSVC) add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) add_definitions(-D_SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING) add_definitions(-D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING) + add_definitions(-DWIN32_LEAN_AND_MEAN) set(__stuff "-permissive- -diagnostics:caret") set(CMAKE_CXX_FLAGS "${__stuff} ${CMAKE_CXX_FLAGS}") diff --git a/compat/macros.hpp b/compat/macros.hpp index 5d82c4ee..5b959011 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -93,11 +93,6 @@ constexpr cc_forceinline void static_warn<true>() {} #define typed_progn(type, ...) ([&]() -> type { __VA_ARGS__ }()) #define progn(...) ([&]() -> decltype(auto) { __VA_ARGS__ }()) -#define prog1(x, ...) ([&]() -> decltype(auto) \ - { \ - decltype(auto) ret1324 = (x); __VA_ARGS__; return ret1324; \ - }()) - // end c++-only macros #endif diff --git a/dinput/keybinding-worker.cpp b/dinput/keybinding-worker.cpp index a3331323..aa8faca8 100644 --- a/dinput/keybinding-worker.cpp +++ b/dinput/keybinding-worker.cpp @@ -48,12 +48,12 @@ bool KeybindingWorker::init() } if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, nullptr) != DI_OK) { - qDebug() << "setup CreateDevice function failed!" << GetLastError(); + qDebug() << "dinput: create keyboard failed" << GetLastError(); return false; } if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { - qDebug() << "setup SetDataFormat function failed!" << GetLastError(); + qDebug() << "dinput: keyboard SetDataFormat" << GetLastError(); dinkeyboard->Release(); dinkeyboard = nullptr; return false; @@ -62,20 +62,20 @@ bool KeybindingWorker::init() if (dinkeyboard->SetCooperativeLevel((HWND) fake_main_window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { dinkeyboard->Release(); dinkeyboard = nullptr; - qDebug() << "setup SetCooperativeLevel function failed!" << GetLastError(); + qDebug() << "dinput: keyboard SetCooperativeLevel" << GetLastError(); return false; } { DIPROPDWORD dipdw; - dipdw.dwData = 128; + dipdw.dwData = num_keyboard_states; dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); dipdw.diph.dwHow = DIPH_DEVICE; dipdw.diph.dwObj = 0; dipdw.diph.dwSize = sizeof(dipdw); if ( dinkeyboard->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph) != DI_OK) { - qDebug() << "setup keyboard buffer mode failed!"; + qDebug() << "dinput: DIPROP_BUFFERSIZE"; dinkeyboard->Release(); dinkeyboard = nullptr; return false; @@ -86,7 +86,7 @@ bool KeybindingWorker::init() { dinkeyboard->Release(); dinkeyboard = nullptr; - qDebug() << "setup dinkeyboard Acquire failed!" << GetLastError(); + qDebug() << "dinput: acquire keyboard failed" << GetLastError(); return false; } @@ -147,7 +147,7 @@ bool KeybindingWorker::run_keyboard_nolock() if (hr != DI_OK) { - eval_once(qDebug() << "dinput: keyboard GetDeviceData failed" << hr); + eval_once(qDebug() << "dinput: keyboard GetDeviceData" << hr); return false; } diff --git a/dinput/keybinding-worker.hpp b/dinput/keybinding-worker.hpp index fad9ec7e..ec403c15 100644 --- a/dinput/keybinding-worker.hpp +++ b/dinput/keybinding-worker.hpp @@ -64,7 +64,7 @@ private: void remove_receiver(fun* pos); ~KeybindingWorker(); - static constexpr int num_keyboard_states = 16; + static constexpr int num_keyboard_states = 64; DIDEVICEOBJECTDATA keyboard_states[num_keyboard_states] {}; KeybindingWorker(const KeybindingWorker&) = delete; diff --git a/dinput/win32-joystick.cpp b/dinput/win32-joystick.cpp index 4da5c57d..71c93543 100644 --- a/dinput/win32-joystick.cpp +++ b/dinput/win32-joystick.cpp @@ -3,19 +3,11 @@ #include "win32-joystick.hpp" #include "compat/macros.hpp" -// doesn't play well with Qt Creator clang code model -#if defined Q_CREATOR_RUN && defined _MSC_VER -# undef offsetof -# define offsetof(type, member) __builtin_offsetof(type, member) -#else -# include <cstddef> -#endif - +#include <cstddef> #include <algorithm> #include <cmath> #include <QWidget> - #include <QDebug> #include <objbase.h> @@ -59,19 +51,15 @@ bool win32_joy_ctx::poll_axis(const QString &guid, int* axes) bool ok = false; HRESULT hr; - if (!FAILED(hr = joy_handle->Poll())) + if (SUCCEEDED(hr = joy_handle->Poll())) + ok = true; + else if (SUCCEEDED(hr = joy_handle->Acquire()) && SUCCEEDED(hr = joy_handle->Poll())) ok = true; - - if (!ok && FAILED(hr = joy_handle->Acquire())) - { - (void)0; - //qDebug() << "joy acquire failed" << hr; - } if (!ok) { (void)joy_handle->Unacquire(); - Sleep(100); + Sleep(0); continue; } @@ -80,7 +68,7 @@ bool win32_joy_ctx::poll_axis(const QString &guid, int* axes) if (FAILED(hr = joy_handle->GetDeviceState(sizeof(js), &js))) { //qDebug() << "joy get state failed" << guid << hr; - Sleep(500); + Sleep(0); continue; } @@ -133,11 +121,12 @@ void win32_joy_ctx::refresh() QString win32_joy_ctx::guid_to_string(const GUID& guid) { - char buf[40] = {0}; - wchar_t szGuidW[40] = {0}; + char buf[40] = {}; + wchar_t szGuidW[40] = {}; - StringFromGUID2(guid, szGuidW, 40); - WideCharToMultiByte(0, 0, szGuidW, -1, buf, 40, nullptr, nullptr); + StringFromGUID2(guid, szGuidW, sizeof(buf)); + WideCharToMultiByte(0, 0, szGuidW, -1, buf, sizeof(buf), nullptr, nullptr); + buf[sizeof(buf)-1] = 0; return QString(buf); } @@ -254,7 +243,7 @@ void win32_joy_ctx::enum_state::refresh() if (!di) { - qDebug() << "can't create dinput"; + qDebug() << "dinput: can't create dinput"; return; } @@ -265,7 +254,7 @@ void win32_joy_ctx::enum_state::refresh() this, DIEDFL_ATTACHEDONLY))) { - eval_once(qDebug() << "failed enum joysticks" << hr); + eval_once(qDebug() << "dinput: failed enum joysticks" << hr); return; } @@ -298,12 +287,12 @@ BOOL CALLBACK win32_joy_ctx::enum_state::EnumJoysticksCallback(const DIDEVICEINS LPDIRECTINPUTDEVICE8 h; if (FAILED(hr = state.di->CreateDevice(pdidInstance->guidInstance, &h, nullptr))) { - qDebug() << "createdevice" << guid << hr; + qDebug() << "dinput: joystick CreateDevice" << guid << hr; goto end; } if (FAILED(h->SetDataFormat(&c_dfDIJoystick2))) { - qDebug() << "format"; + qDebug() << "dinput: joystick SetDataFormat"; h->Release(); goto end; } @@ -328,7 +317,7 @@ BOOL CALLBACK win32_joy_ctx::enum_state::EnumJoysticksCallback(const DIDEVICEINS if (h->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph) != DI_OK) { - qDebug() << "setup joystick buffer mode failed!"; + qDebug() << "dinput: joystick DIPROP_BUFFERSIZE"; h->Release(); goto end; } @@ -336,7 +325,7 @@ BOOL CALLBACK win32_joy_ctx::enum_state::EnumJoysticksCallback(const DIDEVICEINS if (FAILED(hr = h->EnumObjects(EnumObjectsCallback, h, DIDFT_ALL))) { - qDebug() << "enum-objects"; + qDebug() << "dinput: joystick EnumObjects"; h->Release(); goto end; } @@ -363,7 +352,7 @@ BOOL CALLBACK win32_joy_ctx::enum_state::EnumObjectsCallback(const DIDEVICEOBJEC if (FAILED(hr = reinterpret_cast<LPDIRECTINPUTDEVICE8>(ctx)->SetProperty(DIPROP_RANGE, &diprg.diph))) { - qDebug() << "DIPROP_RANGE" << hr; + qDebug() << "dinput: joystick DIPROP_RANGE" << hr; return DIENUM_STOP; } } diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index f96bd2d2..db7ea279 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -25,13 +25,11 @@ cc_noinline static void do_deltas(const double* deltas, double* output, F&& fun) { double norm[N]; + double dist = 0; - const double dist = progn( - double ret = 0; - for (unsigned k = 0; k < N; k++) - ret += deltas[k]*deltas[k]; - return sqrt(ret); - ); + for (unsigned k = 0; k < N; k++) + dist += deltas[k]*deltas[k]; + dist = sqrt(dist); const double value = double(fun(dist)); diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index e6551863..658567b3 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -1,7 +1,7 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! -#include "../build/opentrack-version.h" +#include "../build-clion-msvc-dev/opentrack-version.h" #define MyAppName "opentrack" #define MyAppVersion OPENTRACK_VERSION #define MyAppPublisher "opentrack" @@ -45,7 +45,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "..\build\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs +Source: "..\build-clion-msvc-dev\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" diff --git a/logic/main-settings.cpp b/logic/main-settings.cpp index 2bf0ad1f..19bb692d 100644 --- a/logic/main-settings.cpp +++ b/logic/main-settings.cpp @@ -4,57 +4,8 @@ namespace main_settings_impl { using namespace options; -main_settings::main_settings() : - b(make_bundle("opentrack-ui")), - b_map(make_bundle("opentrack-mappings")), - a_x("x", TX), - a_y("y", TY), - a_z("z", TZ), - a_yaw("yaw", Yaw), - a_pitch("pitch", Pitch), - a_roll("roll", Roll), - all_axis_opts { &a_x, &a_y, &a_z, &a_yaw, &a_pitch, &a_roll }, - reltrans_disable_tx(b, "compensate-translation-disable-x-axis", false), - reltrans_disable_ty(b, "compensate-translation-disable-y-axis", false), - reltrans_disable_tz(b, "compensate-translation-disable-z-axis", false), - reltrans_disable_src_yaw(b, "compensate-translation-disable-source-yaw", false), - reltrans_disable_src_pitch(b, "compensate-translation-disable-source-pitch", false), - reltrans_disable_src_roll(b, "compensate-translation-disable-source-roll", false), - tray_enabled(b, "use-system-tray", false), - tray_start(b, "start-in-tray", false), - center_at_startup(b, "center-at-startup", true), - neck_z(b, "neck-depth", 0), - neck_enable(b, "neck-enable", false), - key_start_tracking1(b, "start-tracking"), - key_start_tracking2(b, "start-tracking-alt"), - key_stop_tracking1(b, "stop-tracking"), - key_stop_tracking2(b, "stop-tracking-alt"), - key_toggle_tracking1(b, "toggle-tracking"), - key_toggle_tracking2(b, "toggle-tracking-alt"), - key_restart_tracking1(b, "restart-tracking"), - key_restart_tracking2(b, "restart-tracking-alt"), - key_center1(b, "center"), - key_center2(b, "center-alt"), - key_toggle1(b, "toggle"), - key_toggle2(b, "toggle-alt"), - key_zero1(b, "zero"), - key_zero2(b, "zero-alt"), - key_toggle_press1(b, "toggle-press"), - key_toggle_press2(b, "toggle-press-alt"), - key_zero_press1(b, "zero-press"), - key_zero_press2(b, "zero-press-alt"), - tracklogging_enabled(b, "tracklogging-enabled", false), - tracklogging_filename(b, "tracklogging-filename", QString()) -{ -} - -module_settings::module_settings() : - b(make_bundle("modules")), - tracker_dll(b, "tracker-dll", "pt"), - filter_dll(b, "filter-dll", "accela"), - protocol_dll(b, "protocol-dll", "freetrack") -{ -} +main_settings::main_settings() = default; +module_settings::module_settings() = default; key_opts::key_opts(bundle b, const QString& name) : keycode(b, QString("keycode-%1").arg(name), ""), @@ -66,9 +17,9 @@ key_opts& key_opts::operator=(const key_opts& x) { if (&x != this) { - keycode = x.keycode(); - guid = x.guid(); - button = x.button(); + keycode = *x.keycode; + guid = *x.guid; + button = *x.button; } return *this; diff --git a/logic/main-settings.hpp b/logic/main-settings.hpp index 41edf3e6..8fef7ea7 100644 --- a/logic/main-settings.hpp +++ b/logic/main-settings.hpp @@ -37,36 +37,67 @@ struct OTR_LOGIC_EXPORT key_opts struct OTR_LOGIC_EXPORT module_settings { - bundle b; - value<QString> tracker_dll, filter_dll, protocol_dll; + bundle b { make_bundle("modules") }; + value<QString> tracker_dll { b, "tracker-dll", "pt" }; + value<QString> filter_dll { b, "filter-dll", "accela" }; + value<QString> protocol_dll { b, "protocol-dll", "freetrack" }; module_settings(); }; struct OTR_LOGIC_EXPORT main_settings final { - bundle b, b_map; - axis_opts a_x, a_y, a_z; - axis_opts a_yaw, a_pitch, a_roll; - axis_opts* all_axis_opts[6]; + bundle b { make_bundle("opentrack-ui") }; + bundle b_map { make_bundle("opentrack-mappings") }; + axis_opts a_x{ "x", TX }, a_y { "y", TY }, a_z { "z", TZ }; + axis_opts a_yaw{ "yaw", Yaw }, a_pitch { "pitch", Pitch }, a_roll { "roll", Roll }; + axis_opts* all_axis_opts[6] { &a_x, &a_y, &a_z, &a_yaw, &a_pitch, &a_roll }; value<reltrans_state> reltrans_mode { b, "relative-translation-mode", reltrans_disabled }; - value<bool> reltrans_disable_tx, reltrans_disable_ty, reltrans_disable_tz; - value<bool> reltrans_disable_src_yaw, reltrans_disable_src_pitch, reltrans_disable_src_roll; - value<bool> tray_enabled, tray_start; - value<bool> center_at_startup; + + value<bool> reltrans_disable_tx { b, "compensate-translation-disable-x-axis", false }; + value<bool> reltrans_disable_ty { b, "compensate-translation-disable-y-axis", false }; + value<bool> reltrans_disable_tz { b, "compensate-translation-disable-z-axis", false }; + + value<bool> reltrans_disable_src_yaw { b, "compensate-translation-disable-source-yaw", false }; + value<bool> reltrans_disable_src_pitch { b, "compensate-translation-disable-source-pitch", false }; + value<bool> reltrans_disable_src_roll { b, "compensate-translation-disable-source-roll", false }; + + value<bool> tray_enabled { b, "use-system-tray", false }; + value<bool> tray_start { b, "start-in-tray", false }; + + value<bool> center_at_startup { b, "center-at-startup", true }; //value<int> center_method; - value<int> neck_z; - value<bool> neck_enable; - key_opts key_start_tracking1, key_start_tracking2; - key_opts key_stop_tracking1, key_stop_tracking2; - key_opts key_toggle_tracking1, key_toggle_tracking2; - key_opts key_restart_tracking1, key_restart_tracking2; - key_opts key_center1, key_center2; - key_opts key_toggle1, key_toggle2; - key_opts key_zero1, key_zero2; - key_opts key_toggle_press1, key_toggle_press2; - key_opts key_zero_press1, key_zero_press2; - value<bool> tracklogging_enabled; - value<QString> tracklogging_filename; + value<int> neck_z { b, "neck-depth", 0 }; + value<bool> neck_enable { b, "neck-enable", false }; + + key_opts key_start_tracking1 { b, "start-tracking" }; + key_opts key_start_tracking2 { b, "start-tracking-alt" }; + + key_opts key_stop_tracking1 { b, "stop-tracking" }; + key_opts key_stop_tracking2 { b, "stop-tracking-alt" }; + + key_opts key_toggle_tracking1 { b, "toggle-tracking" }; + key_opts key_toggle_tracking2 { b, "toggle-tracking-alt" }; + + key_opts key_restart_tracking1 { b, "restart-tracking" }; + key_opts key_restart_tracking2 { b, "restart-tracking-alt" }; + + key_opts key_center1 { b, "center" }; + key_opts key_center2 { b, "center-alt" }; + + key_opts key_toggle1 { b, "toggle" }; + key_opts key_toggle2 { b, "toggle-alt" }; + + key_opts key_zero1 { b, "zero" }; + key_opts key_zero2 { b, "zero-alt" }; + + key_opts key_toggle_press1 { b, "toggle-press" }; + key_opts key_toggle_press2 { b, "toggle-press-alt" }; + + key_opts key_zero_press1 { b, "zero-press" }; + key_opts key_zero_press2 { b, "zero-press-alt" }; + + value<bool> tracklogging_enabled { b, "tracklogging-enabled", false }; + value<QString> tracklogging_filename { b, "tracklogging-filename", {} }; main_settings(); }; diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index 021a576b..eb5ac17a 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -26,12 +26,7 @@ #ifdef _WIN32 # include <windows.h> -#endif - -#if defined __llvm__ -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wlanguage-extension-token" -# pragma clang diagnostic ignored "-Wunknown-pragmas" +# include <mmsystem.h> #endif namespace pipeline_impl { @@ -45,7 +40,7 @@ void reltrans::on_center() { interp_pos = { 0, 0, 0 }; in_zone = false; - cur = false; + moving_to_reltans = false; } euler_t reltrans::rotate(const rmat& R, const euler_t& in, vec3_bool disable) const @@ -83,20 +78,17 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value, if (state != reltrans_disabled) { - const bool in_zone_ = progn( - if (state == reltrans_non_center) - { - const bool looking_down = value(Pitch) < 20; - return looking_down ? std::fabs(value(Yaw)) > 35 : std::fabs(value(Yaw)) > 65; - } - else - return true; - ); + bool in_zone_ = true; + if (state == reltrans_non_center) + { + const bool looking_down = value(Pitch) < 20; + in_zone_ = looking_down ? std::fabs(value(Yaw)) > 35 : std::fabs(value(Yaw)) > 65; + } - if (!cur && in_zone != in_zone_) + if (!moving_to_reltans && in_zone != in_zone_) { //qDebug() << "reltrans-interp: START" << tcomp_in_zone_; - cur = true; + moving_to_reltans = true; interp_timer.start(); interp_phase_timer.start(); RC_stage = 0; @@ -124,7 +116,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value, } } - if (cur) + if (moving_to_reltans) { const double dt = interp_timer.elapsed_seconds(); @@ -156,7 +148,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value, if (delta < eps) { //qDebug() << "reltrans-interp: STOP"; - cur = false; + moving_to_reltans = false; } } else @@ -164,7 +156,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value, } else { - cur = false; + moving_to_reltans = false; in_zone = false; } @@ -213,10 +205,11 @@ double pipeline::map(double pos, Map& axis) #ifndef NO_NAN_CHECK template<int u, int w> -static bool is_nan(const dmat<u,w>& r) +static cc_forceinline +bool is_nan(const dmat<u,w>& r) { - for (int i = 0; i < u; i++) - for (int j = 0; j < w; j++) + for (unsigned i = 0; i < u; i++) + for (unsigned j = 0; j < w; j++) { int val = std::fpclassify(r(i, j)); if (val == FP_NAN || val == FP_INFINITE) @@ -226,21 +219,8 @@ static bool is_nan(const dmat<u,w>& r) return false; } -template<typename x> -static inline -bool nan_check_(const x& datum) -{ - return is_nan(datum); -} - -template<typename x, typename y, typename... xs> -static inline -bool nan_check_(const x& datum, const y& next, const xs&... rest) -{ - return nan_check_(datum) || nan_check_(next, rest...); -} - -static void emit_nan_check_msg(const char* text, const char* fun, int line) +static cc_forceinline +void emit_nan_check_msg(const char* text, const char* fun, int line) { eval_once( qDebug() << "nan check failed" @@ -254,30 +234,33 @@ template<typename... xs> static cc_noinline bool maybe_nan(const char* text, const char* fun, int line, const xs&... vals) { - if (nan_check_(vals...)) - { - emit_nan_check_msg(text, fun, line); - return true; - } + for (const auto& x : { vals... }) + if (is_nan(x)) + { + emit_nan_check_msg(text, fun, line); + return true; + } return false; } -// for MSVC `else' is like `unlikely' for GNU - #define nan_check(...) \ do \ { \ if (likely(!maybe_nan(#__VA_ARGS__, cc_function_name, __LINE__, __VA_ARGS__))) \ + { \ (void)0; \ + } \ else \ + { \ goto error; \ - } while (false) + } \ + } \ + while (false) #else # define nan_check(...) (void)(__VA_ARGS__) #endif - bool pipeline::maybe_enable_center_on_tracking_started() { if (!tracking_started) @@ -689,7 +672,3 @@ bits::bits() : b(0u) } } // ns pipeline_impl - -#if defined __llvm__ -# pragma clang diagnostic pop -#endif diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp index 91dfc668..142a3844 100644 --- a/logic/pipeline.hpp +++ b/logic/pipeline.hpp @@ -51,7 +51,7 @@ class reltrans Timer interp_phase_timer; unsigned RC_stage = 0; - bool cur = false; + bool moving_to_reltans = false; bool in_zone = false; public: diff --git a/spline/spline.cpp b/spline/spline.cpp index cd3daf30..752e85d1 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -367,8 +367,6 @@ void spline::ensure_valid(points_t& list) { QMutexLocker foo(&_mutex); - // storing to s->points fires bundle::changed and that leads to an infinite loop - // thus, only store if we can't help it std::stable_sort(list.begin(), list.end(), sort_fn); const int sz = list.size(); @@ -406,26 +404,24 @@ void spline::ensure_valid(points_t& list) } } - // size check guards against livelock with value<t>/bundle_ signals + // simply storing to s->points fires bundle::changed leading to a livelock + // hence only store if we can't help it - // points that are within bounds if (tmp.size() < points.size()) { + // all points that don't overlap points = std::move(tmp); - // can't stuff there unconditionally - // fires signals from `value<t>' and `bundle_' otherwise s->points = points; } if (all_points.size() < list.size()) - // all points that don't overlap, after clamping + // points that are within currently-specified bounds list = std::move(all_points); last_input_value = {}; activep = false; } -// the return value is only safe to use with no spline::set_bundle calls std::shared_ptr<base_settings> spline::get_settings() { QMutexLocker foo(&_mutex); @@ -460,13 +456,9 @@ void spline::disconnect_signals() { if (conn_changed) { - QObject::disconnect(conn_changed); - QObject::disconnect(conn_maxx); - QObject::disconnect(conn_maxy); - - conn_changed = {}; - conn_maxx = {}; - conn_maxy = {}; + QObject::disconnect(conn_changed), conn_changed = {}; + QObject::disconnect(conn_maxx), conn_maxx = {}; + QObject::disconnect(conn_maxy), conn_maxy = {}; } } diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp index a634768c..fcf58c2d 100644 --- a/tracker-pt/module/point_extractor.cpp +++ b/tracker-pt/module/point_extractor.cpp @@ -155,7 +155,7 @@ void PointExtractor::color_to_grayscale(const cv::Mat& frame, cv::Mat1b& output) } default: eval_once(qDebug() << "wrong pt_color_type enum value" << int(s.blob_color)); - /*FALLTHROUGH*/ + [[fallthrough]]; case pt_color_natural: cv::cvtColor(frame, output, cv::COLOR_BGR2GRAY); break; diff --git a/tracker-rs/ftnoir_tracker_rs_worker.cpp b/tracker-rs/ftnoir_tracker_rs_worker.cpp index 0e2c86f4..15843824 100644 --- a/tracker-rs/ftnoir_tracker_rs_worker.cpp +++ b/tracker-rs/ftnoir_tracker_rs_worker.cpp @@ -7,6 +7,7 @@ #include "ftnoir_tracker_rs_worker.h" #include "rs_impl/ftnoir_tracker_rs_impl.h" +#include <cstdlib> #include <QImage> #include <QDebug> diff --git a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp index 41406193..3230ef56 100644 --- a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp +++ b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp @@ -14,6 +14,8 @@ #include <pxcfacemodule.h> #include <pxcfaceconfiguration.h> +#include <cstdlib> + const size_t kPreviewStreamWidth = 640; const size_t kPreviewStreamHeight = 480; diff --git a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h index a4c03ce8..c71f30fa 100644 --- a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h +++ b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h @@ -6,15 +6,8 @@ */ #pragma once -#ifdef EXPORT_RS_IMPL -#define RSTRACKERIMPL_VISIBILITY __declspec( dllexport ) -#else -#define RSTRACKERIMPL_VISIBILITY -#endif -extern "C" { - RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_start(); - RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_update_pose(double *pose); - RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_get_preview(void* data, int width, int height); - RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_end(); -} +int rs_tracker_impl_start(); +int rs_tracker_impl_update_pose(double *pose); +int rs_tracker_impl_get_preview(void* data, int width, int height); +int rs_tracker_impl_end(); diff --git a/tracker-udp/ftnoir_tracker_udp.cpp b/tracker-udp/ftnoir_tracker_udp.cpp index b6e5eb86..6badaa0f 100644 --- a/tracker-udp/ftnoir_tracker_udp.cpp +++ b/tracker-udp/ftnoir_tracker_udp.cpp @@ -44,16 +44,20 @@ void udp::run() } while (sock.hasPendingDatagrams()); - if (ok && - progn( - for (unsigned i = 0; i < 6; i++) + if (ok) + { + for (unsigned i = 0; i < 6; i++) + { + int val = std::fpclassify(last_recv_pose2[i]); + if (val == FP_NAN || val == FP_INFINITE) { - int val = std::fpclassify(last_recv_pose2[i]); - if (val == FP_NAN || val == FP_INFINITE) - return false; + ok = false; + break; } - return true; - )) + } + } + + if (ok) { for (unsigned i = 0; i < 6; i++) last_recv_pose[i] = last_recv_pose2[i]; diff --git a/tracker-wii/wiiyourself/wiimote.h b/tracker-wii/wiiyourself/wiimote.h index dac949c7..b4738026 100644 --- a/tracker-wii/wiiyourself/wiimote.h +++ b/tracker-wii/wiiyourself/wiimote.h @@ -12,6 +12,7 @@ #include "warns-begin.hpp" +#undef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <tchar.h> // auto Unicode/Ansi support |