summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d/qquaternion.h
Commit message (Collapse)AuthorAgeFilesLines
* 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 <volker.hilsheimer@qt.io>
* QQuaternion: make methods constexpr, noexcept; fix styleVolker Hilsheimer2023-12-091-95/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <edward.welbourne@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Sami Varanka <sami.varanka@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | 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 <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QQuaternion: mark as PRIMITIVE typeGiuseppe D'Angelo2021-03-051-1/+1
| | | | | Change-Id: I043fef8bfc66875b72f34e7939e78c7d1c7f5381 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Math 3D classes: make comparison operators hidden friendsVolker Hilsheimer2020-10-291-12/+12
| | | | | | | | | Reduce ADL noise from QVector2/3/4D and from QQuaternion. Also mark as noexcept. Task-number: QTBUG-87973 Change-Id: Id14fd17c0da43517766b218ed85c3b41f91b43c8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-251-2/+2
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove deprecated method QQuaternion::conjugateMarcel Krems2020-09-071-10/+0
| | | | | Change-Id: If539e47618357ef329925033842f266447632e6f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-2/+2
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Cleanup float-equal warningsLars Knoll2020-06-171-3/+2
| | | | | | | | Consistently use the macro from qcompilerdetection.h instead of manually disabling the warning for three different compilers. Change-Id: Id59d30047c8a504e1082d7e47c02f4746fddf9d6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Silence intel compiler warning about float comparisonOlivier Goffart2019-11-281-0/+1
| | | | | | | | Add the equivalent intel warning macro in public header where there was already the macro for -Wfloat-equal Change-Id: I8f20400f0b95c8f3857fa7a0a33464c8c34d5c0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix GCC -Wfloat-conversion warnings (available since GCC 4.9)Thiago Macieira2017-10-291-2/+2
| | | | | | | | | | | This warning used to be part of -Wconversion, but that generates too more noise than we're willing to fix now (like conversion from qint64 to int). The float conversion does trigger for conversion from double to float, as shown in all the QVectorND uses of float, but more importantly, it triggers on passing floats to ints. Change-Id: I69f37f9304f24709a823fffd14e69cfd33f75988 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Move Q_REQUIRED_RESULT to its correct positionThiago Macieira2017-04-201-3/+3
| | | | | | | | | | | That's before the return type or static, inline, constexpr or such keywords (if any). Perl Script: s/^(\s+)(.*) Q_REQUIRED_RESULT(;)?(\s*\/\/.*)?$/\1Q_REQUIRED_RESULT \2\3\4/ Change-Id: I7814054a102a407d876ffffd14b6a16182f159e2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Add -Wfloat-equal to Qt's header clean checkThiago Macieira2017-03-071-6/+9
| | | | | | | Task-number: QTBUG-57649 Change-Id: I15b62e0f9cec482fbb40fffd1490d802c54bf0fe Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add -Wdouble-promotion to headerscleanJesus Fernandez2016-11-301-2/+3
| | | | | | | | | Fixes: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion] Task-number: QTBUG-57068 Change-Id: I897a341aca83873bc6abd256a82a3b9f09409833 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add qtguiglobal.h and qtguiglobal_p.hLars Knoll2016-07-031-0/+1
| | | | | | | | | | | | | | | | | | | | The new modular configuration system requires one global header per module, that is included by all other files in this module. A similar scheme and naming convention is already being used for many other modules (e.g. printsupport, qml, quick). That header will later on #include the configuration file for Qt Gui. For now it defines the Q_GUI_EXPORT macro for this library. In addition, add a private global header, qtguiglobal_p.h, that can later on include the private config header for Qt Gui for things we don't want to export to the world. Change-Id: Id9ce2a4f3d2962c3592c35e3d080574789195f24 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QQuaternion: perform some operations in memory orderMarc Mutz2015-07-071-14/+14
| | | | | | | | | | | | The order of member variables is wp, xp, yp, zp. When performing operations that touch all members, do so in declaration (=memory) order. Might enable autovectorization. Probably leads to slightly better cache behavior. Change-Id: Id9541e5a8011c349f5d24c5e9322bb232a7607b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QQuaternion: optimize op*Marc Mutz2015-05-131-1/+1
| | | | | | | | | | Swap subexpressions around so the expressions involving w (the first member in memory order) execute first. And no, compilers don't do that automatically. Well, GCC 4.9 doesn't. Change-Id: I918ecc27a9ac9775fa91968c0548d182d7ad28e3 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* QQuaternion: Deprecate conjugate() and introduce conjugated()Sérgio Martins2015-05-131-2/+12
| | | | | | | | | Change-Id: I9aa835138e1e33448fea920f7a5ba99b26a95ebf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Add Q_REQUIRED_RESULT in several placesSérgio Martins2015-05-041-2/+2
| | | | | | Change-Id: Icda3000f1d9f0d41612a50a816aa5de5e32028d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QQuaternion: prepare isNull(), isIdentity() for constexpr'ificationMarc Mutz2015-05-041-2/+2
| | | | | | | | | | | | | | | | | | | ...by dropping the use of qIsNull(), which, in Qt 4, distinguished between -0.0f and +0.0f. But mathematically, whether x, y, z are ±0 doesn't change the fact that the result is the identity element (x, y, z should contain the identity element for addition and w the one for multiplication), or the null element (additive identity). So using qIsNull() was wrong even in Qt 4. In Qt 5, qIsNull() returns true for both ±0, so we can just as well compare to 0.0f instead, which allows to mark these functions constexpr (qIsNull() can't be). Do so. Change-Id: I78b1fa7890036dd3cb4de7f90b75d439f9835e73 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Simplify QQuaternion::operator!=()Marc Mutz2015-04-241-1/+1
| | | | | Change-Id: I5043c86362f5126c52d768b51774086869429e08 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Introduce QQuaternion::fromDirection()Konstantin Ritt2015-04-071-0/+2
| | | | | | | | | | ...which constructs a quaternion using specified forward and upward directions, so that the resulting Z axis "faces" a given forward direction. Change-Id: Ib77b8ab5c359a4880b0d946face87026acdc6f0b Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Michael Krasnyk <michael.krasnyk@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Introduce QQuaternion::rotationTo(vecFrom, vecTo)Konstantin Ritt2015-03-071-0/+2
| | | | | | | | | which returns the shortest arc quaternion to rotate vector from to the destination vector to. Change-Id: Ibd7a746789ecdfe6f7fe17e4ac9049f7ac46560d Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* [QQuaternion] Add a way to convert to/from orthonormal axesKonstantin Ritt2015-03-071-0/+5
| | | | | | | | It is just a convenience wrapper around convertion to/from the rotation matrix. Change-Id: I27511b43866827172960b0152f1c7b65da857f6f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Introduce QQuaternion::dotProduct()Konstantin Ritt2015-03-051-0/+7
| | | | | Change-Id: I14b9857ca0a43808b7d536fc258a6bb10f611211 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
* [QQuaternion] Add operator* that rotates a vector with a quaternionKonstantin Ritt2015-02-261-0/+5
| | | | | | | | Same as quaternion.rotatedVector(vec). Expression like `vec = quat * vec` quite common in the 3D world. Change-Id: I0edd5a5f80537bd149f03f682b3de15c54463e23 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* [QQuaternion] Fix naming of the new methodsKonstantin Ritt2015-02-261-6/+6
| | | | | | | | | | | According to the Qt naming policy, methods that return value(s) via the mutable parameter(s) should have "get" prefix to mention that. [ChangeLog][QtGui][QQuaternion] Added methods to convert a quaternion to/from Euler angles and to/from rotation matrix. Change-Id: I95704e1f4623dc4ca54cd237ea203539fb60d452 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* [QQuaternion] Introduce to/from euler angles conversion routinesKonstantin Ritt2015-02-141-0/+19
| | | | | Change-Id: I26c0a9d1ce9258048cf44eed5b5238920c2317b1 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* [QQuaternion] Introduce toAxisAndAngle()Konstantin Ritt2015-02-141-0/+9
| | | | | | | | | This operation is the exact opposite to QQuaternion::fromAxisAndAngle() (so that it is a way to extract the axis and angle values suitable to create the same quaternion via QQuaternion::fromAxisAndAngle()). Change-Id: I41fda58f5fb2b867cccd6b2faf58ab671fa070da Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* [QQuaternion] Introduce to/from rotation matrix conversion routinesKonstantin Ritt2015-02-061-0/+4
| | | | | | Change-Id: Ic19824e7e135f53a9ce3f2ea7ecd078a589e7425 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* [QMath3D] Add public c-tors that do not initialize the contentsKonstantin Ritt2015-02-041-0/+1
| | | | | | Change-Id: I1a28766451e6750986a239c989e7f30c14479057 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
* Introduce QQuaternion::inverted()Konstantin Ritt2015-01-281-0/+14
| | | | | Change-Id: I6de77082bb7c32e48fb7f7d765a58fdbe68db1fd Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Make gui/math3d classes use float rather than qrealSean Harmer2012-09-071-48/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This corrects the mismatch between using floats for internal storage and qreal in the API of QVector*D which leads to lots of implicit casts between double and float. This change also stops users from being surprised by the loss of precision when using these classes on desktop platforms and removes the need for the private constructors taking a dummy int as the final argument. The QMatrix4x4 and QQuaternion classes have been changed to use float for their internal storage since these are meant to be used in conjunction with the QVector*D classes. This is to prevent unexpected loss of precision and to improve performance. The on-disk format has also been changed from double to float thereby reducing the storage required when streaming vectors and matrices. This is potentially a large saving when working with complex 3D meshes etc. This also has a significant performance improvement when passing matrices to QOpenGLShaderProgram (and QGLShaderProgram) as we no longer have to iterate and convert the data to floats. This is an operation that could easily be needed many times per frame. This change also opens the door for further optimisations of these classes to be implemented by using SIMD intrinsics. This needs to be applied in conjunction with https://codereview.qt-project.org/#change,33548 Task-number: QTBUG-21035 Task-number: QTBUG-20661 Change-Id: I9321b06040ffb93ae1cbd72fd2013267ac901b2e Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+330
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12