summaryrefslogtreecommitdiff
path: root/src/gui/math3d/qmatrix4x4.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-01-17 19:19:39 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-02-11 21:16:22 +0100
commit654a2164994974639e62f9d388408ed559b797a3 (patch)
tree2c03e3a03fc4083c0b759e932caef43f1219298e /src/gui/math3d/qmatrix4x4.h
parentd40ba4adeecda74e246784eee02793ecacbecdcc (diff)
downloadqtbase-654a2164994974639e62f9d388408ed559b797a3.tar.gz
QMatrix4x4: deprecate operator*(QVector3D, QMatrix4x4)
The operation is sketchy for a number of reasons: 1) Mathematically, it doesn't make sense. The code interprets the QVector3D as a point, extending it with w=1, and uses it as a row vector. But similarly, the vector could be intepreted as a directional vector, with w=0. No semantic is "better" than the other. 2) QMatrix4x4 is not meant to be post-multiplied. Granted, one could use a QMatrix4x4 as arbitrary storage for 16 floats, but QMatrix4x4 builds itself to be always *pre* multiplied (e.g. translate changes the 4th column, not the 4th row). We can keep post multiplication for the general case if we do it against a QVector4D, but I don't feel that we should support it also for QVector3D. [ChangeLog][QtGui][QMatrix4x4] The multiplication operator (operator*) between a QVector3D and a QMatrix4x4 has been deprecated. User code needs to extend the QVector3D to a QVector4D first (by specifying the intended w coordinate), and then multiply the QVector4D by the matrix. Pick-to: 6.1 Change-Id: I41b64d8ab7eb6126dc4c49fe29cf3f1b7afc7987 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/gui/math3d/qmatrix4x4.h')
-rw-r--r--src/gui/math3d/qmatrix4x4.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 05e882d7c4..7b0c790ab6 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -109,9 +109,9 @@ public:
#ifndef QT_NO_VECTOR3D
#if QT_DEPRECATED_SINCE(6, 1)
friend QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector);
-#endif
friend QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix);
#endif
+#endif
#ifndef QT_NO_VECTOR4D
friend QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix);
friend QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector);
@@ -720,6 +720,9 @@ inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
#ifndef QT_NO_VECTOR3D
+#if QT_DEPRECATED_SINCE(6, 1)
+
+QT_DEPRECATED_VERSION_X_6_1("Extend the QVector3D to a QVector4D before multiplying")
inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
{
float x, y, z, w;
@@ -745,8 +748,6 @@ inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
return QVector3D(x / w, y / w, z / w);
}
-#if QT_DEPRECATED_SINCE(6, 1)
-
QT_DEPRECATED_VERSION_X_6_1("Use matrix.map(vector) or matrix.mapVector(vector) instead")
inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
{