# HG changeset patch # User Teemu Piippo # Date 1529233563 -10800 # Node ID d2bf2e59a3efa2705c8362851f72ab3e79fe3b19 # Parent 16eb4257e662497ac146284e8d51085a8d26ad6d replaced overloads with a new 'xyz' function diff -r 16eb4257e662 -r d2bf2e59a3ef src/canvas.cpp --- a/src/canvas.cpp Sun Jun 17 13:57:00 2018 +0300 +++ b/src/canvas.cpp Sun Jun 17 14:06:03 2018 +0300 @@ -104,8 +104,8 @@ { if (prepareGridLine(x)) { - glVertex(currentCamera().realize({x, -10000, 999})); - glVertex(currentCamera().realize({x, 10000, 999})); + xyz(glVertex3f, currentCamera().realize({x, -10000, 999})); + xyz(glVertex3f, currentCamera().realize({x, 10000, 999})); } } @@ -113,8 +113,8 @@ { if (prepareGridLine(y)) { - glVertex(currentCamera().realize({-10000, y, 999})); - glVertex(currentCamera().realize({10000, y, 999})); + xyz(glVertex3f, currentCamera().realize({-10000, y, 999})); + xyz(glVertex3f, currentCamera().realize({10000, y, 999})); } } } @@ -154,8 +154,8 @@ QPointF extremum = {cos(azimuth) * 10000, sin(azimuth) * 10000}; QPointF A = pole + extremum; QPointF B = pole - extremum; - glVertex(currentCamera().realize({A.x(), A.y(), 999})); - glVertex(currentCamera().realize({B.x(), B.y(), 999})); + xyz(glVertex3f, currentCamera().realize({A.x(), A.y(), 999})); + xyz(glVertex3f, currentCamera().realize({B.x(), B.y(), 999})); } } @@ -174,8 +174,8 @@ for (int i = 0; i < grid()->polarDivisions(); ++i) { - glVertex(points[i]); - glVertex(ring(points, grid()->polarDivisions())[i + 1]); + xyz(glVertex3f, points[i]); + xyz(glVertex3f, ring(points, grid()->polarDivisions())[i + 1]); } } } diff -r 16eb4257e662 -r d2bf2e59a3ef src/glShared.h --- a/src/glShared.h Sun Jun 17 13:57:00 2018 +0300 +++ b/src/glShared.h Sun Jun 17 14:06:03 2018 +0300 @@ -24,16 +24,6 @@ #include "generics/enums.h" #include "types/vertex.h" -inline void glTranslatef(const Vertex& vertex) -{ - glTranslatef(vertex.x, vertex.y, vertex.z); -} - -inline void glVertex(const Vertex& vertex) -{ - glVertex3f(vertex.x, vertex.y, vertex.z); -} - class LDObject; struct LDPolygon diff -r 16eb4257e662 -r d2bf2e59a3ef src/glrenderer.cpp --- a/src/glrenderer.cpp Sun Jun 17 13:57:00 2018 +0300 +++ b/src/glrenderer.cpp Sun Jun 17 14:06:03 2018 +0300 @@ -407,7 +407,7 @@ glTranslatef(0.0f, 0.0f, -2.0f); glTranslatef(panning (X), panning (Y), -zoom()); glMultMatrixf(padMatrix(m_rotation.toRotationMatrix()).constData()); - glTranslatef(-this->m_compiler->modelCenter()); + xyz(glTranslatef, -m_compiler->modelCenter()); } glEnableClientState (GL_NORMAL_ARRAY); diff -r 16eb4257e662 -r d2bf2e59a3ef src/parser.cpp --- a/src/parser.cpp Sun Jun 17 13:57:00 2018 +0300 +++ b/src/parser.cpp Sun Jun 17 14:06:03 2018 +0300 @@ -384,7 +384,7 @@ Vertex displacement = parseVertex (tokens, 2); // 2 - 4 QMatrix4x4 matrix; - matrix.translate(displacement.x, displacement.y, displacement.z); + matrix.translate(displacement.toVector()); QString referenceName = tokens[14]; for (int i = 0; i < 9; ++i) diff -r 16eb4257e662 -r d2bf2e59a3ef src/types/vertex.h --- a/src/types/vertex.h Sun Jun 17 13:57:00 2018 +0300 +++ b/src/types/vertex.h Sun Jun 17 14:06:03 2018 +0300 @@ -58,6 +58,15 @@ return vertex * scalar; } +/* + * Call 'function' with the x, y and z coordinates of 'vertex'. + */ +template +inline void xyz(Function function, const Vertex& vertex) +{ + function(vertex.x, vertex.y, vertex.z); +} + Q_DECLARE_METATYPE(Vertex) qreal distance(const Vertex& one, const Vertex& other); unsigned int qHash(const Vertex& key);