summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_posewidget
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-07-06 15:51:59 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-07-06 15:51:59 +0200
commit778deec98a4e71974d7bd568cfaf9c5c88f38a4b (patch)
treeae78da55cf86e4ab517642c27094a407fb2f58fe /ftnoir_posewidget
parent2b06b1e44b4c4723aa65c67c1f56b78f66572db8 (diff)
Factor out common code
Diffstat (limited to 'ftnoir_posewidget')
-rw-r--r--ftnoir_posewidget/glwidget.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp
index 3ce44815..671dd35d 100644
--- a/ftnoir_posewidget/glwidget.cpp
+++ b/ftnoir_posewidget/glwidget.cpp
@@ -85,27 +85,25 @@ private:
}
};
+static __inline Vec3f cross(const Vec3f& p1, const Vec3f& p2)
+{
+ return Vec3f(p1.y * p2.z - p2.y * p1.z,
+ p2.x * p1.z - p1.x * p2.z,
+ p1.x * p2.y - p1.y * p2.x);
+}
+
static __inline Vec3f normal(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3)
{
Vec3f u(p2.x - p1.x, p2.y - p1.y, p2.z - p1.z);
Vec3f v(p3.x - p1.x, p3.y - p1.y, p3.z - p1.z);
- Vec3f tmp(u.y * v.z - u.z * v.y,
- u.z * v.x - u.x * v.z,
- u.x * v.y - u.y * v.x);
+ Vec3f tmp = cross(u, v);
double i = 1./sqrt(tmp.x * tmp.x + tmp.y * tmp.y + tmp.z * tmp.z);
return Vec3f(i * tmp.x, i * tmp.y, i * tmp.z);
}
-static __inline Vec3f cross(const Vec3f& p1, const Vec3f& p2)
-{
- return Vec3f(p1.y * p2.z - p2.y * p1.z,
- p2.x * p1.z - p1.x * p2.z,
- p1.x * p2.y - p1.y * p2.x);
-}
-
void GLWidget::project_quad_texture() {
const int sx = width(), sy = height();
Point pt[4];