diff options
46 files changed, 208 insertions, 201 deletions
diff --git a/api/plugin-support.hpp b/api/plugin-support.hpp index 34eee1a4..999a929a 100644 --- a/api/plugin-support.hpp +++ b/api/plugin-support.hpp @@ -62,6 +62,11 @@ struct dylib final handle.setFileName(filename_); handle.setLoadHints(QLibrary::DeepBindHint | QLibrary::PreventUnloadHint | QLibrary::ResolveAllSymbolsHint); +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wcomma" +#endif + if (check(!handle.load())) return; @@ -80,6 +85,9 @@ struct dylib final name = m->name(); type = t; +#ifdef __clang__ +# pragma clang diagnostic pop +#endif } // QLibrary refcounts the .dll's so don't forcefully unload diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 40f65474..62b256e9 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -207,8 +207,14 @@ function(otr_module n_) otr_compat(${n}) - if(CMAKE_COMPILER_IS_CLANG AND (arg_EXECUTABLE OR (NOT arg_BIN AND NOT arg_STATIC))) - set_property(TARGET "${n}" APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-weak-vtables ") + if(CMAKE_COMPILER_IS_CLANGXX AND (arg_EXECUTABLE OR NOT arg_BIN)) + set(opts + weak-vtables + header-hygiene + ) + foreach(k ${opts}) + set_property(TARGET "${n}" APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-${k} ") + endforeach() endif() if(NOT arg_NO-INSTALL) diff --git a/compat/correlation-calibrator.hpp b/compat/correlation-calibrator.hpp index 2c9e1937..cc168fcd 100644 --- a/compat/correlation-calibrator.hpp +++ b/compat/correlation-calibrator.hpp @@ -33,14 +33,14 @@ static constexpr inline double yaw_spacing_in_degrees = 1.5; static constexpr inline double pitch_spacing_in_degrees = 1; static constexpr inline double roll_spacing_in_degrees = 1; -static constexpr inline unsigned yaw_nbuckets = 1+ 360./yaw_spacing_in_degrees; -static constexpr inline unsigned pitch_nbuckets = 1+ 360./pitch_spacing_in_degrees; -static constexpr inline unsigned roll_nbuckets = 1+ 360./roll_spacing_in_degrees; +static constexpr inline unsigned yaw_nbuckets = unsigned(1+ 360./yaw_spacing_in_degrees); +static constexpr inline unsigned pitch_nbuckets = unsigned(1+ 360./pitch_spacing_in_degrees); +static constexpr inline unsigned roll_nbuckets = unsigned(1+ 360./roll_spacing_in_degrees); static constexpr inline double translation_spacing = .25; -static constexpr inline unsigned x_nbuckets = 1+ (max[0]-min[0])/translation_spacing; -static constexpr inline unsigned y_nbuckets = 1+ (max[1]-min[1])/translation_spacing; -static constexpr inline unsigned z_nbuckets = 1+ (max[2]-min[2])/translation_spacing; +static constexpr inline unsigned x_nbuckets = unsigned(1+ (max[0]-min[0])/translation_spacing); +static constexpr inline unsigned y_nbuckets = unsigned(1+ (max[1]-min[1])/translation_spacing); +static constexpr inline unsigned z_nbuckets = unsigned(1+ (max[2]-min[2])/translation_spacing); using vec6 = Mat<double, 6, 1>; using mat66 = Mat<double, 6, 6>; diff --git a/compat/macros1.h b/compat/macros1.h index 56f8e978..4c2d1c1e 100644 --- a/compat/macros1.h +++ b/compat/macros1.h @@ -35,9 +35,9 @@ #endif #ifndef PP_EXPAND -# define PP_EXPAND(x) PP_EXPAND__2(x) -# define PP_EXPAND__2(x) PP_EXPAND__3(x) x -# define PP_EXPAND__3(x) x +# define PP_EXPAND(x) PP_EXPAND2(x) +# define PP_EXPAND2(x) PP_EXPAND3(x) x +# define PP_EXPAND3(x) x #endif #ifdef _MSC_VER diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp index e7df087e..45664bda 100644 --- a/cv/video-widget.cpp +++ b/cv/video-widget.cpp @@ -99,7 +99,8 @@ void cv_video_widget::paintEvent(QPaintEvent*) texture = QImage(W, H, QImage::Format_ARGB32); texture.setDevicePixelRatio(dpr); - width = W, height = H; + width = W; + height = H; frame1 = cv::Mat(); frame2 = cv::Mat(); @@ -125,5 +126,6 @@ void cv_video_widget::get_preview_size(int& w, int& h) { QMutexLocker l(&mtx); - w = width, h = height; + w = width; + h = height; } diff --git a/dinput/keybinding-worker.hpp b/dinput/keybinding-worker.hpp index 43a4aee1..7b9dd259 100644 --- a/dinput/keybinding-worker.hpp +++ b/dinput/keybinding-worker.hpp @@ -24,13 +24,13 @@ struct OTR_DINPUT_EXPORT Key { QString guid; + Timer timer; int keycode = 0; bool shift = false; bool ctrl = false; bool alt = false; bool held = true; bool enabled = true; - Timer timer; public: Key(); diff --git a/filter-kalman/kalman.cpp b/filter-kalman/kalman.cpp index f88d7f90..1960e0f6 100644 --- a/filter-kalman/kalman.cpp +++ b/filter-kalman/kalman.cpp @@ -192,7 +192,6 @@ void kalman::reset() for (int i = 0; i < 6; i++) { last_input[i] = 0; } - first_run = true; dt_since_last_input = 0; prev_slider_pos[0] = s.noise_pos_slider_value; @@ -311,7 +310,7 @@ double settings::map_slider_value(const slider_value& v_) | left_side_log10 */ - const int k = v * num_divisions; // in which division are we?! + const int k = int(v * num_divisions); // in which division are we?! const double f = v * num_divisions - k; // where in the division are we?! const double ff = f * 9. + 1.; const double multiplier = int(ff * 10.) / 10.; diff --git a/filter-kalman/kalman.h b/filter-kalman/kalman.h index 30f9e90f..ad5e3e20 100644 --- a/filter-kalman/kalman.h +++ b/filter-kalman/kalman.h @@ -109,15 +109,19 @@ public: void center() override { reset(); } module_status initialize() override { return status_ok(); } - PoseVector last_input; - Timer timer; - bool first_run; double dt_since_last_input; - settings s; + PoseVector last_input; KalmanFilter kf; KalmanProcessNoiseScaler kf_adaptive_process_noise_cov; DeadzoneFilter dz_filter; - slider_value prev_slider_pos[2]; + settings s; + slider_value prev_slider_pos[2] { + *s.noise_pos_slider_value, + *s.noise_rot_slider_value, + }; + Timer timer; + + bool first_run = true; }; class kalmanDll : public Metadata diff --git a/logic/runtime-libraries.cpp b/logic/runtime-libraries.cpp index b91c9635..097540c2 100644 --- a/logic/runtime-libraries.cpp +++ b/logic/runtime-libraries.cpp @@ -12,6 +12,11 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli with_tracker_teardown sentinel; +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wcomma" +#endif + pProtocol = make_dylib_instance<IProtocol>(p); if (!pProtocol) @@ -57,6 +62,10 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli goto end; } +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + correct = true; return; diff --git a/logic/work.cpp b/logic/work.cpp index da61b348..e0c13ac8 100644 --- a/logic/work.cpp +++ b/logic/work.cpp @@ -53,7 +53,7 @@ std::unique_ptr<TrackLogger> Work::make_logger(main_settings &s) QMessageBox::Ok, QMessageBox::NoButton); } else - return logger; + return std::move(logger); } } diff --git a/migration/CMakeLists.txt b/migration/CMakeLists.txt index 9a7f7dc9..1e187971 100644 --- a/migration/CMakeLists.txt +++ b/migration/CMakeLists.txt @@ -1,2 +1,5 @@ otr_module(migration BIN) target_link_libraries(opentrack-migration opentrack-logic opentrack-spline) +if(CMAKE_COMPILER_IS_CLANGXX) + target_compile_options(${self} PRIVATE "-Wno-weak-vtables") +endif() diff --git a/options/metatype.cpp b/options/metatype.cpp index a4629aa6..3b8ec690 100644 --- a/options/metatype.cpp +++ b/options/metatype.cpp @@ -1,4 +1,5 @@ #include <QMetaType> +#include "compat/macros.hpp" namespace options::detail { @@ -13,19 +14,15 @@ int declare_metatype_for_type(const char* str) } // ns options::detail -#define OPENTRACK_DEFINE_METATYPE2(t, ctr) \ - OPENTRACK_DEFINE_METATYPE3(t, ctr) - -#define OPENTRACK_DEFINE_METATYPE3(t, ctr) \ - OPENTRACK_DEFINE_METATYPE4(t, init_metatype_ ## ctr) - -#define OPENTRACK_DEFINE_METATYPE4(t, sym) \ - class sym { /* NOLINT */ \ - static const int dribble; \ - } sym; /* NOLINT */ \ +#define OPENTRACK_DEFINE_METATYPE2(t, sym) \ + class sym { /* NOLINT */ \ + static const int dribble; \ + }; /* NOLINT */ \ + static sym sym; \ const int sym :: dribble = ::options::detail::declare_metatype_for_type<t>(#t); -#define OPENTRACK_DEFINE_METATYPE(t) OPENTRACK_DEFINE_METATYPE2(t, __COUNTER__) +#define OPENTRACK_DEFINE_METATYPE(t) \ + OPENTRACK_DEFINE_METATYPE2(t, PP_CAT(init, __COUNTER__)) #define OPENTRACK_METATYPE_(x) OPENTRACK_DEFINE_METATYPE(x) #include "metatype.hpp" diff --git a/options/scoped.cpp b/options/scoped.cpp index 8f1ef202..ef5b94d6 100644 --- a/options/scoped.cpp +++ b/options/scoped.cpp @@ -10,17 +10,17 @@ namespace options { // XXX hack: the flag shouldn't be here as action at distance -sh 20160926 -static std::atomic_bool teardown_flag(false); -static void set_teardown_flag(bool value); +static std::atomic<bool> teardown_flag{false}; +[[nodiscard]] static bool set_teardown_flag(bool value); static void ensure_thread(); static bool is_tracker_teardown(); -static void set_teardown_flag(bool value) +static bool set_teardown_flag(bool value) { // flag being set means "opts" is about to go out of scope due to tracker stop // in this case we don't reload options. we only want to reload when cancel is pressed. ensure_thread(); - teardown_flag = value; + return teardown_flag.exchange(value); } static void ensure_thread() @@ -59,14 +59,13 @@ opts::opts(const QString &name) : b(make_bundle(name)) { } -with_tracker_teardown::with_tracker_teardown() : old_value(teardown_flag) +with_tracker_teardown::with_tracker_teardown() : old_value{set_teardown_flag(true)} { - set_teardown_flag(true); } with_tracker_teardown::~with_tracker_teardown() { - set_teardown_flag(old_value); + (void)set_teardown_flag(old_value); } } // ns options diff --git a/options/scoped.hpp b/options/scoped.hpp index 452708f4..dd7dbacf 100644 --- a/options/scoped.hpp +++ b/options/scoped.hpp @@ -6,8 +6,6 @@ #include "export.hpp" -#include <atomic> - namespace options { struct OTR_OPTIONS_EXPORT with_tracker_teardown final @@ -26,11 +24,12 @@ struct OTR_OPTIONS_EXPORT opts bundle b; - virtual ~opts(); - explicit opts(const QString& name); - opts& operator=(const opts&) = delete; opts(const opts&) = delete; + +protected: + explicit opts(const QString& name); + ~opts(); }; } diff --git a/options/slider.hpp b/options/slider.hpp index 1dd9ec7c..abf39685 100644 --- a/options/slider.hpp +++ b/options/slider.hpp @@ -34,11 +34,11 @@ namespace options slider_value& operator=(const slider_value& v) = default; slider_value(const slider_value& v) = default; - slider_value() : slider_value{0, 0, 0} {}; + slider_value() : slider_value{0, 0, 0} {} bool operator==(const slider_value& v) const; bool operator!=(const slider_value& v) const; - operator double() const { return cur_; } + constexpr operator double() const { return cur_; } double cur() const { return cur_; } double min() const { return min_; } double max() const { return max_; } diff --git a/options/value.hpp b/options/value.hpp index ea180b27..3a58f74c 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -110,7 +110,7 @@ public: operator t() const { return get(); } // NOLINT - template<typename w, typename = decltype(static_cast<w>(std::declval<t>()))> + template<typename w> explicit cc_forceinline operator w() const { return to<w>(); } auto operator->() const diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc.h b/proto-fsuipc/ftnoir_protocol_fsuipc.h index fa8bcd45..93e73e7f 100644 --- a/proto-fsuipc/ftnoir_protocol_fsuipc.h +++ b/proto-fsuipc/ftnoir_protocol_fsuipc.h @@ -53,8 +53,8 @@ public: fsuipc(); ~fsuipc() override; module_status initialize() override; - void pose(const double* headpose); - QString game_name() { return tr("Microsoft Flight Simulator X"); } + void pose(const double* headpose) override; + QString game_name() override { return tr("Microsoft Flight Simulator X"); } private: QLibrary FSUIPCLib; double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; @@ -69,8 +69,8 @@ class FSUIPCControls: public IProtocolDialog Q_OBJECT public: FSUIPCControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} + void register_protocol(IProtocol *) override {} + void unregister_protocol() override {} private: Ui::UICFSUIPCControls ui; settings s; @@ -84,8 +84,8 @@ class fsuipcDll : public Metadata { Q_OBJECT - QString name() { return tr("FSUIPC -- Microsoft FS2002/FS2004"); } - QIcon icon() { return QIcon(":/images/fs9.png"); } + QString name() override { return tr("FSUIPC -- Microsoft FS2002/FS2004"); } + QIcon icon() override { return QIcon(":/images/fs9.png"); } }; diff --git a/proto-simconnect/ftnoir_protocol_sc.h b/proto-simconnect/ftnoir_protocol_sc.h index 749f7906..9a504ec6 100644 --- a/proto-simconnect/ftnoir_protocol_sc.h +++ b/proto-simconnect/ftnoir_protocol_sc.h @@ -41,15 +41,14 @@ public: simconnect() = default; ~simconnect() override; module_status initialize() override; - void pose(const double* headpose); + void pose(const double* headpose) override; void handle(); - QString game_name() + QString game_name() override { return tr("FS2004/FSX"); } private: enum { - SIMCONNECT_RECV_ID_NULL, SIMCONNECT_RECV_ID_EXCEPTION = 2, SIMCONNECT_RECV_ID_QUIT = 3, SIMCONNECT_RECV_ID_EVENT_FRAME = 7, @@ -99,8 +98,8 @@ class SCControls: public IProtocolDialog Q_OBJECT public: SCControls(); - void register_protocol(IProtocol *) {} - void unregister_protocol() {} + void register_protocol(IProtocol *) override {} + void unregister_protocol() override {} private: Ui::UICSCControls ui; settings s; @@ -113,6 +112,6 @@ class simconnectDll : public Metadata { Q_OBJECT - QString name() { return tr("Microsoft FSX SimConnect"); } - QIcon icon() { return QIcon(":/images/fsx.png"); } + QString name() override { return tr("Microsoft FSX SimConnect"); } + QIcon icon() override { return QIcon(":/images/fsx.png"); } }; diff --git a/proto-udp/ftnoir_protocol_ftn.cpp b/proto-udp/ftnoir_protocol_ftn.cpp index 4d57140f..0eb79954 100644 --- a/proto-udp/ftnoir_protocol_ftn.cpp +++ b/proto-udp/ftnoir_protocol_ftn.cpp @@ -27,7 +27,7 @@ void udp::pose(const double *headpose) { void udp::set_dest_address() { - dest_port = s.port; + dest_port = (unsigned short)s.port; dest_ip = QHostAddress((s.ip1.to<unsigned>() & 0xff) << 24 | (s.ip2.to<unsigned>() & 0xff) << 16 | (s.ip3.to<unsigned>() & 0xff) << 8 | diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h index 81f70a7f..0de86638 100644 --- a/proto-vjoystick/vjoystick.h +++ b/proto-vjoystick/vjoystick.h @@ -68,6 +68,6 @@ class vjoystick_metadata : public Metadata { Q_OBJECT - QString name() { return tr("Joystick emulation -- vjoystick"); } - QIcon icon() { return QIcon(":/images/vjoystick.png"); } + QString name() override { return tr("Joystick emulation -- vjoystick"); } + QIcon icon() override { return QIcon(":/images/vjoystick.png"); } }; diff --git a/qxt-mini/qxtglobalshortcut.h b/qxt-mini/qxtglobalshortcut.h index 98bee92d..9f8dcf9e 100644 --- a/qxt-mini/qxtglobalshortcut.h +++ b/qxt-mini/qxtglobalshortcut.h @@ -46,8 +46,8 @@ class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject bool keystate; public: - explicit QxtGlobalShortcut(QObject* parent = 0); - explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); + explicit QxtGlobalShortcut(QObject* parent = nullptr); + explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = nullptr); ~QxtGlobalShortcut() override; QKeySequence shortcut() const; diff --git a/sdk-paths-sthalik@Clang-windows.cmake b/sdk-paths-sthalik@Clang-windows.cmake index f1b17246..102917d1 100644 --- a/sdk-paths-sthalik@Clang-windows.cmake +++ b/sdk-paths-sthalik@Clang-windows.cmake @@ -31,110 +31,41 @@ setq(SDK_VJOYSTICK "vjoystick") setq(SDK_REALSENSE "RSSDK-R2") -set(__compat - -Wno-unknown-warning-option - -Wno-ignored-optimization-argument - -Wno-unused-command-line-option - - -Wall -Wextra -Wpedantic - -Wstrict-aliasing=3 - -Wstrict-overflow=4 - -Wdelete-non-virtual-dtor - -Wno-odr - -Wattributes -) -set(_compat "") -foreach(k ${__compat}) - set(_compat "${_compat} ${k}") -endforeach() - -set(base-flags "-Wall -Wextra -Wpedantic ${_compat}") -set(base-cxxflags "") # WARNING: this is utter experimental nonsense set(_cxxflags - -Wweak-vtables - -Wlifetime - -Wfloat-overflow-conversion - -Wabstract-vbase-init - -Wduplicated-branches - -Wduplicated-cond - -Wnon-virtual-dtor - -Wassign-enum - -Watomic-implicit-seq-cst - -Watomic-properties - -Wbitfield-enum-conversion - -Wc++11-narrowing - -Wc++98-c++11-c++14-c++17-compat-pedantic - -Wc++2a-compat-pedantic - -Wc99-compat - -Wc99-extensions - -Wcast-qual - -Wchar-subscripts - -Wconsumed - -Wdouble-conversion - -Wdouble-promotion - -Wnon-literal-null-conversion - -Wshorten-64-to-32 - -Wdelete-non-virtual-dtor - -Wfloat-equal - -Wfloat-overflow-conversion - -Wfloat-zero-conversion - -Wformat-non-iso - -Wformat-nonliteral - -Wgcc-compat - -Wignored-qualifiers - -Wimplicit - -Wimplicit-fallthrough - -Winconsistent-missing-destructor-override - -Winconsistent-missing-override - -Winfinite-recursion - -Wkeyword-macro - -Wkeyword-compat - -Wloop-analysis - -Wmain - -Wmethod-signatures - -Wmismatched-tags - -Wmissing-braces - -Wmove - -Woverriding-method-mismatch - -Wpacked - -Wpragmas - -Wreorder - -Wreturn-std-move - -Wself-assign - -Wself-move - -Wshadow-field-in-constructor-modified - -Wsometimes-uninitialized - -Wstrict-prototypes - -Wsuspicious-memaccess - -Wtautological-compare - -Wthread-safety - -Wundefined-reinterpret-cast - -Wundefined-var-template - -Wunguarded-availability - -Wunneeded-internal-declaration - -Wunneeded-member-function - -Wunreachable-code-aggressive - -Wunused - - -Wmost - - -Wno-float-conversion + -Weverything + + -Wno-global-constructors -Wno-exit-time-destructors -Wno-deprecated - -Wno-comma -Wno-self-assign-overloaded + -Wno-double-promotion + -Wno-c++98-compat-pedantic + -Wno-old-style-cast + -Wno-shadow + -Wno-sign-conversion + -Wno-used-but-marked-unused + -Wno-covered-switch-default + -Wno-missing-prototypes + -Wno-padded + -Wno-switch-enum + + -Werror + -Werror=inconsistent-missing-destructor-override + #-Wno-error=padded + + -fdiagnostics-color=always ) set(base-cxxflags "") foreach(k ${_cxxflags}) set(base-cxxflags "${base-cxxflags} ${k}") endforeach() -set(CMAKE_C_FLAGS "-std=c11 ${base-flags} ${CMAKE_C_FLAGS}") -set(CMAKE_CXX_FLAGS "-std=c++17 ${base-flags} ${base-cxxflags} ${CMAKE_CXX_FLAGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${base-cxxflags}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${base-cxxflags}") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}") -set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math ${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_RELEASE "-ffast-math ${CMAKE_CXX_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_DEBUG "-ggdb ${CMAKE_CXX_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_DEBUG "-ggdb ${CMAKE_C_FLAGS_DEBUG}") diff --git a/spline/broken/qfunctionconfiguratorplugin.h b/spline/broken/qfunctionconfiguratorplugin.h index ca68e0e2..11b9a58c 100644 --- a/spline/broken/qfunctionconfiguratorplugin.h +++ b/spline/broken/qfunctionconfiguratorplugin.h @@ -16,7 +16,7 @@ class QFunctionConfiguratorPlugin : public QObject, public QDesignerCustomWidget Q_INTERFACES(QDesignerCustomWidgetInterface) public: - QFunctionConfiguratorPlugin(QObject *parent = 0); + QFunctionConfiguratorPlugin(QObject *parent = nullptr); bool isContainer() const; bool isInitialized() const; diff --git a/spline/spline.cpp b/spline/spline.cpp index ea5b8c95..5381a28e 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -221,6 +221,12 @@ void spline::update_interp_data() const double maxy = max_output(); float last = 0; + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wfloat-equal" +#endif + for (unsigned i = 0; i < unsigned(value_count); i++) { if (data[i] == magic_fill_value) @@ -228,6 +234,10 @@ void spline::update_interp_data() const data[i] = clamp(data[i], 0, (float)maxy); last = data[i]; } + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif } void spline::remove_point(int i) diff --git a/spline/spline.hpp b/spline/spline.hpp index 87489076..e79dd8cc 100644 --- a/spline/spline.hpp +++ b/spline/spline.hpp @@ -109,8 +109,6 @@ class OTR_SPLINE_EXPORT spline : public base_spline QMetaObject::Connection conn_changed, conn_maxx, conn_maxy; mutable std::vector<float> data = std::vector<float>(value_count, float(-16)); mutable QPointF last_input_value; - mutable bool activep = false; - mutable bool validp = false; std::shared_ptr<QObject> ctx { std::make_shared<QObject>() }; @@ -119,6 +117,9 @@ class OTR_SPLINE_EXPORT spline : public base_spline static constexpr inline std::size_t value_count = 4096; + mutable bool activep = false; + mutable bool validp = false; + public: void invalidate_settings(); diff --git a/tracker-aruco/ftnoir_tracker_aruco.h b/tracker-aruco/ftnoir_tracker_aruco.h index 757182e8..2c2a1e05 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.h +++ b/tracker-aruco/ftnoir_tracker_aruco.h @@ -52,14 +52,13 @@ enum aruco_fps }; struct settings : opts { - value<QString> camera_name { b, "camera-name", ""}; - value<int> fov { b, "field-of-view", 56 }; - value<double> headpos_x { b, "headpos-x", 0 }, headpos_y { b, "headpos-y", 0 }, headpos_z { b, "headpos-z", 0 }; + value<QString> camera_name { b, "camera-name", ""}; value<int> resolution { b, "force-resolution", 0 }; + value<int> fov { b, "field-of-view", 56 }; value<aruco_fps> force_fps { b, "force-fps", fps_default }; settings(); @@ -102,19 +101,19 @@ private: settings s; double pose[6] {}, fps = 0; double no_detection_timeout = 0; - cv::Mat frame, grayscale, color; cv::Matx33d r; - std::vector<cv::Point3f> obj_points {4}; cv::Matx33d intrinsics = cv::Matx33d::eye(); - aruco::MarkerDetector detector; - std::vector<aruco::Marker> markers; cv::Vec3d t; cv::Vec3d rvec, tvec; - std::vector<cv::Point2f> roi_projection; - std::vector<cv::Point2f> repr2; cv::Matx33d m_r, m_q, rmat = cv::Matx33d::eye(); cv::Vec3d euler; std::vector<cv::Point3f> roi_points {4}; + std::vector<cv::Point2f> roi_projection; + std::vector<cv::Point2f> repr2; + std::vector<cv::Point3f> obj_points {4}; + aruco::MarkerDetector detector; + std::vector<aruco::Marker> markers; + cv::Mat frame, grayscale, color; cv::Rect last_roi { 65535, 65535, 0, 0 }; Timer fps_timer, last_detection_timer; unsigned adaptive_size_pos { 0 }; @@ -129,8 +128,8 @@ private: static constexpr inline double timeout = .35; static constexpr inline double timeout_backoff_c = .25; - static constexpr inline float size_min = 0.05; - static constexpr inline float size_max = 0.5; + static constexpr inline float size_min = 0.05f; + static constexpr inline float size_max = 0.5f; static constexpr inline double RC = .25; @@ -168,6 +167,6 @@ private Q_SLOTS: class aruco_metadata : public Metadata { Q_OBJECT - QString name() { return QString("aruco -- paper marker tracker"); } - QIcon icon() { return QIcon(":/images/aruco.png"); } + QString name() override { return QString("aruco -- paper marker tracker"); } + QIcon icon() override { return QIcon(":/images/aruco.png"); } }; diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp index 08027f48..b53a9213 100644 --- a/tracker-hatire/ftnoir_tracker_hat.cpp +++ b/tracker-hatire/ftnoir_tracker_hat.cpp @@ -126,18 +126,18 @@ void hatire::data(double *data) const struct { + double& place; + float input; bool enable; bool sign; - float input; - double& place; } spec[] = { - { s.EnableX, s.InvertX, HAT.Trans[s.XAxis], data[TX] }, - { s.EnableY, s.InvertY, HAT.Trans[s.YAxis], data[TY] }, - { s.EnableZ, s.InvertZ, HAT.Trans[s.ZAxis], data[TZ] }, - { s.EnableYaw, s.InvertYaw, HAT.Rot[s.YawAxis], data[Yaw] }, - { s.EnablePitch, s.InvertPitch, HAT.Rot[s.PitchAxis], data[Pitch] }, - { s.EnableRoll, s.InvertRoll, HAT.Rot[s.RollAxis], data[Roll] }, + { data[TX], HAT.Trans[s.XAxis], s.EnableX, s.InvertX, }, + { data[TY], HAT.Trans[s.YAxis], s.EnableY, s.InvertY, }, + { data[TZ], HAT.Trans[s.ZAxis], s.EnableZ, s.InvertZ, }, + { data[Yaw], HAT.Rot[s.YawAxis], s.EnableYaw, s.InvertYaw }, + { data[Pitch], HAT.Rot[s.PitchAxis], s.EnablePitch, s.InvertPitch }, + { data[Roll], HAT.Rot[s.RollAxis], s.EnableRoll, s.InvertRoll }, }; for (auto& k : spec) diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index cafc973a..7589242d 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -108,7 +108,7 @@ void Tracker_PT::run() video_widget->get_preview_size(w, h); if (w != preview_width || h != preview_height) { - preview_width = w, preview_height = h; + preview_width = w; preview_height = h; preview_frame = traits->make_preview(w, h); } } diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 2a156cbc..d900b78d 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -123,10 +123,16 @@ QString TrackerDialog_PT::threshold_display_text(int threshold_value) int w = s.cam_res_x, h = s.cam_res_y; if (w * h <= 0) - w = 640, h = 480; + { + w = 640; + h = 480; + } if (tracker && tracker->get_cam_info(&info) && info.res_x * info.res_y != 0) - w = info.res_x, h = info.res_y; + { + w = info.res_x; + h = info.res_y; + } double value = pt_point_extractor::threshold_radius_value(w, h, threshold_value); diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp index f9d9ff48..86cffd72 100644 --- a/tracker-pt/module/camera.cpp +++ b/tracker-pt/module/camera.cpp @@ -88,7 +88,7 @@ bool Camera::start(int idx, int fps, int res_x, int res_y) if (idx >= 0 && fps >= 0 && res_x >= 0 && res_y >= 0) { if (cam_desired.idx != idx || - cam_desired.fps != fps || + (int)cam_desired.fps != fps || cam_desired.res_x != res_x || cam_desired.res_y != res_y || !cap || !cap->isOpened() || !cap->grab()) diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp index c0756a40..80d9dfc2 100644 --- a/tracker-pt/module/point_extractor.cpp +++ b/tracker-pt/module/point_extractor.cpp @@ -285,7 +285,7 @@ void PointExtractor::extract_points(const pt_frame& frame_, pt_preview& preview_ // XXX we could go to the next scanline unless the points are really small. // i'd expect each point being present on at least one unique scanline // but it turns out some people are using 2px points -sh 20180110 -#if BROKEN && 0 +#if defined BROKEN && 0 break; #endif } diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp index 103228f5..e295a4c9 100644 --- a/tracker-pt/point_tracker.cpp +++ b/tracker-pt/point_tracker.cpp @@ -182,7 +182,7 @@ bool PointTracker::maybe_use_old_point_order(const PointOrder& order, const pt_c if (cnt1 + cnt2) { qDebug() << "old-order" << ((cnt1 * 100) / f(cnt1 + cnt2)) << "nsamples" << (cnt1 + cnt2); - cnt1 = 0, cnt2 = 0; + cnt1 = 0; cnt2 = 0; } } if (validp) @@ -248,6 +248,11 @@ PointTracker::PointOrder PointTracker::find_correspondences(const vec2* points, return p; } +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wfloat-equal" +#endif + int PointTracker::POSIT(const PointModel& model, const PointOrder& order, f focal_length) { // POSIT algorithm for coplanar points as presented in @@ -399,6 +404,10 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order, f foca return i; } +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + vec2 PointTracker::project(const vec3& v_M, f focal_length) { return project(v_M, focal_length, X_CM); diff --git a/tracker-pt/pt-api.cpp b/tracker-pt/pt-api.cpp index d137a60a..128dcaea 100644 --- a/tracker-pt/pt-api.cpp +++ b/tracker-pt/pt-api.cpp @@ -45,7 +45,7 @@ std::tuple<double, double> pt_pixel_pos_mixin::to_pixel_pos(double x, double y, std::tuple<double, double> pt_pixel_pos_mixin::to_screen_pos(double px, double py, int w, int h) { - px *= w/(w-1.), py *= h/(h-1.); + px *= w/(w-1.); py *= h/(h-1.); return std::make_tuple((px - w/2.)/w, -(py - h/2.)/w); } diff --git a/tracker-pt/pt-settings.hpp b/tracker-pt/pt-settings.hpp index 2027302b..df45b499 100644 --- a/tracker-pt/pt-settings.hpp +++ b/tracker-pt/pt-settings.hpp @@ -62,7 +62,6 @@ struct pt_settings final : options::opts value<slider_value> threshold_slider { b, "threshold-slider", { 128, 0, 255 } }; explicit pt_settings(const QString& name) : opts(name) {} - ~pt_settings() override = default; }; #ifdef __clang__ diff --git a/tracker-rs/ftnoir_tracker_rs.h b/tracker-rs/ftnoir_tracker_rs.h index 881e03ca..f322d0f6 100644 --- a/tracker-rs/ftnoir_tracker_rs.h +++ b/tracker-rs/ftnoir_tracker_rs.h @@ -20,7 +20,7 @@ class RSTracker : public QObject, public ITracker public: RSTracker(); - ~RSTracker(); + ~RSTracker() override; module_status start_tracker(QFrame *) override; void data(double *data) override; @@ -50,6 +50,6 @@ class RSTrackerMetaData : public Metadata { Q_OBJECT - QString name(); - QIcon icon(); + QString name() override; + QIcon icon() override; }; diff --git a/tracker-rs/ftnoir_tracker_rs_worker.h b/tracker-rs/ftnoir_tracker_rs_worker.h index 098d6c10..8758e520 100644 --- a/tracker-rs/ftnoir_tracker_rs_worker.h +++ b/tracker-rs/ftnoir_tracker_rs_worker.h @@ -16,7 +16,7 @@ class RSTrackerWorkerThread : public QThread public: RSTrackerWorkerThread(); - ~RSTrackerWorkerThread(); + ~RSTrackerWorkerThread() override; void getPose(double* pose); const QImage getPreview(); diff --git a/tracker-rs/imagewidget.h b/tracker-rs/imagewidget.h index f04eb1a3..a6d5932b 100644 --- a/tracker-rs/imagewidget.h +++ b/tracker-rs/imagewidget.h @@ -14,7 +14,7 @@ class ImageWidget : public QWidget { Q_OBJECT public: - ImageWidget(QWidget* parent = 0); + ImageWidget(QWidget* parent = nullptr); void setImage(QImage image); private: diff --git a/tracker-wii/CMakeLists.txt b/tracker-wii/CMakeLists.txt index e40692ba..f43dca55 100644 --- a/tracker-wii/CMakeLists.txt +++ b/tracker-wii/CMakeLists.txt @@ -3,7 +3,8 @@ if(WIN32) if(OpenCV_FOUND) add_subdirectory(wiiyourself) otr_module(tracker-wii) - target_link_libraries(opentrack-tracker-wii opentrack-tracker-pt-base opentrack-wiiyourself bthprops) - target_include_directories(opentrack-tracker-wii PRIVATE "${CMAKE_SOURCE_DIR}/tracker-pt") + target_link_libraries(${self} opentrack-tracker-pt-base opentrack-wiiyourself bthprops) + target_include_directories(${self} PRIVATE SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/wiiyourself") + target_include_directories(${self} PRIVATE "${CMAKE_SOURCE_DIR}/tracker-pt") endif() endif() diff --git a/tracker-wii/wii_camera.cpp b/tracker-wii/wii_camera.cpp index ab216215..da998ecf 100644 --- a/tracker-wii/wii_camera.cpp +++ b/tracker-wii/wii_camera.cpp @@ -7,8 +7,19 @@ */ // silence #pragma deprecated in bluetoothapis.h + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif + #undef _WIN32_WINNT #define _WIN32_WINNT _WIN32_WINNT_VISTA + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + #undef NTDDI_VERSION #define NTDDI_VERSION NTDDI_VISTASP1 diff --git a/tracker-wii/wii_camera.h b/tracker-wii/wii_camera.h index 11af8846..c8a1d106 100644 --- a/tracker-wii/wii_camera.h +++ b/tracker-wii/wii_camera.h @@ -21,7 +21,7 @@ #include <QString> -#include <wiiyourself/wiimote.h> +#include <wiimote.h> #include "wii_frame.hpp" namespace pt_module { diff --git a/tracker-wii/wiiyourself/CMakeLists.txt b/tracker-wii/wiiyourself/CMakeLists.txt index fe6d62e8..91fa245a 100644 --- a/tracker-wii/wiiyourself/CMakeLists.txt +++ b/tracker-wii/wiiyourself/CMakeLists.txt @@ -1,4 +1,7 @@ if(WIN32) otr_module(wiiyourself STATIC NO-COMPAT NO-QT) target_link_libraries(${self} setupapi hid winmm) + if(CMAKE_COMPILER_IS_CLANGXX OR CMAKE_COMPILER_IS_GNUCXX) + target_compile_options(${self} PRIVATE -Wno-error) + endif() endif() diff --git a/tracker-wii/wiiyourself/warns-begin.hpp b/tracker-wii/wiiyourself/warns-begin.hpp index e4b148ef..dab250f7 100644 --- a/tracker-wii/wiiyourself/warns-begin.hpp +++ b/tracker-wii/wiiyourself/warns-begin.hpp @@ -10,3 +10,11 @@ # pragma GCC diagnostic ignored "-Wcast-function-type" # endif #endif + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +# pragma clang diagnostic ignored "-Wextra-semi" +# pragma clang diagnostic ignored "-Wshadow-field" +# pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif diff --git a/tracker-wii/wiiyourself/warns-end.hpp b/tracker-wii/wiiyourself/warns-end.hpp index beaf245d..3de03ca5 100644 --- a/tracker-wii/wiiyourself/warns-end.hpp +++ b/tracker-wii/wiiyourself/warns-end.hpp @@ -1,3 +1,7 @@ #ifdef __GNUG__ # pragma GCC diagnostic pop #endif + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif diff --git a/tracker-wii/wiiyourself/wiimote.cpp b/tracker-wii/wiiyourself/wiimote.cpp index f6946fad..90788495 100644 --- a/tracker-wii/wiiyourself/wiimote.cpp +++ b/tracker-wii/wiiyourself/wiimote.cpp @@ -1432,7 +1432,7 @@ int wiimote::ParseExtension(BYTE *buff, unsigned offset) float raw_x = buff[offset + 0]; float raw_y = buff[offset + 1]; - if ((raw_x != joy.RawX) || (raw_y != joy.RawY)) + if (std::fabs(raw_x - joy.RawX) < 1e-6f || std::fabs(raw_y - joy.RawY) < 1e-6f) changed |= NUNCHUK_JOYSTICK_CHANGED; joy.RawX = raw_x; diff --git a/variant/default/main.cpp b/variant/default/main.cpp index 09bb5e2a..0038583b 100644 --- a/variant/default/main.cpp +++ b/variant/default/main.cpp @@ -5,7 +5,7 @@ # include <windows.h> #endif -#if defined Q_CREATOR_RUN +#ifdef __clang__ # pragma GCC diagnostic ignored "-Wmain" #endif diff --git a/variant/default/new_file_dialog.h b/variant/default/new_file_dialog.h index 5669e4a9..7244e524 100644 --- a/variant/default/new_file_dialog.h +++ b/variant/default/new_file_dialog.h @@ -11,7 +11,7 @@ class new_file_dialog : public QDialog { Q_OBJECT public: - new_file_dialog(QWidget* parent = 0); + new_file_dialog(QWidget* parent = nullptr); bool is_ok(QString& name_); private: |