summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d
Commit message (Collapse)AuthorAgeFilesLines
* QQuaternion: long live Axes / toAxes()Marc Mutz7 days2-13/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compilers hate out parameters, so provide a replacement for getAxes(), toAxes(), that returns the result in a struct Axes { x, y, z } instead. Then make getAxes() an inline wrapper around a toAxes() call, porting from Q_ASSERT(x && y && z) to Q_PRE(x); Q_PRE(y); Q_PRE(z); as a drive-by. The separation gives a more detailed error when triggered, and produces a shorter assertion string. Add tests, naturally, and port getAxes() calls that don't test getAxes() to the new function. There appear to be no other in-tree users that could be ported. For symmetry reasons, also add a fromAxes(Axes) overload. Take the argument by value, to avoid the compiler having to deal with aliasing analysis. At worst, pass-by-value is like pass-by-cref, and whether or not the extra copy is added or, since C++17, elided, depends on the specific call. Suppress Clazy's schizophrenic warning, which complains that we don't take (QVector3D, QVector3D, QVector3D) by value, but also if we take struct {QVector x,y,z} by value. [ChangeLog][QtGui][QQuaternion] Added toAxes(), a getAxes() replacement. Task-number: QTBUG-138199 Change-Id: Ie26e16528dc06806e59e54eff2d656a33c322bad Reviewed-by: Volker Hilsheimer <[email protected]>
* QQuaternion: document some get*() preconditionsMarc Mutz8 days1-0/+12
| | | | | | | | | | | | | | | | | | | | The functions assert that the pointers are all non-null, so we should document it as a precondition. There may be more preconditions inherited from the underlying math, but I can't find my Algebra book, and it's pre-existing, so maybe for another patch. Amends: - 1e441d298db5e7ad1635067106e4b7ed251fd4bd (getAxes()) - 88142e73d5e062cf26638511a42140b59ef736cc (getEulerAngles()) - 5d784deb71edd1e6584cd2f118d27dd3be2da5e6 (getAxisAndAngle() née toAxisAndAngle()). Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Idadb6183c8cabdaf3bdedb73794d3fc5d6052bac Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
* [docs] QQuaternion: fix links to QVector3D functionsMarc Mutz9 days1-2/+3
| | | | | | | | | | | | | | Without qualification, qdoc links x() to this class' x(). But the documentation means QVector3D::x(), so we need an explicit \l here. Similar to ab1ce95c8ce38683477373cf84ba5686ea00efed for QString/QByteArray. Amends 88142e73d5e062cf26638511a42140b59ef736cc. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I6eb5ca38f328ce36988e10e3221b801e68629938 Reviewed-by: Volker Hilsheimer <[email protected]>
* [docs] QQuaternion: fix grammarMarc Mutz9 days1-1/+1
| | | | | | | | | | "Angles" are plural, so the verb has to be in plural form, too. Amends 88142e73d5e062cf26638511a42140b59ef736cc. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ic19ba9de8b7f33fafb35eff7f256698ebf4b8443 Reviewed-by: Volker Hilsheimer <[email protected]>
* [docs] QQuaternion: fix grammar in toRotationMatrix()Marc Mutz9 days1-2/+2
| | | | | | | | | | Need definite acticles here, not indefinite one. Amends ba640a75a5cc9fec63a5204ccf143dbb7f398842. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I843b9d97276308412d566fbd453c706c9570c876 Reviewed-by: Volker Hilsheimer <[email protected]>
* QQuaternion: rename the fromEulerAngles() argumentMarc Mutz10 days2-7/+7
| | | | | | | | | | | | The eulerAngles name will clash with a function I intend to add, of the same name, probably triggering -Wshadow. Besides, this fixes long lines and isn't any less readable. Picking all the way since it's 100% risk-free. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Iea552c6cad4ad20164cf0cc462cb1dcb2bc752c0 Reviewed-by: Volker Hilsheimer <[email protected]>
* QQuaternion: fix MingW "redeclared without dllimport attribute" errorMarc Mutz10 days1-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I don't know why, but after years of no changes to the header, the CI on 6.5 started to throw the dreaded qquaternion.h:138:8: error: 'QQuaternion::QQuaternion()' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] Fix by plastering the class with inline keywords. This just goes to show that separating definition and declaration of inline functions (and exporting non-polymorphic classes wholesale) is usually a bad idea. Remove the inline keywords from the definitions to order to use the linker on all platforms to verify we marked all functions inline that are. Later releases are unaffected, because f9f1272e7c438b79591032877f2b386af8085c3f plastered the class with constexpr, which implies inline. Manual conflict resolution for dev: - there were three inline keywords left outside the class after f9f1272e7c438b79591032877f2b386af8085c3f, this patch removes them, so mark it as a cherry-pick of the 6.5 change, which did the same Pick-to: 6.10 6.9 6.8 Change-Id: I5f044e4aae8e31173c0717d4b70d53fece99b927 Reviewed-by: Volker Hilsheimer <[email protected]> (cherry picked from commit fccb455a4f94e5bc95ba6ad54a46fa71439314bb) Reviewed-by: Daniel Smith <[email protected]>
* [docs] QQuaternion: fix \overload in toEulerAngles() docsMarc Mutz12 days1-1/+0
| | | | | | | | | | | | | The function is no longer overloaded. getEulerAngles() used to be called toEulerAngles() (88142e73d5e062cf26638511a42140b59ef736cc), but was later renamed to the idiomatic get-prefix (1872857ca72658cd58c0c39b31da493f794be6ca). Amends 1872857ca72658cd58c0c39b31da493f794be6ca. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ibc71635aa836e9c33fb2b88ce30cc7a35fbf1291 Reviewed-by: Volker Hilsheimer <[email protected]>
* QQuaternion: fix incorrect Qt 7 export on inline functionMarc Mutz12 days1-1/+1
| | | | | | | | | | | | | | The fromEulerAngles(QVector3D) function is and will stay inline, as it's just forwarding to the (float, float, float) overload of the same name. So it needn't be, and shan't, either, be exported come Qt 7. Remove the QT7_ONLY export. Partially reverts / amends f9f1272e7c438b79591032877f2b386af8085c3f. Pick-to: 6.10 6.9 6.8 Change-Id: I8ed0054ca89ab04ef0b06bea953473e91789fda6 Reviewed-by: Volker Hilsheimer <[email protected]>
* QQuaternion: comment all #endif'sMarc Mutz12 days1-5/+5
| | | | | | | | | | | | | | | It's easier to comprehend what's going on, because there are quite a few different ones here. Exception: if the #if block contains only very few lines (max four or so, didn't count), then a naked #endif is ok, and arguably easier on the eye, so leave them in that case. Amends the start of the public history. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ib1b27859344916caa17dc1ff0010b6b10d34bb13 Reviewed-by: Volker Hilsheimer <[email protected]>
* QQuaternion: make a mutable function-static int[] constexprMarc Mutz2025-06-251-1/+1
| | | | | | | | | | | | | | | The array, despite being declared mutable, is never modified (and doing so would be a data race if threads concurrently call QQuaternion::fromRotationMatrix(), because it was declared static). Fix by making it constexpr instead. It need not be static, as the compiler will just optimize it away, anyway. Amends ba640a75a5cc9fec63a5204ccf143dbb7f398842. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I0a37f7718b1e79f34d8dd56dc56d951cb8a1d44c Reviewed-by: Friedemann Kleint <[email protected]>
* Doc: Fix incorrect \fn signaturesTopi Reinio2025-03-051-2/+1
| | | | | | | | | | | | | Several \fn signatures were either incorrect or missing qualifiers required to make QDoc match the documentation with the declarations. These were not caught in the CI when testing documentation builds due to a bug in QDoc. Pick-to: 6.9 Task-number: QTBUG-134250 Change-Id: I7a4af11d9bc3687597b348cc2d4ee15212e0281f Reviewed-by: Thiago Macieira <[email protected]>
* qFuzzy(Compare|IsNull)(): mark as noexceptMarc Mutz2024-08-282-2/+2
| | | | | | | | | | | | | | These all cannot fail, so can and should be noexcept. Most were already. Found in API-review. [ChangeLog][QtCore/QtGui] All qFuzzyCompare() and qFuzzyIsNull() overloads are now noexcept. Pick-to: 6.8 Change-Id: I67a2981ea4af9be0370becf84103822fd766ab5e Reviewed-by: Ivan Solovev <[email protected]>
* QQuaterion: fix formattingIvan Solovev2024-01-151-7/+13
| | | | | | | | | | | | Fix indentation, split too long lines. Amends f9f1272e7c438b79591032877f2b386af8085c3f Found in 6.7 API Review Pick-to: 6.7 Change-Id: I3e9e3647afbe1a49fe78258177aff5cb878ce030 Reviewed-by: Volker Hilsheimer <[email protected]>
* QQuaternion: make methods constexpr, noexcept; fix styleVolker Hilsheimer2023-12-092-136/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The class stores all data inline, and most member functions are inline already with trivial arithmetic operations on those data members. So we can make the class almost completely constexpr. This includes member functions that construct or use QVector3D/4D, as those types are also fully constexpr. Almost all inline (and now constexpr) member functions can then also be made noexcept, with the exception of the division operators that don't check the divisor for 0. qFuzzyCompare(float, float) is not noexcept, but it has no preconditions and never throws, so we can make the QQuaternion overload noexcept. Remove const from values returned by arithmetic operators, and fix whitespace style in prototypes (also the few that are not already touched by the other changes). Prepare unexporting the class wholesale in Qt 7; we only have to export out-of-line functions, but can't make that change in Qt 6, as the implicitly defined special member functions are exported (at least on MSVC). Change-Id: I3e43232bf66009352e8de937c07b2985147fb33c Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Sami Varanka <[email protected]>
* Doc: Fix \fn template arguments for Qt GuiTopi Reinio2023-11-181-1/+1
| | | | | | | | | Upcoming changes to QDoc require accurate definition for template arguments in \fn commands. Task-number: QTBUG-118080 Change-Id: I75f8956c5fc094402837f96bd4598b60e3a7c649 Reviewed-by: Luca Di Sera <[email protected]>
* Use atan2() in Quaternion axis-and-angleEdward Welbourne2023-08-181-1/+1
| | | | | | | | | | | | | | | | | It's more numerically robust than acos() - we can't hit a range error if we get strange rounding effects - and we've got the value of the sin of the angle already (it's the length of the x, y, z part), so might as well use it. As length is necessarily positive, atan2() will give an upper-half-plane resolution, matching what acos() gave us. This incidentally means that you no longer need to normalize() your quaternion before you ask for axis and angle. Task-number: QTBUG-114313 Change-Id: If3fa2b371c72991f1f8f151f78ef7f9180aa87cf Reviewed-by: Matthias Rauter <[email protected]> Reviewed-by: Jøger Hansegård <[email protected]> Reviewed-by: Eirik Aavitsland <[email protected]>
* Fix for QQuaternion normalize when length > 1Paul Olav Tvete2023-06-121-3/+1
| | | | | | | | | | | | If the length of the quaternion was slightly larger than 1, the resulting quaternion would be invalid, causing getAxisAndAngle() to fail. Fixes: QTBUG-114313 Pick-to: 6.5 6.6 Change-Id: I8f0616e74590dd6cfee0ce913d214c8e280c4df4 Reviewed-by: Laszlo Agocs <[email protected]> Reviewed-by: Andy Nichols <[email protected]>
* Verify fix for manual get<I> calls for QVector<N>DMarc Mutz2023-03-221-0/+2
| | | | | | | | | | | | | | | The necessary QT_ENABLE_P0846_SEMANTICS_FOR is already provided by qpoint.h) here. Add a test to confirm it works. Amends 0e22001a3bb070d4e9956e89543ec0e5ac6f23f8. [ChangeLog][QtGui][QVector2/3/4D] Fixed manual get<I>() calls (Tuple Protocol) in C++17 mode. Task-number: QTBUG-111598 Change-Id: Id4a118b6439c2d1471b921f8d92ee558f9902eab Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Modernize Tuple Protocol implementationsMarc Mutz2023-03-161-6/+9
| | | | | | | | | | | | | | | | | The existing get<I>() implementations are very clever™, if I, as their inventor in at least the Qt ecosystem, may say so myself. E.g. the () around the return value are absolutely required, to ensure we return by reference, not by value, through decltype(auto). C++23 gives us forward_like, which doesn't require the parentheses, because it always returns a reference. Also replace decay_t with C++20's remove_cvref_t, the latter being more efficient (performs less work). Change-Id: Ic9ed0c25e6d6bfbd77d7c85858a8d97fe58be615 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* QVector<N>D: simplify get<I>() implementationMarc Mutz2023-03-161-18/+3
| | | | | | | | instead of if (I == x) return ~~~[x]; just always return ~~~[I]. Pick-to: 6.5 Change-Id: I236159480ab90201f7e3f6f90fdcd1cab5d3a223 Reviewed-by: Thiago Macieira <[email protected]>
* Allow specify distance to plane for QTransformJiDe Zhang2022-08-182-11/+34
| | | | | | | | | | | | | | | | | The default camera to plane distance is 1024, when rotating a big image along the x or y axis, some areas of the screen may move above the camera, causing the rotation to fail. A new rotation interface has been added to allow users to specify the distance from the camera to the plane themselves when rotating the QImage. Also, this support has been added to QMatrix4x4::projectedRotate. [ChangeLog][QtGui][QTransform] Added overloads to rotate() and rotateRadians() that allow specifying of the distance to the rotation plane. Fixes: QTBUG-105088 Change-Id: I81f629916ddd9b6ab84e0282191e4284a88a85f5 Reviewed-by: Eirik Aavitsland <[email protected]>
* Fix typos in docs and commentsKai Köhne2022-06-152-4/+4
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-05-1611-423/+27
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Lars Knoll <[email protected]> Reviewed-by: Jörg Bornemann <[email protected]>
* Update comments in QQuaternion::getEulerAnglesInho Lee2022-04-271-2/+3
| | | | | | | | | | | A comment from the patch 6ffc8d8eb6c44fbd51e37770e7013c4610ead96d is a little ambiguous. This patch is just to give information about the modification. Task-number: QTBUG-72103 Pick-to: 6.3 6.2 5.15 Change-Id: I6bfc3ae926c118de0d969a4b44f438c24f8d4f72 Reviewed-by: Edward Welbourne <[email protected]>
* QtGui: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN [1/2]: public APIMarc Mutz2022-04-052-8/+17
| | | | | | | | | | | | | It's one of our best tools to improve compile times. Can't backport to Qt 6.3 or 6.2 because this change introduces new exported symbols. Task-number: QTBUG-102206 Change-Id: Ib8224ed60afa893744f369fe7394d27e89b66c11 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Mårten Nordheim <[email protected]>
* Fix up some QMatrix4x4 docsLaszlo Agocs2022-03-292-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The deprecation note for one of the operator* is wrong: Using mapVector() is never the right choice given the deprecated operator* itself is implemented by calling map(). It could be that in some cases the results are identical so one can get away with migrating to mapVector(), but this is incorrect in other cases and causes regressions all over the place. Thus we should only recommend using map() instead, never mapVector(). As shown by recent experiences, the current docs are insufficient/wrong and caused a number of regressions in the Qt code base as well. Also enhance some related docs. It could be that the wording is not always academically correct, however having some additional notes in there help make it obvious to the reader (or at least raise some alarms) that there are important differences between map and mapVector. Also improve the note for the other deprecated operator*. There is only one way to convert to a vec4, given the existing implementation of the operator, and that is by using 1 for w. Make this clear to the reader. Pick-to: 6.3 6.2 Change-Id: I1d8dbca44fdc103ab62d49bfc1d4ce37a9bc130b Reviewed-by: Mårten Nordheim <[email protected]> Reviewed-by: Andy Nichols <[email protected]>
* Miscellanea fixes for QT_TYPESAFE_FLAGS in our headersGiuseppe D'Angelo2022-03-071-10/+10
| | | | | | | | | | | | | | | | | | | | | In preparation for adding it to headersclean. Some remarks: * QStandardItemModel builds just fine (QFlags has comparison operators against literal zero); the warning we however get is about 0 converted to a null pointer constant. There's nothing we can do about that one (even <compare> gives such a warning). * Several code was depending on flags->int conversions. Add toInt(), but also cast again to the expected type to avoid warnings in case toInt() returns unsigned int. * Ported to explicit casts to bool rather than test(Any)Flag to minimize confusion for people unfamiliar with the test*Flag methods. Change-Id: I5be280ac33a0b38e2680096f0e79129fd55ba241 Reviewed-by: Marc Mutz <[email protected]>
* QtGui/math3d: Fix QQuaternion::getEulerAngles for GimbalLock casesYuya Nishihara2022-01-161-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is heavily inspired by the patch written by Inho Lee <[email protected]>, which says "There is a precision problem in the previous algorithm when checking pitch value. (In the case that the rotation on the X-axis makes Gimbal lock.)" In order to work around the precision problem, this patch does: 1. switch to the algorithm described in the inline comment to make the story simple. 2. forcibly normalize the {x, y, z, w} components to eliminate fractional errors. 3. set threshold to avoid hidden division by cos(pitch) =~ 0. From my testing which compares dot product of the original quaternion and the one recreated from Euler angles, calculation within float range seems okay. (abs(normalize(q_orig) * normalize(q_roundtrip)) >= 0.99999) Many thanks to Inho Lee for the original patch and discussion about rounding errors. Fixes: QTBUG-72103 Pick-to: 6.3 6.2 5.15 Change-Id: I8995e4affe603111ff2303a0dfcbdb0b1ae03f10 Reviewed-by: Yuya Nishihara <[email protected]> Reviewed-by: Inho Lee <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* gui: Fix typos in documentationJonas Kvinge2021-10-121-4/+4
| | | | | | Pick-to: 5.15 6.2 Change-Id: I533f5a55cd0cd60a76990b552d7dab51a301ac1c Reviewed-by: Giuseppe D'Angelo <[email protected]>
* Purge Q_NO_TEMPLATE_FRIENDS and platforms lacking support for themFabian Kosmale2021-10-021-4/+0
| | | | | | | | | | Given that we rely on C++17, it should be safe to mandate that level of language support. Change-Id: If07ccb36bea2a5113a8f5aacf635be7d2590baf7 Reviewed-by: Lars Knoll <[email protected]> Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Thiago Macieira <[email protected]>
* Doc: Ensure deprecated APIs in Gui are documented as suchNico Vertriest2021-07-261-4/+4
| | | | | | | | | | | Added missing #if-ery and deprecation macros to a QFont constructor that was only documented as deprecated. Fixes: QTBUG-94521 Fixes: QTBUG-95310 Pick-to: 6.2 6.1 Change-Id: I3d0418a3f7dca191a9068cc22627fe4deb7c53c5 Reviewed-by: Edward Welbourne <[email protected]>
* tst_QMatrixNxN: fix type-punning warningMarc Mutz2021-06-301-0/+4
| | | | | | | | | | | | | ... by making the test class a friend of the CUT, as we do elsewhere for the same reason. This allows to remove the duplicated enum and struct in favor of using The Real Thing™, which means the test can no longer go out of sync with the CUT anymore. Change-Id: I87dc8bb4a5476ae4fc99e006c4690e96d2f530d2 Reviewed-by: Giuseppe D'Angelo <[email protected]> Reviewed-by: Friedemann Kleint <[email protected]>
* QtGui/math3d : Fix QQuaternion::getEulerAnglesInho Lee2021-06-011-1/+5
| | | | | | | | | | | When rotating M_PI_2 based on x-axis, quaternion to euler conversion makes NaN for the x-rotation value. This patch fixes this corner case. Fixes: QTBUG-93600 Pick-to: 6.1 6.0 5.15 Change-Id: Ice321a80ad90dba9cf3ee3a14ec7d3d047c21bd3 Reviewed-by: Laszlo Agocs <[email protected]> Reviewed-by: Andy Nichols <[email protected]>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-4/+4
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <[email protected]>
* QQuaternion: mark as PRIMITIVE typeGiuseppe D'Angelo2021-03-051-1/+1
| | | | | Change-Id: I043fef8bfc66875b72f34e7939e78c7d1c7f5381 Reviewed-by: Thiago Macieira <[email protected]>
* Add more support for structured bindingsGiuseppe D'Angelo2021-02-251-0/+79
| | | | | | | | | | | | | | | | | | | | | | | After QPoint(F), it's now the time of QSize(F) and QVectorND, which can be unambiguously decomposed. [ChangeLog][QtCore][QSize] QSize is now usable in a structured binding declaration. [ChangeLog][QtCore][QSizeF] QSizeF is now usable in a structured binding declaration. [ChangeLog][QtGui][QVector2D] QVector2D is now usable in a structured binding declaration. [ChangeLog][QtGui][QVector3D] QVector3D is now usable in a structured binding declaration. [ChangeLog][QtGui][QVector4D] QVector4D is now usable in a structured binding declaration. Change-Id: I67bb152f4210f2be27607179cd2ec522174cc483 Reviewed-by: Volker Hilsheimer <[email protected]>
* Doc: Fix documentation warnings qtbaseNico Vertriest2021-02-181-4/+4
| | | | | | Task-number: QTBUG-90662 Change-Id: If31847f8f2b8b57a8a8624d0406a030b5752f1c8 Reviewed-by: Paul Wicking <[email protected]>
* MinGW: fix warning in QMatrix4x4::map functionsMårten Nordheim2021-02-151-5/+5
| | | | | | | | | | | | | | | | The definitions get the following warning (treated as error): redeclared without dllimport attribute after being referenced with dll linkage [-Werror] I take it to mean that because they are labelled 'inline' the compiler disregards the 'dllimport', but that makes it inconsistent with the declaration. So we label the declaration inline as well. Pick-to: 6.1 6.0 5.15 Change-Id: I87bb42141a1086b2c565db881077f33acb4aab64 Reviewed-by: Giuseppe D'Angelo <[email protected]> Reviewed-by: Friedemann Kleint <[email protected]>
* QMatrix4x4: deprecate operator*(QVector3D, QMatrix4x4)Giuseppe D'Angelo2021-02-112-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
* QMatrix4x4: deprecate operator*(QMatrix4x4, QVector3D/QPoint(F))Giuseppe D'Angelo2021-02-112-3/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | The operation does not make sense at the "fundamental" level for these classes (algebraic, in this case), so it shouldn't exist. It's also a semantic trap: * it interprets a _vector_ as a _point_ instead (the vector gets 1-extended in 4D) * after the multiplication, it gets perspective divided. These semantics do not belong to operator*. operator*(QVector3D/QPoint(F), QMatrix) will be tackled in a next commit; we don't have a straightforward replacement for it. Drive-by, document that map() interprets vectors as points. [ChangeLog][QtGui][QMatrix4x4] operator* between a QMatrix4x4 and a QVector3D, QPoint, or QPointF has been deprecated in favor of map() and mapVector(). Pick-to: 6.1 Task-number: QTBUG-89708 Change-Id: Iad78d6eb68cc8cdc3ac16b1635c4d3b522c95213 Reviewed-by: Edward Welbourne <[email protected]>
* Clean up documentation in QVector[234]DEdward Welbourne2021-02-051-30/+50
| | | | | Change-Id: I13f04c06280b998e5489eb114977ec0ed37178b7 Reviewed-by: Paul Wicking <[email protected]>
* Make explicit that we expect co-ordinates to be finiteEdward Welbourne2021-02-042-52/+111
| | | | | | | | | | | | | | | | | | | The various spatial-vector, line, point, region and margin types have all long taken for granted that their co-ordinates are finite and, in particular, not NaN. Make this expectation explicit in the documentation. Added assertions where (chiefly) noexcept and (where the assertion would be a simple qIsFinite() call) constexpr didn't preclude doing so. Also assert against zero divisors that would lead to non-finite results. Make minor clean-ups to docs in the process. QMarginsF had several methods whose declaration, definition and docs weren't consistent in their parameter names. Task-number: QTBUG-89010 Change-Id: I601a830959d13a73dcb17ce31a1202a1486c8f7f Reviewed-by: Laszlo Agocs <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Rationalize QVector[234]D's length-handlingEdward Welbourne2021-02-041-87/+28
| | | | | | | | Use qHypot() instead of casting to and from double so much, use qFuzzyCompare(_, 1.0f) rather than qFuzzyIsNull(_ - 1.0f). Change-Id: I70f38fe2d9aefe1ceb15e1a370f181a7856911b7 Reviewed-by: Laszlo Agocs <[email protected]>
* Rationalize QQuaternion's length-scaling codeEdward Welbourne2021-02-041-56/+40
| | | | | | | | | | | | | | | | | | | | | Use qHypot() to implement length(), avoid duplicating its code and use its result more carefully, saving the need for casting to and from double. Subtracting a double from 1.0f still got a double, so the qFuzzyIsNull() checks were using double's tolerance, where the use of 1.0f indicates the float tolerance would have been more apt. Also, use qFuzzyCompare(_, 1.0f) instead of qFuzzyIsNull(_ - 1.0f). In getEulerAngles(), scale co-ordinates by length before multiplying (to ensure O(1) quantities) rather than scaling the products by the squared length (possibly after {ov,und}erflowing). Change-Id: Id8792d6eb047ee9567a9bbb246657b0217b0849f Reviewed-by: Andreas Buhr <[email protected]> Reviewed-by: Laszlo Agocs <[email protected]> Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Andrei Golubev <[email protected]>
* QMatrix4x4: implement operator*(QVector3D/QPoint(F)) in terms of mapGiuseppe D'Angelo2021-02-011-97/+97
| | | | | | | | Rather than the other way around, in preparation for deprecation. Change-Id: I001d7617425a24e960871925130c5314c393ea8c Reviewed-by: Laszlo Agocs <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
* QVectorND: make some constructors explicitGiuseppe D'Angelo2021-01-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QVector2D has implicit conversions towards QVector3D/4D, and QVector3D has an implicit conversion towards QVector4D. Although in principle this is fine because it's not a data loss, it's still sketchy; for instance, it allows mixed operations to compile: vector2d + vector3d; vector4d - vector3d; vector3d * vector4d; // ! (Random observation: the conversion from QPoint(F) to QVectorND are actually already marked as explicit.) This is a leftover not done for Qt 6.0. I am not making these opt-out: having an implicit conversion here is outright *dangerous*, and any usage that fails to compile needs to be inspected to make sure it was the intended behavior. [ChangeLog][Potentially Source-Incompatible Changes] The QVector2D/3D/4D converting constructors from another QVectorND now explicit. This was done to prevent a category of bugs resulting from operations accidentally mixing QVectorND objects. Fixes: QTBUG-90327 Change-Id: Ifcd873f6a0d3fc10b9e68c935fe1f69f86a2340b Reviewed-by: Volker Hilsheimer <[email protected]> Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Lars Knoll <[email protected]>
* QMatrix4x4: mark it as Q_PRIMITIVE_TYPEGiuseppe D'Angelo2021-01-171-1/+1
| | | | | | | | | My guess: it was relocatable because before 6.0/5.15 we didn't call constructors for Q_PRIMITIVE_TYPEs. Change-Id: Ibc9e23e41d0c4b9718fc7036d9a647cfdcfa7d47 Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Lars Knoll <[email protected]>
* Doc: Link to correct locationPaul Wicking2021-01-111-4/+4
| | | | | | | | | Reflow text to fit style while at it, to satisfy git clang-format. Pick-to: 6.0 5.15 Fixes: QTBUG-89709 Change-Id: Iab2bf09399adf2cb0f0219ab40978bb238825ae8 Reviewed-by: Topi Reiniö <[email protected]>
* Remove the qmake project filesJoerg Bornemann2021-01-071-14/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <[email protected]> Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Kai Koehne <[email protected]>