summaryrefslogtreecommitdiffhomepage
path: root/pose-widget
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-06-15 09:22:43 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-06-15 09:22:43 +0200
commit7e3f2ec7b38d547e39d667b9ab188f90775dd3bf (patch)
treec52266e5db62c170e43b39328c2e32c01da75706 /pose-widget
parent1661572fcc8eed78d5cb20edf5e8478d4616ce36 (diff)
octopus: simplify vector math
Also rename identifiers for clarity.
Diffstat (limited to 'pose-widget')
-rw-r--r--pose-widget/glwidget.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp
index b444e87e..66527a57 100644
--- a/pose-widget/glwidget.cpp
+++ b/pose-widget/glwidget.cpp
@@ -70,7 +70,7 @@ public:
}
bool barycentric_coords(const vec2& px, vec2& uv) const
{
- vec2 v2({ px.x() - origin.x(), px.y() - origin.y() });
+ vec2 v2 = px - origin;
double dot12 = v1.dot(v2);
double dot02 = v0.dot(v2);
double u = (dot11 * dot02 - dot01 * dot12) * invDenom;
@@ -162,15 +162,15 @@ void GLWidget::project_quad_texture() {
for (int x = 0; x < sx; x++) {
vec2 pos({(double)x, (double)y});
for (int i = 0; i < 2; i++) {
- vec2 coords;
- if (triangles[i].barycentric_coords(pos, coords))
+ vec2 uv;
+ if (triangles[i].barycentric_coords(pos, uv))
{
const int px = origs[i][0].x()
- + coords.x() * (origs[i][2].x() - origs[i][0].x())
- + coords.y() * (origs[i][1].x() - origs[i][0].x());
+ + uv.x() * (origs[i][2].x() - origs[i][0].x())
+ + uv.y() * (origs[i][1].x() - origs[i][0].x());
const int py = origs[i][0].y()
- + coords.x() * (origs[i][2].y() - origs[i][0].y())
- + coords.y() * (origs[i][1].y() - origs[i][0].y());
+ + uv.x() * (origs[i][2].y() - origs[i][0].y())
+ + uv.y() * (origs[i][1].y() - origs[i][0].y());
int r = orig[py * orig_pitch + px * orig_depth + 2];
int g = orig[py * orig_pitch + px * orig_depth + 1];