summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp17
-rw-r--r--src/gui/math3d/qmatrix4x4.h17
2 files changed, 29 insertions, 5 deletions
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index 2adb94573b..2f7931d099 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -1280,6 +1280,23 @@ void QMatrix4x4::projectedRotate(float angle, float x, float y, float z)
*this *= rot;
}
+/*!
+ \fn int QMatrix4x4::flags() const
+ \internal
+*/
+
+/*!
+ \enum QMatrix4x4::Flags
+ \internal
+ \omitvalue Identity
+ \omitvalue Translation
+ \omitvalue Scale
+ \omitvalue Rotation2D
+ \omitvalue Rotation
+ \omitvalue Perspective
+ \omitvalue General
+*/
+
#ifndef QT_NO_QUATERNION
/*!
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 95f4db92ec..64bf9c607e 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -185,12 +185,10 @@ public:
#endif
void projectedRotate(float angle, float x, float y, float z);
-private:
- float m[4][4]; // Column-major order to match OpenGL.
- int flagBits; // Flag bits from the enum below.
// When matrices are multiplied, the flag bits are or-ed together.
- enum {
+ // Note that the ordering of the bit values matters. (ident < t < s < r2d < r < p)
+ enum Flag {
Identity = 0x0000, // Identity matrix
Translation = 0x0001, // Contains a translation
Scale = 0x0002, // Contains a scale
@@ -199,6 +197,13 @@ private:
Perspective = 0x0010, // Last row is different from (0, 0, 0, 1)
General = 0x001f // General matrix, unknown contents
};
+ Q_DECLARE_FLAGS(Flags, Flag)
+
+ Flags flags() const { return flagBits; }
+
+private:
+ float m[4][4]; // Column-major order to match OpenGL.
+ Flags flagBits;
// Construct without initializing identity matrix.
explicit QMatrix4x4(int) { }
@@ -206,6 +211,8 @@ private:
QMatrix4x4 orthonormalInverse() const;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMatrix4x4::Flags)
+
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
@@ -627,7 +634,7 @@ inline QMatrix4x4 operator-(const QMatrix4x4& m1, const QMatrix4x4& m2)
inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
{
- int flagBits = m1.flagBits | m2.flagBits;
+ QMatrix4x4::Flags flagBits = m1.flagBits | m2.flagBits;
if (flagBits < QMatrix4x4::Rotation2D) {
QMatrix4x4 m = m1;
m.m[3][0] += m.m[0][0] * m2.m[3][0];