summaryrefslogtreecommitdiffhomepage
path: root/pose-widget
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-12 12:01:51 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-12 12:04:28 +0100
commitf3a13f070dee3356f332890a5eeb91c4464fec8d (patch)
tree5ac26dfd1ea006287ebd41b79ba40abcff8e9338 /pose-widget
parenta680c4573fb83e26caa8daee08d08dc045710dd6 (diff)
pose-widget, logic/tracker: adjust euler helpers usage
Diffstat (limited to 'pose-widget')
-rw-r--r--pose-widget/glwidget.cpp22
-rw-r--r--pose-widget/glwidget.h19
2 files changed, 24 insertions, 17 deletions
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 <QDebug>
+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<num>(.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 <QWidget>
#include <QPixmap>
#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<num, 3, 1>;
+using vec2 = Mat<num, 2, 1>;
+
+using namespace euler;
+
class POSE_WIDGET_EXPORT GLWidget : public QWidget
{
public:
- using num = float;
- using vec2 = Mat<num, 2, 1>;
- using vec3 = Mat<num, 3, 1>;
using rmat = Mat<num, 3, 3>;
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;