diff options
-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(); } |