**diff options**

author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-01-17 19:19:39 +0100 |
---|---|---|

committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-12 02:03:06 +0000 |

commit | 2c55e121c22601d365aa353cfa39ee856770855c (patch) | |

tree | 0af68cb64d2e0e28542872589b3083b0fbbaec21 /src/gui/math3d/qmatrix4x4.cpp | |

parent | 121ad4c22f55be831105943ba11a4ff51b732698 (diff) |

QMatrix4x4: deprecate operator*(QVector3D, QMatrix4x4)v6.1.0-alpha1

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.
Change-Id: I41b64d8ab7eb6126dc4c49fe29cf3f1b7afc7987
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 654a2164994974639e62f9d388408ed559b797a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>

Diffstat (limited to 'src/gui/math3d/qmatrix4x4.cpp')

-rw-r--r-- | src/gui/math3d/qmatrix4x4.cpp | 8 |

1 files changed, 5 insertions, 3 deletions

diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 591809df31..947af641d1 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -627,16 +627,18 @@ QMatrix4x4& QMatrix4x4::operator/=(float divisor) #ifndef QT_NO_VECTOR3D +#if QT_DEPRECATED_SINCE(6, 1) + /*! \fn QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix) \relates QMatrix4x4 + \obsolete Convert the QVector3D to a QVector4D first, then multiply. + Returns the result of transforming \a vector according to \a matrix, - with the matrix applied post-vector. + with the matrix applied post-vector. The vector is transformed as a point. */ -#if QT_DEPRECATED_SINCE(6, 1) - /*! \fn QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector) \relates QMatrix4x4 |