From f3a13f070dee3356f332890a5eeb91c4464fec8d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 12 Nov 2016 12:01:51 +0100 Subject: pose-widget, logic/tracker: adjust euler helpers usage --- pose-widget/glwidget.cpp | 22 ++++++++++------------ pose-widget/glwidget.h | 19 ++++++++++++++----- 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'pose-widget') diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 7f24fa7a..01a6b74b 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -14,6 +14,9 @@ #include +using namespace euler; +using namespace impl; + GLWidget::GLWidget(QWidget *parent) : QWidget(parent) { Q_INIT_RESOURCE(posewidget); @@ -54,19 +57,14 @@ void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle, double x, d } class Triangle { - using num = GLWidget::num; - using vec2 = GLWidget::vec2; - using vec3 = GLWidget::vec3; + num dot00, dot01, dot11, invDenom; + vec2 v0, v1, origin; public: Triangle(const vec2& p1, const vec2& p2, const vec2& p3); bool barycentric_coords(const vec2& px, vec2& uv, int& i) const; - -private: - num dot00, dot01, dot11, invDenom; - vec2 v0, v1, origin; }; -inline GLWidget::vec3 GLWidget::normal(const vec3& p1, const vec3& p2, const vec3& p3) +inline vec3 GLWidget::normal(const vec3& p1, const vec3& p2, const vec3& p3) { using std::sqrt; @@ -80,7 +78,7 @@ inline GLWidget::vec3 GLWidget::normal(const vec3& p1, const vec3& p2, const vec return tmp * i; } -Triangle::Triangle(const Triangle::vec2& p1, const Triangle::vec2& p2, const Triangle::vec2& p3) +Triangle::Triangle(const vec2& p1, const vec2& p2, const vec2& p3) { using std::fabs; @@ -107,7 +105,7 @@ Triangle::Triangle(const Triangle::vec2& p1, const Triangle::vec2& p2, const Tri invDenom = 1 / denom; } -bool Triangle::barycentric_coords(const Triangle::vec2& px, Triangle::vec2& uv, int& i) const +bool Triangle::barycentric_coords(const vec2& px, vec2& uv, int& i) const { i = 0; const vec2 v2 = px - origin; @@ -272,7 +270,7 @@ void GLWidget::project_quad_texture() } } -GLWidget::vec2 GLWidget::project(const vec3 &point) +vec2 GLWidget::project(const vec3 &point) { vec3 ret = rotation * point; num z = std::max(.75f, 1 + translation.z()/-60); @@ -286,7 +284,7 @@ GLWidget::vec2 GLWidget::project(const vec3 &point) return vec2(z * (ret.x() + x), z * (ret.y() + y)); } -GLWidget::vec3 GLWidget::project2(const vec3 &point) +vec3 GLWidget::project2(const vec3 &point) { return rotation * point; } diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h index 013cc0d5..f98b4628 100644 --- a/pose-widget/glwidget.h +++ b/pose-widget/glwidget.h @@ -11,7 +11,7 @@ #include #include #include "api/plugin-api.hpp" -#include "compat/simple-mat.hpp" +#include "compat/euler.hpp" #ifdef BUILD_pose_widget # define POSE_WIDGET_EXPORT Q_DECL_EXPORT @@ -19,12 +19,17 @@ # define POSE_WIDGET_EXPORT Q_DECL_IMPORT #endif +namespace impl { + +using num = float; +using vec3 = Mat; +using vec2 = Mat; + +using namespace euler; + class POSE_WIDGET_EXPORT GLWidget : public QWidget { public: - using num = float; - using vec2 = Mat; - using vec3 = Mat; using rmat = Mat; GLWidget(QWidget *parent); @@ -36,7 +41,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); + static vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3); rmat rotation; vec3 translation; @@ -44,3 +49,7 @@ private: QImage back; QImage image; }; + +} + +using impl::GLWidget; -- cgit v1.2.3