diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2020-02-04 15:49:43 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2020-02-06 08:41:11 +0000 |
commit | 07ada921dcbb6fbc7cb2cd0736681b93f9b3ead6 (patch) | |
tree | bcfa44e585715566c02bd8295d0311fef04797d4 /share/qtcreator/qml | |
parent | 0b1a463c473ee8a6846b5703c4ff659822bf6c33 (diff) | |
download | qt-creator-07ada921dcbb6fbc7cb2cd0736681b93f9b3ead6.tar.gz |
QmlDesigner: Fix camera frustum visualization in 3d edit view
Now camera frustum visualization should always appear correctly in
3D edit view, as the QSSGRenderCamera node is created at frustum
geometry update time if it's missing. Active scene change
also triggers geometry update for camera gizmos.
Change-Id: If24e97490b2ff6607049b5288c6e167aa29a86b2
Fixes: QDS-1472
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share/qtcreator/qml')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml | 5 | ||||
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml index 034ff237b7..1a9dd55429 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml @@ -34,6 +34,11 @@ IconGizmo { property alias geometryName: cameraGeometry.name // Name must be unique for each geometry property alias viewPortRect: cameraGeometry.viewPortRect + onActiveSceneChanged: { + if (activeScene == scene) + cameraGeometry.update(); + } + Model { id: gizmoModel geometry: cameraGeometry diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp index 0ffebc7246..69973385b1 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp @@ -113,6 +113,11 @@ QSSGRenderGraphObject *CameraGeometry::updateSpatialNode(QSSGRenderGraphObject * if (!m_camera) return node; + if (!m_camera->cameraNode()) { + // Force cameraNode creation by doing a dummy mapping call + m_camera->mapToViewport({}, m_viewPortRect.width(), m_viewPortRect.height()); + } + node = QQuick3DGeometry::updateSpatialNode(node); QSSGRenderGeometry *geometry = static_cast<QSSGRenderGeometry *>(node); @@ -154,10 +159,10 @@ void CameraGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexDat if (qobject_cast<QQuick3DOrthographicCamera *>(m_camera)) { // For some reason ortho cameras show double what projection suggests, // so give them doubled viewport to match visualization to actual camera view - camera->calculateProjection(QRectF(0, 0, m_viewPortRect.width() * 2.0, + camera->calculateGlobalVariables(QRectF(0, 0, m_viewPortRect.width() * 2.0, m_viewPortRect.height() * 2.0)); } else { - camera->calculateProjection(m_viewPortRect); + camera->calculateGlobalVariables(m_viewPortRect); } m = camera->projection.inverted(); } |