QmlDesigner: Fix 3D picking of RuntimeLoader loaded models

RuntimeLoader creates the loaded nodes dynamically, similar to
Repeater3D and Loader3D, so handle it similarly as well.

Fixes: QDS-6053
Change-Id: Iece15254e720cfc0a6796b182ef00c3a773cf35d
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2022-01-24 15:23:34 +02:00
parent 5887d13d46
commit 94a17f1e7e
4 changed files with 39 additions and 0 deletions

View File

@@ -13,6 +13,10 @@ versionAtLeast(QT_VERSION, 5.15.0) {
QT *= quick3dparticles-private QT *= quick3dparticles-private
DEFINES *= QUICK3D_PARTICLES_MODULE DEFINES *= QUICK3D_PARTICLES_MODULE
} }
qtHaveModule(quick3dassetutils) {
QT *= quick3dassetutils-private
DEFINES *= QUICK3D_ASSET_UTILS_MODULE
}
} }
HEADERS += $$PWD/qt5nodeinstanceserver.h \ HEADERS += $$PWD/qt5nodeinstanceserver.h \

View File

@@ -104,6 +104,9 @@
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "../editor3d/qt5compat/qquick3darealight_p.h" #include "../editor3d/qt5compat/qquick3darealight_p.h"
#endif #endif
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
#include <private/qquick3druntimeloader_p.h>
#endif
#endif #endif
#ifdef QUICK3D_PARTICLES_MODULE #ifdef QUICK3D_PARTICLES_MODULE
@@ -2317,13 +2320,23 @@ void Qt5InformationNodeInstanceServer::handleInstanceHidden(const ServerNodeInst
} else { } else {
auto checkRepeater = qobject_cast<QQuick3DRepeater *>(checkNode); auto checkRepeater = qobject_cast<QQuick3DRepeater *>(checkNode);
auto checkLoader = qobject_cast<QQuick3DLoader *>(checkNode); auto checkLoader = qobject_cast<QQuick3DLoader *>(checkNode);
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
auto checkRunLoader = qobject_cast<QQuick3DRuntimeLoader *>(checkNode);
if (checkRepeater || checkLoader || checkRunLoader) {
#else
if (checkRepeater || checkLoader) { if (checkRepeater || checkLoader) {
#endif
// Repeaters/loaders may not yet have created their children, so we set // Repeaters/loaders may not yet have created their children, so we set
// _pickTarget on them and connect the notifier. // _pickTarget on them and connect the notifier.
if (checkNode->property("_pickTarget").isNull()) { if (checkNode->property("_pickTarget").isNull()) {
if (checkRepeater) { if (checkRepeater) {
QObject::connect(checkRepeater, &QQuick3DRepeater::objectAdded, QObject::connect(checkRepeater, &QQuick3DRepeater::objectAdded,
this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
} else if (checkRunLoader) {
QObject::connect(checkRunLoader, &QQuick3DRuntimeLoader::statusChanged,
this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
#endif
} else { } else {
QObject::connect(checkLoader, &QQuick3DLoader::loaded, QObject::connect(checkLoader, &QQuick3DLoader::loaded,
this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);

View File

@@ -42,6 +42,9 @@
#include <private/qquick3dnode_p_p.h> #include <private/qquick3dnode_p_p.h>
#include <private/qquick3drepeater_p.h> #include <private/qquick3drepeater_p.h>
#include <private/qquick3dloader_p.h> #include <private/qquick3dloader_p.h>
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
#include <private/qquick3druntimeloader_p.h>
#endif
#endif #endif
namespace QmlDesigner { namespace QmlDesigner {
@@ -63,11 +66,21 @@ void Quick3DNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNo
QObject *obj = object(); QObject *obj = object();
auto repObj = qobject_cast<QQuick3DRepeater *>(obj); auto repObj = qobject_cast<QQuick3DRepeater *>(obj);
auto loadObj = qobject_cast<QQuick3DLoader *>(obj); auto loadObj = qobject_cast<QQuick3DLoader *>(obj);
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
auto runLoadObj = qobject_cast<QQuick3DRuntimeLoader *>(obj);
if (repObj || loadObj || runLoadObj) {
#else
if (repObj || loadObj) { if (repObj || loadObj) {
#endif
if (auto infoServer = qobject_cast<Qt5InformationNodeInstanceServer *>(nodeInstanceServer())) { if (auto infoServer = qobject_cast<Qt5InformationNodeInstanceServer *>(nodeInstanceServer())) {
if (repObj) { if (repObj) {
QObject::connect(repObj, &QQuick3DRepeater::objectAdded, QObject::connect(repObj, &QQuick3DRepeater::objectAdded,
infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0)
} else if (runLoadObj) {
QObject::connect(runLoadObj, &QQuick3DRuntimeLoader::statusChanged,
infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);
#endif
} else { } else {
QObject::connect(loadObj, &QQuick3DLoader::loaded, QObject::connect(loadObj, &QQuick3DLoader::loaded,
infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject);

View File

@@ -178,6 +178,15 @@ extend_qtc_executable(qml2puppet
DEFINES QUICK3D_PARTICLES_MODULE DEFINES QUICK3D_PARTICLES_MODULE
) )
# Quick3DAssetUtils optionally depends on QuickTimeline, so find also it to make the CI build work
find_package(Qt5 5.15.0 COMPONENTS Quick3DAssetUtils QuickTimeline QUIET)
extend_qtc_executable(qml2puppet
CONDITION TARGET Qt5::Quick3DAssetUtils
FEATURE_INFO "Qt Quick 3D asset utils"
DEPENDS Qt5::Quick3DAssetUtilsPrivate
DEFINES QUICK3D_ASSET_UTILS_MODULE
)
extend_qtc_executable(qml2puppet extend_qtc_executable(qml2puppet
CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 6.0.0 CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 6.0.0