diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2022-06-10 15:23:16 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2022-06-10 13:15:05 +0000 |
commit | dedbbc75b564b0a93c89688d76a7cab6dbc06046 (patch) | |
tree | ab14abaac6b5e365228746c8085c1f35b45a0142 | |
parent | 36dbc62a1d67f02241e5c5860af083d7f4a0d7b5 (diff) | |
download | qt-creator-dedbbc75b564b0a93c89688d76a7cab6dbc06046.tar.gz |
QmlDesigner: Apply root item transform in Node component previews
When generating a preview from a component with a 3D node for a root,
the root Node transform is now applied when calculating camera zoom.
Fixes: QDS-7131
Change-Id: I73054a09b3e82868c999ef6f9797dc941e625b33
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
4 files changed, 6 insertions, 6 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNodeView.qml index 5c8b9e1cd7..b497b0419a 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNodeView.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNodeView.qml @@ -37,7 +37,7 @@ View3D { function fitToViewPort(closeUp) { // The magic number is the distance from camera default pos to origin - _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, sourceModel, root, + _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, model, root, 1040, closeUp); } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNodeView.qml index 1762e3c9a4..4da76ea097 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNodeView.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNodeView.qml @@ -37,7 +37,7 @@ View3D { function fitToViewPort(closeUp) { // The magic number is the distance from camera default pos to origin - _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, sourceModel, root, + _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, model, root, 1040, closeUp); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp index 74c2eb270e..590785a30e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp @@ -812,7 +812,7 @@ QVector3D GeneralHelper::pivotScenePosition(QQuick3DNode *node) const // Calculate bounds for given node, including all child nodes. // Returns true if the tree contains at least one Model node. bool GeneralHelper::getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVector3D &minBounds, - QVector3D &maxBounds, bool recursive) + QVector3D &maxBounds) { if (!node) { const float halfExtent = 100.f; @@ -825,7 +825,7 @@ bool GeneralHelper::getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVec auto nodePriv = QQuick3DObjectPrivate::get(node); auto renderNode = static_cast<QSSGRenderNode *>(nodePriv->spatialNode); - if (recursive && renderNode) { + if (renderNode) { #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) if (renderNode->flags.testFlag(QSSGRenderNode::Flag::TransformDirty)) renderNode->calculateLocalTransform(); @@ -850,7 +850,7 @@ bool GeneralHelper::getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVec if (auto childNode = qobject_cast<QQuick3DNode *>(child)) { QVector3D newMinBounds = minBounds; QVector3D newMaxBounds = maxBounds; - bool childHasModel = getBounds(view3D, childNode, newMinBounds, newMaxBounds, true); + bool childHasModel = getBounds(view3D, childNode, newMinBounds, newMaxBounds); // Ignore any subtrees that do not have Model in them as we don't need those // for visual bounds calculations if (childHasModel) { diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h index 5bb1fa1662..8014a71187 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h @@ -130,7 +130,7 @@ private: void handlePendingToolStateUpdate(); QVector3D pivotScenePosition(QQuick3DNode *node) const; bool getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVector3D &minBounds, - QVector3D &maxBounds, bool recursive = false); + QVector3D &maxBounds); QTimer m_overlayUpdateTimer; QTimer m_toolStateUpdateTimer; |