From 778deec98a4e71974d7bd568cfaf9c5c88f38a4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 6 Jul 2013 15:51:59 +0200 Subject: Factor out common code --- ftnoir_posewidget/glwidget.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'ftnoir_posewidget/glwidget.cpp') 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]; -- cgit v1.2.3