Enable the scenegraph to remove its QMatrix4x4_Accessor hack

Expose flagBits via a public function marked as internal.

Task-number: QTBUG-82670
Change-Id: Ia64d934d3dda3e718357cf4e3c32866a613a4722
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
This commit is contained in:
Laszlo Agocs 2020-05-28 13:06:37 +02:00
parent 07ded4912f
commit 1f88ccc8ad
2 changed files with 29 additions and 5 deletions

View File

@ -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
/*!

View File

@ -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];