Sun, 17 Jun 2018 14:06:03 +0300
replaced overloads with a new 'xyz' function
src/canvas.cpp | file | annotate | diff | comparison | revisions | |
src/glShared.h | file | annotate | diff | comparison | revisions | |
src/glrenderer.cpp | file | annotate | diff | comparison | revisions | |
src/parser.cpp | file | annotate | diff | comparison | revisions | |
src/types/vertex.h | file | annotate | diff | comparison | revisions |
--- 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]); } } }
--- 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
--- 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);
--- 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)
--- 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<typename Function> +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);