summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_posewidget/glwidget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-01-23 04:21:00 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-01-23 04:21:00 +0100
commit6b1a0d5705d3eea34fbdc6a8acf6aa6bc225a868 (patch)
treed9259aafb0b595c511ab1a6334a94d439b3a20c7 /ftnoir_posewidget/glwidget.cpp
parent84b790bba2d3272ea38e473ad951b4dc6259ec58 (diff)
glwidget: don't perform useless computation
The distances are known, so hardcode them instead.
Diffstat (limited to 'ftnoir_posewidget/glwidget.cpp')
-rw-r--r--ftnoir_posewidget/glwidget.cpp41
1 files changed, 12 insertions, 29 deletions
diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp
index 70667f06..590edbc6 100644
--- a/ftnoir_posewidget/glwidget.cpp
+++ b/ftnoir_posewidget/glwidget.cpp
@@ -186,37 +186,20 @@ void GLWidget::project_quad_texture() {
int qx2 = std::min<int>(ow - 1, std::max<int>(0, qx + 1.0));
int qy2 = std::min<int>(oh - 1, std::max<int>(0, qy + 1.0));
- double dx1 = qx1 - qx;
- double dy1 = qy1 - qy;
- double dx2 = qx2 - qx;
- double dy2 = qy2 - qy;
-
- double d1 = 2 - (dx1 * dx1 + dy1 * dy1);
- double d2 = 2 - (dx2 * dx2 + dy2 * dy2);
- double d3 = 2 - (dx2 * dx2 + dy1 * dy1);
- double d4 = 2 - (dx1 * dx1 + dy2 * dy2);
-
- double inv_norm = 1. / (d1 + d2 + d3 + d4);
-
- d1 *= inv_norm;
- d2 *= inv_norm;
- d3 *= inv_norm;
- d4 *= inv_norm;
-
- double r = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 2]
- + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 2]
- + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 2]
- + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 2];
+ double r = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 2]
+ + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 2]
+ + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 2]
+ + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 2]) / 9;
- double g = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 1]
- + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 1]
- + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 1]
- + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 1];
+ double g = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 1]
+ + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 1]
+ + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 1]
+ + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 1]) / 9;
- double b = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 0]
- + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 0]
- + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 0]
- + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 0];
+ double b = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 0]
+ + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 0]
+ + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 0]
+ + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 0]) / 9;
dest[y * dest_pitch + x * dest_depth + 0] = std::max<int>(0, std::min<int>(255, r));
dest[y * dest_pitch + x * dest_depth + 1] = std::max<int>(0, std::min<int>(255, g));