diff options
Diffstat (limited to 'logic')
-rw-r--r-- | logic/main-settings.hpp | 6 | ||||
-rw-r--r-- | logic/tracker.cpp | 30 | ||||
-rw-r--r-- | logic/tracker.h | 3 |
3 files changed, 27 insertions, 12 deletions
diff --git a/logic/main-settings.hpp b/logic/main-settings.hpp index 346c3fb2..ca18a0e9 100644 --- a/logic/main-settings.hpp +++ b/logic/main-settings.hpp @@ -67,7 +67,7 @@ struct main_settings { bundle b, b_map; axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; - value<bool> tcomp_p, tcomp_tz; + value<bool> tcomp_p, tcomp_disable_tx, tcomp_disable_ty, tcomp_disable_tz; value<bool> tray_enabled, tray_start; value<int> camera_yaw, camera_pitch, camera_roll; value<bool> use_camera_offset_from_centering; @@ -89,7 +89,9 @@ struct main_settings a_pitch(b, b_map, "pitch", Pitch), a_roll(b, b_map, "roll", Roll), tcomp_p(b, "compensate-translation", true), - tcomp_tz(b, "compensate-translation-disable-z-axis", false), + tcomp_disable_tx(b, "compensate-translation-disable-x-axis", false), + tcomp_disable_ty(b, "compensate-translation-disable-y-axis", false), + tcomp_disable_tz(b, "compensate-translation-disable-z-axis", false), tray_enabled(b, "use-system-tray", false), tray_start(b, "start-in-tray", false), camera_yaw(b, "camera-yaw", 0), diff --git a/logic/tracker.cpp b/logic/tracker.cpp index f404e8e0..a2c913d3 100644 --- a/logic/tracker.cpp +++ b/logic/tracker.cpp @@ -62,16 +62,26 @@ double Tracker::map(double pos, Map& axis) return double(fc.getValue(pos)); } -void Tracker::t_compensate(const rmat& rmat, const euler_t& xyz_, euler_t& output, bool rz) +void Tracker::t_compensate(const rmat& rmat, const euler_t& xyz, euler_t& output, + bool disable_tx, bool disable_ty, bool disable_tz) { // TY is really yaw axis. need swapping accordingly. - const euler_t ret = rmat * euler_t(xyz_(TZ), -xyz_(TX), -xyz_(TY)); - if (!rz) + const euler_t ret = rmat * euler_t(xyz(TZ), -xyz(TX), -xyz(TY)); + + if (disable_tz) + output(2) = xyz(TZ); + else output(2) = ret(0); + + if (disable_ty) + output(1) = xyz(TY); + else + output(1) = -ret(2); + + if (disable_tx) + output(0) = xyz(TX); else - output(2) = xyz_(2); - output(1) = -ret(2); - output(0) = -ret(1); + output(0) = -ret(1); } #include "compat/nan.hpp" @@ -230,9 +240,9 @@ void Tracker::logic() euler_t pos = euler_t(&value[TX]) - t_center; if (s.use_camera_offset_from_centering) - t_compensate(real_rotation.rot_center.t() * real_rotation.camera.t(), pos, pos, false); + t_compensate(real_rotation.rot_center.t() * real_rotation.camera.t(), pos, pos, false, false, false); else - t_compensate(real_rotation.camera.t(), pos, pos, false); + t_compensate(real_rotation.camera.t(), pos, pos, false, false, false); for (int i = 0; i < 3; i++) { @@ -279,7 +289,9 @@ void Tracker::logic() t_compensate(euler_to_rmat(euler_t(value(Yaw) * d2r, value(Pitch) * d2r, value(Roll) * d2r)), value_, value_, - s.tcomp_tz); + s.tcomp_disable_tx, + s.tcomp_disable_ty, + s.tcomp_disable_tz); if (is_nan(value_)) nanp = true; for (int i = 0; i < 3; i++) diff --git a/logic/tracker.h b/logic/tracker.h index 1546d910..5be55ccb 100644 --- a/logic/tracker.h +++ b/logic/tracker.h @@ -118,7 +118,8 @@ private: double map(double pos, Map& axis); void logic(); - void t_compensate(const rmat& rmat, const euler_t& ypr, euler_t& output, bool rz); + void t_compensate(const rmat& rmat, const euler_t& ypr, euler_t& output, + bool disable_tx, bool disable_ty, bool disable_tz); void run() override; static constexpr double r2d = 180. / M_PI; |