From 557489c3fcb930885f9129cdd76047de1852b4da Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 25 Jan 2022 15:31:32 +0200 Subject: QmlDesigner: Fix camera frustum initialization for Qt5 builds In Qt5 builds, we need additional async update at camera geometry initialization to ensure source camera is up to date and frustum mesh can be constructed. Fixes: QDS-6071 Change-Id: I41371ae66fde432b0fdf4b5fee6a0604d005bf63 Reviewed-by: Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- .../qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp | 10 ++++++++++ .../qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp index 4260921a37..046dc48606 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp @@ -142,6 +142,16 @@ void CameraGeometry::doUpdateGeometry() if (!QQuick3DObjectPrivate::get(m_camera)->spatialNode) { // Doing explicit viewport mapping forces cameraNode creation m_camera->mapToViewport({}, m_viewPortRect.width(), m_viewPortRect.height()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + if (!m_nodeCreationUpdateDone) { + // Post-node creation update is done only once to avoid infinite loop in case the node + // creation fails. + m_nodeCreationUpdateDone = true; + m_cameraUpdatePending = true; + update(); + return; + } +#endif } GeometryBase::doUpdateGeometry(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h index 5b4fa66fe4..c65b0d1798 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h @@ -67,6 +67,9 @@ private: QQuick3DCamera *m_camera = nullptr; QRectF m_viewPortRect; bool m_cameraUpdatePending = false; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + bool m_nodeCreationUpdateDone = false; +#endif }; } -- cgit v1.2.3