summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/tracker.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-17 11:24:12 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-17 11:24:12 +0200
commiteb1a95e3cea400340e5a64c2791a4a09ca3a0074 (patch)
tree238ad2f3a3e392074dfefb4abdf3437f867fa0c4 /facetracknoir/tracker.cpp
parent547b8f94b2f2814a6ef86e6022c6525b03fcbd2d (diff)
parent619d3d8010b3c093fba8e87f831cc438d8822479 (diff)
Merge commit 'f78b96a' into unstable
* commit 'f78b96a': gcc too much a piece of work often submit mapped data to filter, not raw nonsense drop decimal places for rot/trans in UI rotation below -99 didn't display, just froze add-comment
Diffstat (limited to 'facetracknoir/tracker.cpp')
-rw-r--r--facetracknoir/tracker.cpp103
1 files changed, 56 insertions, 47 deletions
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp
index 09edd45b..0f299153 100644
--- a/facetracknoir/tracker.cpp
+++ b/facetracknoir/tracker.cpp
@@ -36,14 +36,13 @@ Tracker::~Tracker()
wait();
}
-void Tracker::get_curve(double pos, double& out, Mapping& axis) {
+double Tracker::map(double pos, Mapping& axis) {
bool altp = (pos < 0) && axis.opts.altp;
axis.curve.setTrackingActive( !altp );
axis.curveAlt.setTrackingActive( altp );
auto& fc = altp ? axis.curveAlt : axis.curve;
- out = (axis.opts.invert ? -1 : 1) * fc.getValue(pos);
-
- out += axis.opts.zero;
+ double invert = axis.opts.invert ? -1 : 1;
+ return invert * (fc.getValue(pos) + axis.opts.zero);
}
void Tracker::t_compensate(const double* input, double* output, bool rz)
@@ -82,24 +81,14 @@ void Tracker::t_compensate(const double* input, double* output, bool rz)
output[i] = ret(i);
}
-void Tracker::run() {
- Pose pose_offset, unstopped_pose;
-
- double newpose[6] = {0};
- const int sleep_ms = 3;
-
-#if defined(_WIN32)
- (void) timeBeginPeriod(1);
-#endif
+void Tracker::logic()
+{
+ Libraries->pTracker->GetHeadPoseData(newpose);
+
+ Pose final_raw;
- while (!should_quit)
+ if (enabledp)
{
- t.start();
-
- Libraries->pTracker->GetHeadPoseData(newpose);
-
- Pose final_raw, filtered;
-
for (int i = 0; i < 6; i++)
{
auto& axis = m(i);
@@ -109,37 +98,57 @@ void Tracker::run() {
// not really raw, after axis remap -sh
final_raw(i) = newpose[k];
}
+ unstopped_raw = final_raw;
+ }
+
+ Pose filtered_pose;
+
+ if (Libraries->pFilter)
+ Libraries->pFilter->FilterHeadPoseData(final_raw, filtered_pose);
+ else
+ filtered_pose = final_raw;
+
+ if (centerp)
+ {
+ centerp = false;
+ raw_center = final_raw;
+ }
+
+ Pose raw_centered = filtered_pose & raw_center;
+
+ Pose mapped_pose_precomp;
+
+ for (int i = 0; i < 6; i++)
+ mapped_pose_precomp(i) = map(raw_centered(i), m(i));
+
+ Pose mapped_pose;
+
+ if (s.tcomp_p)
+ t_compensate(mapped_pose_precomp, mapped_pose, s.tcomp_tz);
+ else
+ mapped_pose = mapped_pose_precomp;
- {
- if (enabledp)
- unstopped_pose = final_raw;
-
- if (Libraries->pFilter)
- Libraries->pFilter->FilterHeadPoseData(unstopped_pose, filtered);
- else
- filtered = unstopped_pose;
-
- if (centerp) {
- centerp = false;
- pose_offset = filtered;
- }
-
- filtered = filtered & pose_offset;
-
- for (int i = 0; i < 6; i++)
- get_curve(filtered(i), filtered(i), m(i));
- }
+ Libraries->pProtocol->sendHeadposeToGame(mapped_pose);
- if (s.tcomp_p)
- t_compensate(filtered, filtered, s.tcomp_tz);
+ {
+ QMutexLocker foo(&mtx);
+ output_pose = mapped_pose;
+ raw_6dof = unstopped_raw;
+ }
+}
- Libraries->pProtocol->sendHeadposeToGame(filtered);
+void Tracker::run() {
+ const int sleep_ms = 3;
- {
- QMutexLocker foo(&mtx);
- output_pose = filtered;
- raw_6dof = final_raw;
- }
+#if defined(_WIN32)
+ (void) timeBeginPeriod(1);
+#endif
+
+ while (!should_quit)
+ {
+ t.start();
+
+ logic();
double q = sleep_ms * 1000L;
q -= t.elapsed();