diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2021-06-10 15:16:38 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2021-06-11 07:47:19 +0000 |
commit | 74f65abed0fae2424f34dc068d7909a091e625ae (patch) | |
tree | d43326739b13c0a7b5d3dd4621860d11cd0cda9a /share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d | |
parent | 4e1ca8d3c5051e9b25163f884e8411860829784c (diff) |
QmlPuppet: Fix multiselection 3D transformations when nodes have pivot
We simply need to store the scene position of the pivot point of the
node instead of node itself and work with that.
Fixes: QDS-4515
Change-Id: I99155636c52897794bea21b2db7f7d2d00059d91
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp | 27 | ||||
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h | 1 |
2 files changed, 23 insertions, 5 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp index b2bb062147..09b2569e2d 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp @@ -41,6 +41,7 @@ #include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h> #include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h> #include <QtQuick3DUtils/private/qssgbounds3_p.h> +#include <QtQuick3DUtils/private/qssgutils_p.h> #include <QtQuick/qquickwindow.h> #include <QtQuick/qquickitem.h> #include <QtCore/qmath.h> @@ -403,11 +404,8 @@ void GeneralHelper::setMultiSelectionTargets(QQuick3DNode *multiSelectRootNode, void GeneralHelper::resetMultiSelectionNode() { - for (auto it = m_multiSelDataMap.begin(); it != m_multiSelDataMap.end(); ++it) { - it.value() = {it.key()->scenePosition(), - it.key()->scale(), - it.key()->rotation()}; - } + for (auto it = m_multiSelDataMap.begin(); it != m_multiSelDataMap.end(); ++it) + it.value() = {pivotScenePosition(it.key()), it.key()->scale(), it.key()->rotation()}; m_multiSelNodeData = {}; if (!m_multiSelDataMap.isEmpty()) { @@ -570,6 +568,25 @@ void GeneralHelper::handlePendingToolStateUpdate() m_toolStatesPending.clear(); } +// Calculate scene position of the node's pivot point, which in practice is just the position +// of the node without applying the pivot offset. +QVector3D GeneralHelper::pivotScenePosition(QQuick3DNode *node) const +{ + if (!node) + return {}; + + QQuick3DNode *parent = node->parentNode(); + if (!parent) + return node->position(); + + QMatrix4x4 localTransform; + localTransform.translate(node->position()); + + const QMatrix4x4 sceneTransform = parent->sceneTransform() * localTransform; + + return mat44::getPosition(sceneTransform); +} + } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h index 153553d52b..22e37e2352 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h @@ -119,6 +119,7 @@ protected: private: void handlePendingToolStateUpdate(); + QVector3D pivotScenePosition(QQuick3DNode *node) const; QTimer m_overlayUpdateTimer; QTimer m_toolStateUpdateTimer; |