replaced GLRotationMatrix with QMatrix4x4

Sun, 17 Jun 2018 13:57:00 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 17 Jun 2018 13:57:00 +0300
changeset 1404
16eb4257e662
parent 1403
7a2d84112983
child 1405
d2bf2e59a3ef

replaced GLRotationMatrix with QMatrix4x4

src/basics.h file | annotate | diff | comparison | revisions
src/canvas.cpp file | annotate | diff | comparison | revisions
src/glShared.h file | annotate | diff | comparison | revisions
src/glcamera.cpp file | annotate | diff | comparison | revisions
src/glcamera.h file | annotate | diff | comparison | revisions
src/glrenderer.cpp file | annotate | diff | comparison | revisions
src/glrenderer.h file | annotate | diff | comparison | revisions
src/types/vertex.cpp file | annotate | diff | comparison | revisions
src/types/vertex.h file | annotate | diff | comparison | revisions
--- a/src/basics.h	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/basics.h	Sun Jun 17 13:57:00 2018 +0300
@@ -44,7 +44,6 @@
 	using Super = SUPER;
 
 class LDObject;
-using GLRotationMatrix = QMatrix4x4;
 
 enum Axis
 {
--- a/src/canvas.cpp	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/canvas.cpp	Sun Jun 17 13:57:00 2018 +0300
@@ -189,13 +189,13 @@
 	if (this->camera() < Camera::Free)
 	{
 		GLfloat cullz = this->cullValues[static_cast<int>(this->camera())];
-		GLRotationMatrix matrix = {
+		QMatrix4x4 matrix = {
 			1, 0, 0, cullz,
 			0, 1, 0, 0,
 			0, 0, 1, 0,
 			0, 0, 0, 1,
 		};
-		glMultMatrixf(matrix);
+		glMultMatrixf(matrix.constData());
 	}
 }
 
--- a/src/glShared.h	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/glShared.h	Sun Jun 17 13:57:00 2018 +0300
@@ -24,11 +24,6 @@
 #include "generics/enums.h"
 #include "types/vertex.h"
 
-inline void glMultMatrixf(const GLRotationMatrix& matrix)
-{
-	glMultMatrixf(matrix.constData());
-}
-
 inline void glTranslatef(const Vertex& vertex)
 {
 	glTranslatef(vertex.x, vertex.y, vertex.z);
--- a/src/glcamera.cpp	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/glcamera.cpp	Sun Jun 17 13:57:00 2018 +0300
@@ -236,7 +236,7 @@
 	return m_name;
 }
 
-const GLRotationMatrix& GLCamera::transformationMatrix() const
+const QMatrix4x4& GLCamera::transformationMatrix() const
 {
 	return m_rotationMatrix;
 }
@@ -244,9 +244,9 @@
 /*
  * Returns the camera's transformation matrix, scaled by the given scale value.
  */
-GLRotationMatrix GLCamera::transformationMatrix(double scale) const
+QMatrix4x4 GLCamera::transformationMatrix(double scale) const
 {
-	GLRotationMatrix matrix = m_rotationMatrix;
+	QMatrix4x4 matrix = m_rotationMatrix;
 
 	for (int i = 0; i < 4; ++i)
 	for (int j = 0; j < 4; ++j)
@@ -255,7 +255,7 @@
 	return matrix;
 }
 
-static const GLRotationMatrix ldrawToIdealAdapterMatrix = {1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1};
+static const QMatrix4x4 ldrawToIdealAdapterMatrix = {1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1};
 
 /*
  * Converts from rea co-ordinates to ideal co-ordinates.
@@ -275,19 +275,19 @@
 	return idealCoordinates.transformed(ldrawToIdealAdapterMatrix).transformed(m_rotationMatrix.inverted());
 }
 
-GLRotationMatrix GLCamera::realMatrix() const
+QMatrix4x4 GLCamera::realMatrix() const
 {
 	/* glOrtho(-virtualSize.width(), virtualSize.width(),
 			-virtualSize.height(), virtualSize.height(),
 			-1000.0f, 1000.0f); */
-	GLRotationMatrix ortho {
+	QMatrix4x4 ortho {
 		1 / float(m_virtualSize.width()), 0, 0, 0,
 		0, 1 / float(m_virtualSize.height()), 0, 0,
 		0, 0, -0.0001, 0,
 		0, 0, 0, 1
 	};
 
-	GLRotationMatrix panningMatrix {
+	QMatrix4x4 panningMatrix {
 		1, 0, 0, float(m_panningX),
 		0, 1, 0, float(m_panningY),
 		0, 0, 1, 0,
--- a/src/glcamera.h	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/glcamera.h	Sun Jun 17 13:57:00 2018 +0300
@@ -22,7 +22,7 @@
 
 struct FixedCameraParameters
 {
-	GLRotationMatrix rotationMatrix;
+	QMatrix4x4 rotationMatrix;
 	Axis localX;
 	Axis localY;
 	bool negatedX;
@@ -59,12 +59,12 @@
 	Q_SLOT void rendererResized(int width, int height);
 	void setPanning(double x, double y);
 	void setZoom(double zoom);
-	const GLRotationMatrix& transformationMatrix() const;
-	GLRotationMatrix transformationMatrix(double scale) const;
+	const QMatrix4x4& transformationMatrix() const;
+	QMatrix4x4 transformationMatrix(double scale) const;
 	const QSizeF& virtualSize() const;
 	double zoom() const;
 	void zoomNotch(bool inward);
-	GLRotationMatrix realMatrix() const;
+	QMatrix4x4 realMatrix() const;
 
 private:
 	QString m_name;
@@ -74,7 +74,7 @@
 	double m_zoom = 30;
 	QSize m_size;
 	QSizeF m_virtualSize;
-	GLRotationMatrix m_rotationMatrix;
+	QMatrix4x4 m_rotationMatrix;
 	Axis m_localX = X; // Which axis to use for Y
 	Axis m_localY = Y; // Which axis to use for Y
 	bool m_isFree = false; // Is this the free camera?
--- a/src/glrenderer.cpp	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/glrenderer.cpp	Sun Jun 17 13:57:00 2018 +0300
@@ -37,15 +37,15 @@
 const QPen GLRenderer::thinBorderPen {QColor {0, 0, 0, 208}, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin};
 
 // Transformation matrices for the fixed cameras.
-const GLRotationMatrix GLRenderer::topCameraMatrix = GLRotationMatrix {};
-const GLRotationMatrix GLRenderer::frontCameraMatrix = {1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1};
-const GLRotationMatrix GLRenderer::leftCameraMatrix = {0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1};
-const GLRotationMatrix GLRenderer::bottomCameraMatrix = {1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1};
-const GLRotationMatrix GLRenderer::backCameraMatrix = {-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1};
-const GLRotationMatrix GLRenderer::rightCameraMatrix = {0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1};
+const QMatrix4x4 GLRenderer::topCameraMatrix = QMatrix4x4 {};
+const QMatrix4x4 GLRenderer::frontCameraMatrix = {1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1};
+const QMatrix4x4 GLRenderer::leftCameraMatrix = {0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1};
+const QMatrix4x4 GLRenderer::bottomCameraMatrix = {1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1};
+const QMatrix4x4 GLRenderer::backCameraMatrix = {-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1};
+const QMatrix4x4 GLRenderer::rightCameraMatrix = {0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1};
 
 // Conversion matrix from LDraw to OpenGL coordinates.
-const GLRotationMatrix GLRenderer::ldrawToGLAdapterMatrix = {1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1};
+const QMatrix4x4 GLRenderer::ldrawToGLAdapterMatrix = {1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1};
 
 /*
  * Constructs a GL renderer.
@@ -359,7 +359,7 @@
 /*
  * Pads a 3×3 matrix into a 4×4 one by adding cells from the identity matrix.
  */
-GLRotationMatrix padMatrix(const QMatrix3x3& stub)
+QMatrix4x4 padMatrix(const QMatrix3x3& stub)
 {
 	return {
 		stub(0, 0), stub(0, 1), stub(0, 2), 0,
@@ -395,8 +395,8 @@
 		glMatrixMode (GL_PROJECTION);
 		glPushMatrix();
 		glLoadIdentity();
-		glMultMatrixf(currentCamera().realMatrix());
-		glMultMatrixf(ldrawToGLAdapterMatrix);
+		glMultMatrixf(currentCamera().realMatrix().constData());
+		glMultMatrixf(ldrawToGLAdapterMatrix.constData());
 		drawFixedCameraBackdrop();
 	}
 	else
--- a/src/glrenderer.h	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/glrenderer.h	Sun Jun 17 13:57:00 2018 +0300
@@ -81,13 +81,13 @@
 	void setSelectionModel(QItemSelectionModel* selectionModel);
 
 	static const QPen thinBorderPen;
-	static const GLRotationMatrix topCameraMatrix;
-	static const GLRotationMatrix frontCameraMatrix;
-	static const GLRotationMatrix leftCameraMatrix;
-	static const GLRotationMatrix bottomCameraMatrix;
-	static const GLRotationMatrix backCameraMatrix;
-	static const GLRotationMatrix rightCameraMatrix;
-	static const GLRotationMatrix ldrawToGLAdapterMatrix;
+	static const QMatrix4x4 topCameraMatrix;
+	static const QMatrix4x4 frontCameraMatrix;
+	static const QMatrix4x4 leftCameraMatrix;
+	static const QMatrix4x4 bottomCameraMatrix;
+	static const QMatrix4x4 backCameraMatrix;
+	static const QMatrix4x4 rightCameraMatrix;
+	static const QMatrix4x4 ldrawToGLAdapterMatrix;
 
 signals:
 	void objectHighlightingChanged(const QModelIndex& oldIndex, const QModelIndex& newIndex);
--- a/src/types/vertex.cpp	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/types/vertex.cpp	Sun Jun 17 13:57:00 2018 +0300
@@ -195,7 +195,7 @@
 /*
  * Transforms this vertex with a tranformation matrix and returns the result.
  */
-Vertex Vertex::transformed(const GLRotationMatrix& matrix) const
+Vertex Vertex::transformed(const QMatrix4x4& matrix) const
 {
 	return {
 		matrix(0, 0) * this->x
--- a/src/types/vertex.h	Sun Jun 17 13:53:33 2018 +0300
+++ b/src/types/vertex.h	Sun Jun 17 13:57:00 2018 +0300
@@ -34,7 +34,7 @@
 	QVector3D toVector() const;
 	void transform(const QMatrix4x4& matrix);
 	void rotate(const QQuaternion& orientation);
-	Vertex transformed(const GLRotationMatrix& matrix) const;
+	Vertex transformed(const QMatrix4x4& matrix) const;
 	void setCoordinate(Axis ax, qreal value);
 
 	Vertex& operator+=(const QVector3D& other);

mercurial