From 6685572195f1e3e22a803ca984d3566516488815 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 03:48:13 +0200 Subject: pose-widget: use floats --- pose-widget/glwidget.cpp | 59 +++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 26 deletions(-) mode change 100644 => 100755 pose-widget/glwidget.cpp (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp old mode 100644 new mode 100755 index 8fbe046e..6da1948e --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -12,6 +12,10 @@ #include #include +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wnarrowing" +#endif + GLWidget::GLWidget(QWidget *parent) : QWidget(parent) { Q_INIT_RESOURCE(posewidget); @@ -31,17 +35,17 @@ void GLWidget::paintEvent ( QPaintEvent * event ) { p.drawImage(event->rect(), texture); } -void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle, double x, double y, double z) +void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float y, float z) { - double c1 = cos(yAngle / 57.295781); - double s1 = sin(yAngle / 57.295781); - double c2 = cos(xAngle / 57.295781); - double s2 = sin(xAngle / 57.295781); - double c3 = cos(zAngle / 57.295781); - double s3 = sin(zAngle / 57.295781); + float c1 = cos(yAngle / 57.295781); + float s1 = sin(yAngle / 57.295781); + float c2 = cos(xAngle / 57.295781); + float s2 = sin(xAngle / 57.295781); + float c3 = cos(zAngle / 57.295781); + float s3 = sin(zAngle / 57.295781); - double foo[] = { + float foo[] = { c2*c3, -c2*s3, s2, c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1, s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2, @@ -55,6 +59,7 @@ void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle, double x, d class Triangle { + using num = GLWidget::num; public: Triangle(const vec2& p1, const vec2& p2, @@ -71,27 +76,29 @@ public: bool barycentric_coords(const vec2& px, vec2& uv) const { vec2 v2 = px - origin; - double dot12 = v1.dot(v2); - double dot02 = v0.dot(v2); - double u = (dot11 * dot02 - dot01 * dot12) * invDenom; - double v = (dot00 * dot12 - dot01 * dot02) * invDenom; + num dot12 = v1.dot(v2); + num dot02 = v0.dot(v2); + num u = (dot11 * dot02 - dot01 * dot12) * invDenom; + num v = (dot00 * dot12 - dot01 * dot02) * invDenom; uv = vec2({u, v}); return (u >= 0) && (v >= 0) && (u + v <= 1); } private: - double dot00, dot01, dot11, invDenom; + num dot00, dot01, dot11, invDenom; vec2 v0, v1, origin; }; static __inline vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3) { + using num = GLWidget::num; + vec3 u = p2 - p1; vec3 v = p3 - p1; vec3 tmp = u.cross(v); - double i = 1./sqrt(tmp.dot(tmp)); + num i = 1./sqrt(tmp.dot(tmp)); return tmp * i; } @@ -100,14 +107,14 @@ void GLWidget::project_quad_texture() { const int sx = width(), sy = height(); vec2 pt[4]; const vec3 corners[] = { - vec3({0., 0., 0.}), - vec3({sx-1., 0., 0.}), - vec3({0., sy-1., 0.}), - vec3({sx-1., sy-1., 0.}) + vec3({0., 0, 0}), + vec3({sx-1, 0, 0}), + vec3({0, sy-1, 0}), + vec3({sx-1, sy-1, 0.}) }; for (int i = 0; i < 4; i++) { - pt[i] = project(vec3({corners[i].x() - sx/2., corners[i].y() - sy/2., 0})); + pt[i] = project(vec3({corners[i].x() - sx/2, corners[i].y() - sy/2, 0})); pt[i].x() += sx/2.; pt[i].y() += sy/2.; } @@ -121,7 +128,7 @@ void GLWidget::project_quad_texture() { normal2 = normal(foo[0], foo[1], foo[2]); } - double dir = normal1.dot(normal2); + num dir = normal1.dot(normal2); QImage& tex = dir < 0 ? back : front; @@ -137,8 +144,8 @@ void GLWidget::project_quad_texture() { const vec2 projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; const vec2 origs[2][3] = { - { vec2({0., 0.}), vec2({ow-1., 0.}), vec2({0., oh-1.}) }, - { vec2({ow-1., oh-1.}), vec2({ow-1., 0.}), vec2({0., oh-1.}) } + { vec2({0, 0}), vec2({ow-1, 0}), vec2({0, oh-1}) }, + { vec2({ow-1, oh-1}), vec2({ow-1, 0}), vec2({0, oh-1}) } }; const Triangle triangles[2] = { Triangle(projected[0][0], projected[0][1], projected[0][2]), @@ -160,7 +167,7 @@ void GLWidget::project_quad_texture() { for (int y = 0; y < sy; y++) for (int x = 0; x < sx; x++) { - vec2 pos({(double)x, (double)y}); + vec2 pos({(num)x, (num)y}); for (int i = 0; i < 2; i++) { vec2 uv; if (triangles[i].barycentric_coords(pos, uv)) @@ -190,12 +197,12 @@ void GLWidget::project_quad_texture() { vec2 GLWidget::project(const vec3 &point) { vec3 ret = rotation * point; - double z = std::max(.75, 1. + translation.z()/-60.); + num z = std::max(.75, 1. + translation.z()/-60); int w = width(), h = height(); - double x = w * translation.x() / 2. / -40.; + num x = w * translation.x() / 2 / -40; if (std::abs(x) > w/2) x = x > 0 ? w/2 : w/-2; - double y = h * translation.y() / 2. / -40.; + num y = h * translation.y() / 2 / -40; if (std::abs(y) > h/2) y = y > 0 ? h/2 : h/-2; return vec2 { z * (ret.x() + x), z * (ret.y() + y) }; -- cgit v1.2.3 From 9161646a6ed0b84770c9645689b98b2d4a2dfb82 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 06:35:43 +0200 Subject: pose-widget: don't pollute global namespace --- pose-widget/glwidget.cpp | 10 +++++----- pose-widget/glwidget.h | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 6da1948e..d6d5260e 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -60,6 +60,8 @@ void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float class Triangle { using num = GLWidget::num; + using vec2 = GLWidget::vec2; + using vec3 = GLWidget::vec3; public: Triangle(const vec2& p1, const vec2& p2, @@ -89,10 +91,8 @@ private: vec2 v0, v1, origin; }; -static __inline vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3) +inline GLWidget::vec3 GLWidget::normal(const vec3& p1, const vec3& p2, const vec3& p3) { - using num = GLWidget::num; - vec3 u = p2 - p1; vec3 v = p3 - p1; @@ -194,7 +194,7 @@ void GLWidget::project_quad_texture() { this->texture = texture; } -vec2 GLWidget::project(const vec3 &point) +GLWidget::vec2 GLWidget::project(const vec3 &point) { vec3 ret = rotation * point; num z = std::max(.75, 1. + translation.z()/-60); @@ -208,7 +208,7 @@ vec2 GLWidget::project(const vec3 &point) return vec2 { z * (ret.x() + x), z * (ret.y() + y) }; } -vec3 GLWidget::project2(const vec3 &point) +GLWidget::vec3 GLWidget::project2(const vec3 &point) { return rotation * point; } diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h index aaea3e06..81517399 100755 --- a/pose-widget/glwidget.h +++ b/pose-widget/glwidget.h @@ -12,14 +12,14 @@ #include "opentrack/plugin-api.hpp" #include "opentrack/simple-mat.hpp" -typedef Mat vec2; -typedef Mat vec3; -typedef Mat rmat; - class GLWidget : public QWidget { public: using num = float; + using vec2 = Mat; + using vec3 = Mat; + using rmat = Mat; + GLWidget(QWidget *parent); ~GLWidget(); void rotateBy(float xAngle, float yAngle, float zAngle, float x, float y, float z); @@ -29,6 +29,7 @@ private: vec2 project(const vec3& point); vec3 project2(const vec3& point); void project_quad_texture(); + static inline vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3); rmat rotation; vec3 translation; QImage front; -- cgit v1.2.3 From 7b6627bb4769ada62c0b632cd72db9d0f0f74406 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 06:35:52 +0200 Subject: pose-widget: we no longer warn on narrowing conversions --- pose-widget/glwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index d6d5260e..8a90c37c 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -167,7 +167,7 @@ void GLWidget::project_quad_texture() { for (int y = 0; y < sy; y++) for (int x = 0; x < sx; x++) { - vec2 pos({(num)x, (num)y}); + vec2 pos({x, y}); for (int i = 0; i < 2; i++) { vec2 uv; if (triangles[i].barycentric_coords(pos, uv)) -- cgit v1.2.3 From 9814176e83fc621f5dc150ec923c558435a41b4e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 09:43:35 +0200 Subject: pose-widget: const nonsense --- pose-widget/glwidget.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 8a90c37c..6c04c4e6 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -77,11 +77,11 @@ public: } bool barycentric_coords(const vec2& px, vec2& uv) const { - vec2 v2 = px - origin; - num dot12 = v1.dot(v2); - num dot02 = v0.dot(v2); - num u = (dot11 * dot02 - dot01 * dot12) * invDenom; - num v = (dot00 * dot12 - dot01 * dot02) * invDenom; + const vec2 v2 = px - origin; + const num dot12 = v1.dot(v2); + const num dot02 = v0.dot(v2); + const num u = (dot11 * dot02 - dot01 * dot12) * invDenom; + const num v = (dot00 * dot12 - dot01 * dot02) * invDenom; uv = vec2({u, v}); return (u >= 0) && (v >= 0) && (u + v <= 1); } -- cgit v1.2.3 From cfed344344b996aea1e6388031dc20b1d15a25f3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 08:51:28 +0200 Subject: simple-mat: replace initializer_list with variadic ctor Gives us type safety rather than argument count mismatch. Also there's no more narrowing conversion issue. Replace usages. Explicitly delete initializer_list ctor. --- opentrack/simple-mat.hpp | 70 ++++++++++++++++++++++++++++++++++++++---------- opentrack/tracker.cpp | 4 +-- pose-widget/glwidget.cpp | 40 +++++++++++++-------------- 3 files changed, 76 insertions(+), 38 deletions(-) (limited to 'pose-widget/glwidget.cpp') diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 9f0911cb..2b4cb72e 100755 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -41,13 +41,43 @@ namespace { enum { P = a == 1 ? 1 : 3 }; enum { Q = a == 1 ? 3 : 1 }; }; + + template struct assignable; + + template + struct assignable { + enum { value = true }; + }; + + template + struct assignable { + enum { value = std::is_assignable::value && assignable::value }; + }; + + template + struct is_arglist_correct + { + enum { value = h * w == sizeof...(ts) && assignable::value }; + }; } template -struct Mat +class Mat { num data[h_][w_]; + static_assert(h_ > 0 && w_ > 0, "must have positive mat dimensions"); + + struct cast + { + template + static num _(u x) { return static_cast(x); } + }; + + Mat(std::initializer_list&& xs) = delete; + +public: + // parameters w_ and h_ are rebound so that SFINAE occurs // removing them causes a compile-time error -sh 20150811 @@ -101,9 +131,9 @@ struct Mat typename std::enable_if::value, Mat::P, is_dim3::Q>>::type cross(const Mat& p2) const { - return Mat({y() * p2.z() - p2.y() * z(), - p2.x() * z() - x() * p2.z(), - x() * p2.y() - y() * p2.x()}); + return Mat(y() * p2.z() - p2.y() * z(), + p2.x() * z() - x() * p2.z(), + x() * p2.y() - y() * p2.x()); } Mat operator+(const Mat& other) const @@ -161,9 +191,9 @@ struct Mat num sum = num(0); for (int k = 0; k < h_; k++) - sum += data[j][k]*other.data[k][i]; + sum += data[j][k]*other(k, i); - ret.data[j][i] = sum; + ret(j, i) = sum; } return ret; @@ -172,19 +202,29 @@ struct Mat inline num operator()(int j, int i) const { return data[j][i]; } inline num& operator()(int j, int i) { return data[j][i]; } - Mat(std::initializer_list&& list) + template::value>> + Mat(ts const&... xs) { - auto iter = list.begin(); - for (int i = 0; i < h_; i++) - for (int j = 0; j < w_; j++) - data[i][j] = *iter++; + const std::initializer_list init = { cast::_(xs)... }; + auto iter = init.begin(); + for (int j = 0; j < h_; j++) + for (int i = 0; i < w_; i++) + data[j][i] = *iter++; + } + + template + Mat(const t* xs) + { + for (int j = 0; j < h_; j++) + for (int i = 0; i < w_; i++) + data[j][i] = num(*xs++); } Mat() { for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - data[j][i] = 0; + data[j][i] = num(0); } Mat(const num* mem) @@ -194,6 +234,8 @@ struct Mat data[j][i] = mem[i*h_+j]; } + Mat(num* mem) : Mat(const_cast(mem)) {} + // XXX add more operators as needed, third-party dependencies mostly // not needed merely for matrix algebra -sh 20141030 @@ -237,10 +279,10 @@ struct Mat if (std::abs(pitch_1) + std::abs(roll_1) + std::abs(yaw_1) > std::abs(pitch_2) + std::abs(roll_2) + std::abs(yaw_2)) { bool fix_neg_pitch = pitch_1 < 0; - return dmat<3, 1>({yaw_2, std::fmod(fix_neg_pitch ? -pi - pitch_1 : pitch_2, pi), roll_2}); + return dmat<3, 1>(yaw_2, std::fmod(fix_neg_pitch ? -pi - pitch_1 : pitch_2, pi), roll_2); } else - return dmat<3, 1>({yaw_1, pitch_1, roll_1}); + return dmat<3, 1>(yaw_1, pitch_1, roll_1); } // tait-bryan angles, not euler diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index 22a8933c..403e87c5 100755 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -52,7 +52,7 @@ double Tracker::map(double pos, Mapping& axis) void Tracker::t_compensate(const rmat& rmat, const double* xyz, double* output, bool rz) { // TY is really yaw axis. need swapping accordingly. - dmat<3, 1> tvec({ xyz[2], -xyz[0], -xyz[1] }); + dmat<3, 1> tvec( xyz[2], -xyz[0], -xyz[1] ); const dmat<3, 1> ret = rmat * tvec; if (!rz) output[2] = ret(0); @@ -107,7 +107,7 @@ void Tracker::logic() }; const rmat cam = rmat::euler_to_rmat(off); rmat r = rmat::euler_to_rmat(&value[Yaw]); - dmat<3, 1> t { value(0), value(1), value(2) }; + dmat<3, 1> t(value(0), value(1), value(2)); r = cam * r; diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 6c04c4e6..334c845b 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -45,14 +45,10 @@ void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float float c3 = cos(zAngle / 57.295781); float s3 = sin(zAngle / 57.295781); - float foo[] = { - c2*c3, -c2*s3, s2, - c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1, - s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2, - }; - - rotation = rmat(foo); - translation = vec3({x, y, z}); + rotation = rmat(c2*c3, -c2*s3, s2, + c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1, + s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2); + translation = vec3(x, y, z); update(); } @@ -68,8 +64,8 @@ public: const vec2& p3) { origin = p1; - v0 = vec2({ p3.x() - p1.x(), p3.y() - p1.y() }); - v1 = vec2({ p2.x() - p1.x(), p2.y() - p1.y() }); + v0 = vec2(p3.x() - p1.x(), p3.y() - p1.y()); + v1 = vec2(p2.x() - p1.x(), p2.y() - p1.y()); dot00 = v0.dot(v0); dot01 = v0.dot(v1); dot11 = v1.dot(v1); @@ -82,7 +78,7 @@ public: const num dot02 = v0.dot(v2); const num u = (dot11 * dot02 - dot01 * dot12) * invDenom; const num v = (dot00 * dot12 - dot01 * dot02) * invDenom; - uv = vec2({u, v}); + uv = vec2(u, v); return (u >= 0) && (v >= 0) && (u + v <= 1); } @@ -107,19 +103,19 @@ void GLWidget::project_quad_texture() { const int sx = width(), sy = height(); vec2 pt[4]; const vec3 corners[] = { - vec3({0., 0, 0}), - vec3({sx-1, 0, 0}), - vec3({0, sy-1, 0}), - vec3({sx-1, sy-1, 0.}) + vec3(0., 0, 0), + vec3(sx-1, 0, 0), + vec3(0, sy-1, 0), + vec3(sx-1, sy-1, 0.) }; for (int i = 0; i < 4; i++) { - pt[i] = project(vec3({corners[i].x() - sx/2, corners[i].y() - sy/2, 0})); + pt[i] = project(vec3(corners[i].x() - sx/2, corners[i].y() - sy/2, 0)); pt[i].x() += sx/2.; pt[i].y() += sy/2.; } - vec3 normal1({0, 0, 1}); + vec3 normal1(0, 0, 1); vec3 normal2; { vec3 foo[3]; @@ -137,15 +133,15 @@ void GLWidget::project_quad_texture() { vec2 p2[4]; for (int i = 0; i < 4; i++) - p2[i] = vec2({pt[i].x(), pt[i].y()}); + p2[i] = vec2(pt[i].x(), pt[i].y()); QImage texture(QSize(sx, sy), QImage::Format_RGB888); QColor bgColor = palette().color(QPalette::Current, QPalette::Window); texture.fill(bgColor); const vec2 projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; const vec2 origs[2][3] = { - { vec2({0, 0}), vec2({ow-1, 0}), vec2({0, oh-1}) }, - { vec2({ow-1, oh-1}), vec2({ow-1, 0}), vec2({0, oh-1}) } + { vec2(0, 0), vec2(ow-1, 0), vec2(0, oh-1) }, + { vec2(ow-1, oh-1), vec2(ow-1, 0), vec2(0, oh-1) } }; const Triangle triangles[2] = { Triangle(projected[0][0], projected[0][1], projected[0][2]), @@ -167,7 +163,7 @@ void GLWidget::project_quad_texture() { for (int y = 0; y < sy; y++) for (int x = 0; x < sx; x++) { - vec2 pos({x, y}); + vec2 pos(x, y); for (int i = 0; i < 2; i++) { vec2 uv; if (triangles[i].barycentric_coords(pos, uv)) @@ -205,7 +201,7 @@ GLWidget::vec2 GLWidget::project(const vec3 &point) num y = h * translation.y() / 2 / -40; if (std::abs(y) > h/2) y = y > 0 ? h/2 : h/-2; - return vec2 { z * (ret.x() + x), z * (ret.y() + y) }; + return vec2(z * (ret.x() + x), z * (ret.y() + y)); } GLWidget::vec3 GLWidget::project2(const vec3 &point) -- cgit v1.2.3 From 4d0bbe2df4228e767ef1402268181fd4483b792b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 08:56:00 +0200 Subject: nix -Wnarrowing, not needed since previous commit --- pose-widget/glwidget.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 334c845b..74f12c27 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -12,10 +12,6 @@ #include #include -#ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wnarrowing" -#endif - GLWidget::GLWidget(QWidget *parent) : QWidget(parent) { Q_INIT_RESOURCE(posewidget); -- cgit v1.2.3 From bf9d97d17b6e9ecc70d8d48f52aca3ade60fc7e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 21 Aug 2015 02:22:03 +0200 Subject: pose-widget: use unsigned char, sprinkle const --- pose-widget/glwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 74f12c27..8bf169df 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -171,9 +171,9 @@ void GLWidget::project_quad_texture() { + uv.x() * (origs[i][2].y() - origs[i][0].y()) + uv.y() * (origs[i][1].y() - origs[i][0].y()); - int r = orig[py * orig_pitch + px * orig_depth + 2]; - int g = orig[py * orig_pitch + px * orig_depth + 1]; - int b = orig[py * orig_pitch + px * orig_depth + 0]; + const unsigned char r = orig[py * orig_pitch + px * orig_depth + 2]; + const unsigned char g = orig[py * orig_pitch + px * orig_depth + 1]; + const unsigned char b = orig[py * orig_pitch + px * orig_depth + 0]; dest[y * dest_pitch + x * dest_depth + 0] = r; dest[y * dest_pitch + x * dest_depth + 1] = g; -- cgit v1.2.3 From 21cd2c012ef23ec3f4b374d82056f1fa1694d904 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:02:57 +0200 Subject: props changed only Some source files had executable bit on. Remove it. --- CMakeLists.txt | 0 bin/NPClient.dll | Bin bin/NPClient64.dll | Bin bin/freetrackclient.dll | Bin clientfiles/make-csv.pl | 0 csv/csv.cpp | 0 facetracknoir/keyboard.h | 0 facetracknoir/process_detector.cpp | 0 facetracknoir/process_detector.h | 0 ftnoir_filter_kalman/ftnoir_filter_kalman.h | 0 ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 0 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 0 ftnoir_tracker_aruco/include/markerdetector.h | 0 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 0 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 0 opentrack-compat/process-list.hpp | 0 opentrack/simple-mat.hpp | 0 opentrack/tracker.cpp | 0 opentrack/win32-shortcuts.cpp | 0 opentrack/win32-shortcuts.h | 0 pose-widget/glwidget.cpp | 0 pose-widget/glwidget.h | 0 qfunctionconfigurator/functionconfig.cpp | 0 23 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 CMakeLists.txt mode change 100755 => 100644 bin/NPClient.dll mode change 100755 => 100644 bin/NPClient64.dll mode change 100755 => 100644 bin/freetrackclient.dll mode change 100755 => 100644 clientfiles/make-csv.pl mode change 100755 => 100644 csv/csv.cpp mode change 100755 => 100644 facetracknoir/keyboard.h mode change 100755 => 100644 facetracknoir/process_detector.cpp mode change 100755 => 100644 facetracknoir/process_detector.h mode change 100755 => 100644 ftnoir_filter_kalman/ftnoir_filter_kalman.h mode change 100755 => 100644 ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp mode change 100755 => 100644 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp mode change 100755 => 100644 ftnoir_tracker_aruco/include/markerdetector.h mode change 100755 => 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp mode change 100755 => 100644 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp mode change 100755 => 100644 opentrack-compat/process-list.hpp mode change 100755 => 100644 opentrack/simple-mat.hpp mode change 100755 => 100644 opentrack/tracker.cpp mode change 100755 => 100644 opentrack/win32-shortcuts.cpp mode change 100755 => 100644 opentrack/win32-shortcuts.h mode change 100755 => 100644 pose-widget/glwidget.cpp mode change 100755 => 100644 pose-widget/glwidget.h mode change 100755 => 100644 qfunctionconfigurator/functionconfig.cpp (limited to 'pose-widget/glwidget.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/bin/NPClient.dll b/bin/NPClient.dll old mode 100755 new mode 100644 diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll old mode 100755 new mode 100644 diff --git a/bin/freetrackclient.dll b/bin/freetrackclient.dll old mode 100755 new mode 100644 diff --git a/clientfiles/make-csv.pl b/clientfiles/make-csv.pl old mode 100755 new mode 100644 diff --git a/csv/csv.cpp b/csv/csv.cpp old mode 100755 new mode 100644 diff --git a/facetracknoir/keyboard.h b/facetracknoir/keyboard.h old mode 100755 new mode 100644 diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp old mode 100755 new mode 100644 diff --git a/facetracknoir/process_detector.h b/facetracknoir/process_detector.h old mode 100755 new mode 100644 diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h old mode 100755 new mode 100644 diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp old mode 100755 new mode 100644 diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp old mode 100755 new mode 100644 diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp old mode 100755 new mode 100644 diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp old mode 100755 new mode 100644 diff --git a/opentrack/win32-shortcuts.cpp b/opentrack/win32-shortcuts.cpp old mode 100755 new mode 100644 diff --git a/opentrack/win32-shortcuts.h b/opentrack/win32-shortcuts.h old mode 100755 new mode 100644 diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp old mode 100755 new mode 100644 diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h old mode 100755 new mode 100644 diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp old mode 100755 new mode 100644 -- cgit v1.2.3 From 530debcb9e55dfbbb83dee215d28bbdc7e7f4af9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 31 Aug 2015 05:45:57 +0200 Subject: pose-widget: add comment --- pose-widget/glwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 8bf169df..61b88b80 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -162,6 +162,8 @@ void GLWidget::project_quad_texture() { vec2 pos(x, y); for (int i = 0; i < 2; i++) { vec2 uv; + // XXX knowing center of the lookup pos, + // we have symmetry so only one lookup is needed -sh 20150831 if (triangles[i].barycentric_coords(pos, uv)) { const int px = origs[i][0].x() -- cgit v1.2.3 From ade85a7c5cd9ece75e0f1dbadf6417b71198fb38 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 31 Aug 2015 07:34:52 +0200 Subject: pose-widget: simplify --- pose-widget/glwidget.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'pose-widget/glwidget.cpp') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 61b88b80..2cb858d7 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -105,11 +105,8 @@ void GLWidget::project_quad_texture() { vec3(sx-1, sy-1, 0.) }; - for (int i = 0; i < 4; i++) { - pt[i] = project(vec3(corners[i].x() - sx/2, corners[i].y() - sy/2, 0)); - pt[i].x() += sx/2.; - pt[i].y() += sy/2.; - } + for (int i = 0; i < 4; i++) + pt[i] = project(vec3(corners[i].x() - sx/2, corners[i].y() - sy/2, 0)) + vec2(sx/2, sy/2); vec3 normal1(0, 0, 1); vec3 normal2; @@ -126,15 +123,11 @@ void GLWidget::project_quad_texture() { int ow = tex.width(), oh = tex.height(); - vec2 p2[4]; - - for (int i = 0; i < 4; i++) - p2[i] = vec2(pt[i].x(), pt[i].y()); QImage texture(QSize(sx, sy), QImage::Format_RGB888); QColor bgColor = palette().color(QPalette::Current, QPalette::Window); texture.fill(bgColor); - const vec2 projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; + const vec2 projected[2][3] = { { pt[0], pt[1], pt[2] }, { pt[3], pt[1], pt[2] } }; const vec2 origs[2][3] = { { vec2(0, 0), vec2(ow-1, 0), vec2(0, oh-1) }, { vec2(ow-1, oh-1), vec2(ow-1, 0), vec2(0, oh-1) } -- cgit v1.2.3