diff options
Diffstat (limited to 'src')
41 files changed, 176 insertions, 85 deletions
diff --git a/src/core/changes/qnodecreatedchange_p.h b/src/core/changes/qnodecreatedchange_p.h index cb1470970..5e4c5b91d 100644 --- a/src/core/changes/qnodecreatedchange_p.h +++ b/src/core/changes/qnodecreatedchange_p.h @@ -53,10 +53,10 @@ #include <Qt3DCore/private/qscenechange_p.h> #include <Qt3DCore/private/qt3dcore_global_p.h> -struct QMetaObject; - QT_BEGIN_NAMESPACE +struct QMetaObject; + namespace Qt3DCore { class QNode; diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp index d0ed58efd..64ea65087 100644 --- a/src/core/nodes/qentity.cpp +++ b/src/core/nodes/qentity.cpp @@ -52,6 +52,8 @@ #include <Qt3DCore/private/qcomponent_p.h> #include <Qt3DCore/private/qscene_p.h> +#include <QQueue> + QT_BEGIN_NAMESPACE namespace Qt3DCore { @@ -233,6 +235,20 @@ QNodeCreatedChangeBasePtr QEntity::createNodeCreationChange() const Q_D(const QEntity); data.parentEntityId = parentEntity() ? parentEntity()->id() : Qt3DCore::QNodeId(); + + // Find all child entities + QQueue<QNode *> queue; + queue.append(childNodes().toList()); + data.childEntityIds.reserve(queue.size()); + while (!queue.isEmpty()) { + auto *child = queue.dequeue(); + auto *childEntity = qobject_cast<QEntity *>(child); + if (childEntity != nullptr) + data.childEntityIds.push_back(childEntity->id()); + else + queue.append(child->childNodes().toList()); + } + data.componentIdsAndTypes.reserve(d->m_components.size()); const QComponentVector &components = d->m_components; for (QComponent *c : components) { diff --git a/src/core/nodes/qentity_p.h b/src/core/nodes/qentity_p.h index ef35d83a1..8fe03cd6b 100644 --- a/src/core/nodes/qentity_p.h +++ b/src/core/nodes/qentity_p.h @@ -91,6 +91,7 @@ struct QEntityData { Qt3DCore::QNodeId parentEntityId; QVector<QNodeIdTypePair> componentIdsAndTypes; + Qt3DCore::QNodeIdVector childEntityIds; }; } diff --git a/src/quick3d/imports/animation/importsanimation.pro b/src/quick3d/imports/animation/importsanimation.pro index 5492a4f39..7b637dd3c 100644 --- a/src/quick3d/imports/animation/importsanimation.pro +++ b/src/quick3d/imports/animation/importsanimation.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = quick3danimationplugin TARGETPATH = Qt3D/Animation -IMPORT_VERSION = 2.2 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += core-private qml qml-private 3dcore 3drender 3danimation 3dquick 3dquickrender 3dquickanimation 3dquick-private 3dquickanimation-private diff --git a/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp b/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp index 017e2a453..5656ef570 100644 --- a/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp +++ b/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp @@ -100,6 +100,9 @@ void Qt3DQuick3DAnimationPlugin::registerTypes(const char *uri) qmlRegisterUncreatableType<Qt3DAnimation::QAbstractChannelMapping>(uri, 2, 10, "AbstractChannelMapping", QStringLiteral("QAbstractChannelMapping is abstract")); qmlRegisterType<Qt3DAnimation::QSkeletonMapping>(uri, 2, 10, "SkeletonMapping"); + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/animation/qt3dquick3danimationplugin.h b/src/quick3d/imports/animation/qt3dquick3danimationplugin.h index 3800194ce..42e0efbef 100644 --- a/src/quick3d/imports/animation/qt3dquick3danimationplugin.h +++ b/src/quick3d/imports/animation/qt3dquick3danimationplugin.h @@ -42,13 +42,6 @@ #include <QtQml/qqmlextensionplugin.h> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_Qt3D_Animation); -#endif -} - QT_BEGIN_NAMESPACE class Qt3DQuick3DAnimationPlugin : public QQmlExtensionPlugin @@ -56,7 +49,7 @@ class Qt3DQuick3DAnimationPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: - Qt3DQuick3DAnimationPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } + Qt3DQuick3DAnimationPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override; }; diff --git a/src/quick3d/imports/core/importscore.pro b/src/quick3d/imports/core/importscore.pro index 6f43d8c99..4ff71488a 100644 --- a/src/quick3d/imports/core/importscore.pro +++ b/src/quick3d/imports/core/importscore.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = quick3dcoreplugin TARGETPATH = Qt3D/Core -IMPORT_VERSION = 2.0 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += core-private qml qml-private quick quick-private 3dcore 3dcore-private 3dquick 3dquick-private diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp index 05d99f05f..76d78c8fa 100644 --- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp +++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp @@ -54,6 +54,8 @@ #include <Qt3DQuick/private/qquaternionanimation_p.h> #include <Qt3DQuick/private/qt3dquick_global_p.h> +#include <QtQml/qqml.h> + QT_BEGIN_NAMESPACE void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) @@ -64,6 +66,7 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) Qt3DCore::Quick::registerExtendedType<Qt3DCore::QEntity, Qt3DCore::Quick::Quick3DEntity>("QEntity", "Qt3D.Core/Entity", uri, 2, 0, "Entity"); qmlRegisterType<Qt3DCore::Quick::Quick3DEntityLoader>(uri, 2, 0, "EntityLoader"); + qmlRegisterRevision<Qt3DCore::Quick::Quick3DEntityLoader, 12>(uri, 2, 12); qmlRegisterType<Qt3DCore::Quick::Quick3DNodeInstantiator>(uri, 2, 0, "NodeInstantiator"); qmlRegisterType<Qt3DCore::QTransform>(uri, 2, 0, "Transform"); qmlRegisterType<Qt3DCore::QArmature>(uri, 2, 10, "Armature"); @@ -79,6 +82,9 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) qmlRegisterExtendedUncreatableType<Qt3DCore::QNode, Qt3DCore::Quick::Quick3DNodeV9, 9>(uri, 2, 9, "Node", QStringLiteral("Node is a base class")); Qt3DCore::Quick::registerExtendedType<Qt3DCore::QJoint, Qt3DCore::Quick::Quick3DJoint>("QJoint", "Qt3D.Core/Joint", uri, 2, 10, "Joint"); + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } Qt3DQuick3DCorePlugin::~Qt3DQuick3DCorePlugin() diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.h b/src/quick3d/imports/core/qt3dquick3dcoreplugin.h index 99c6ab525..afc092bbb 100644 --- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.h +++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.h @@ -42,13 +42,6 @@ #include <QtQml/QQmlExtensionPlugin> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_Qt3D_Core); -#endif -} - QT_BEGIN_NAMESPACE class Qt3DQuick3DCorePlugin : public QQmlExtensionPlugin @@ -56,7 +49,7 @@ class Qt3DQuick3DCorePlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - Qt3DQuick3DCorePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); } + Qt3DQuick3DCorePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } ~Qt3DQuick3DCorePlugin(); void registerTypes(const char *uri) override; }; diff --git a/src/quick3d/imports/extras/importsextras.pro b/src/quick3d/imports/extras/importsextras.pro index 22f753ee0..ea5b39a89 100644 --- a/src/quick3d/imports/extras/importsextras.pro +++ b/src/quick3d/imports/extras/importsextras.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = quick3dextrasplugin TARGETPATH = Qt3D/Extras -IMPORT_VERSION = 2.0 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += core-private qml qml-private quick quick-private 3dcore 3dcore-private 3dquick 3dquick-private 3dextras 3dlogic 3dquickextras 3dquickextras-private diff --git a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp index 9a3e76923..a4ced963a 100644 --- a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp +++ b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp @@ -141,6 +141,9 @@ void Qt3DQuick3DExtrasPlugin::registerTypes(const char *uri) qmlRegisterType<Qt3DExtras::QExtrudedTextMesh>(uri, 2, 9, "ExtrudedTextMesh"); qmlRegisterType<Qt3DExtras::QText2DEntity>(uri, 2, 9, "Text2DEntity"); + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } diff --git a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.h b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.h index b7c1f5f87..95b5a8717 100644 --- a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.h +++ b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.h @@ -45,8 +45,7 @@ static void initResources() { #ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_Qt3D_Extras); - Q_INIT_RESOURCE(extras); + Q_INIT_RESOURCE(extras); // from the Qt3DQuickExtras module #endif } diff --git a/src/quick3d/imports/input/importsinput.pro b/src/quick3d/imports/input/importsinput.pro index 83a7797f9..2b0dd0354 100644 --- a/src/quick3d/imports/input/importsinput.pro +++ b/src/quick3d/imports/input/importsinput.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = quick3dinputplugin TARGETPATH = Qt3D/Input -IMPORT_VERSION = 2.0 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += core-private qml 3dcore 3dinput 3dinput-private 3dquickinput-private diff --git a/src/quick3d/imports/input/qt3dquick3dinputplugin.cpp b/src/quick3d/imports/input/qt3dquick3dinputplugin.cpp index 5719a2b98..ba2e0661c 100644 --- a/src/quick3d/imports/input/qt3dquick3dinputplugin.cpp +++ b/src/quick3d/imports/input/qt3dquick3dinputplugin.cpp @@ -104,6 +104,9 @@ void Qt3DQuick3DInputPlugin::registerTypes(const char *uri) #ifdef HAVE_QGAMEPAD qmlRegisterType<Qt3DInput::QGamepadInput>(uri, 2, 0, "GamepadInput"); #endif + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/input/qt3dquick3dinputplugin.h b/src/quick3d/imports/input/qt3dquick3dinputplugin.h index e02710696..b2399af30 100644 --- a/src/quick3d/imports/input/qt3dquick3dinputplugin.h +++ b/src/quick3d/imports/input/qt3dquick3dinputplugin.h @@ -42,13 +42,6 @@ #include <QtQml/QQmlExtensionPlugin> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_Qt3D_Input); -#endif -} - QT_BEGIN_NAMESPACE class Qt3DQuick3DInputPlugin : public QQmlExtensionPlugin @@ -56,7 +49,7 @@ class Qt3DQuick3DInputPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - Qt3DQuick3DInputPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { initResources(); } + Qt3DQuick3DInputPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override; }; diff --git a/src/quick3d/imports/logic/importslogic.pro b/src/quick3d/imports/logic/importslogic.pro index c2b33f665..955a4fd61 100644 --- a/src/quick3d/imports/logic/importslogic.pro +++ b/src/quick3d/imports/logic/importslogic.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = quick3dlogicplugin TARGETPATH = Qt3D/Logic -IMPORT_VERSION = 2.0 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += core-private qml 3dcore 3dlogic diff --git a/src/quick3d/imports/logic/qt3dquick3dlogicplugin.cpp b/src/quick3d/imports/logic/qt3dquick3dlogicplugin.cpp index f97bc8fc6..0fbe64002 100644 --- a/src/quick3d/imports/logic/qt3dquick3dlogicplugin.cpp +++ b/src/quick3d/imports/logic/qt3dquick3dlogicplugin.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE void Qt3DQuick3DLogicPlugin::registerTypes(const char *uri) { qmlRegisterType<Qt3DLogic::QFrameAction>(uri, 2, 0, "FrameAction"); + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/logic/qt3dquick3dlogicplugin.h b/src/quick3d/imports/logic/qt3dquick3dlogicplugin.h index 8f4a2fe39..d59d7d09d 100644 --- a/src/quick3d/imports/logic/qt3dquick3dlogicplugin.h +++ b/src/quick3d/imports/logic/qt3dquick3dlogicplugin.h @@ -42,13 +42,6 @@ #include <QtQml/QQmlExtensionPlugin> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_Qt3D_Logic); -#endif -} - QT_BEGIN_NAMESPACE class Qt3DQuick3DLogicPlugin : public QQmlExtensionPlugin @@ -56,7 +49,7 @@ class Qt3DQuick3DLogicPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - Qt3DQuick3DLogicPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } + Qt3DQuick3DLogicPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override; }; diff --git a/src/quick3d/imports/render/importsrender.pro b/src/quick3d/imports/render/importsrender.pro index cc34ff3df..a8d68c8ee 100644 --- a/src/quick3d/imports/render/importsrender.pro +++ b/src/quick3d/imports/render/importsrender.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = quick3drenderplugin TARGETPATH = Qt3D/Render -IMPORT_VERSION = 2.0 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += core-private qml qml-private 3dcore 3drender 3drender-private 3dquick 3dquick-private 3dquickrender-private diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp index 4b30bcd2f..9e889816c 100644 --- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp +++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp @@ -296,6 +296,9 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri) qmlRegisterType<Qt3DRender::QStencilOperation>(uri, 2, 0, "StencilOperation"); qmlRegisterType<Qt3DRender::QStencilMask>(uri, 2, 0, "StencilMask"); qmlRegisterType<Qt3DRender::QLineWidth>(uri, 2, 10, "LineWidth"); + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.h b/src/quick3d/imports/render/qt3dquick3drenderplugin.h index 11802b179..68a5cade5 100644 --- a/src/quick3d/imports/render/qt3dquick3drenderplugin.h +++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.h @@ -42,13 +42,6 @@ #include <QtQml/QQmlExtensionPlugin> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_Qt3D_Render); -#endif -} - QT_BEGIN_NAMESPACE class Qt3DQuick3DRenderPlugin : public QQmlExtensionPlugin @@ -56,7 +49,7 @@ class Qt3DQuick3DRenderPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - Qt3DQuick3DRenderPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } + Qt3DQuick3DRenderPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override; }; diff --git a/src/quick3d/imports/scene2d/importsscene2d.pro b/src/quick3d/imports/scene2d/importsscene2d.pro index 32fbc5b1b..1582d4ee4 100644 --- a/src/quick3d/imports/scene2d/importsscene2d.pro +++ b/src/quick3d/imports/scene2d/importsscene2d.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = qtquickscene2dplugin TARGETPATH = QtQuick/Scene2D -IMPORT_VERSION = 2.0 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += qml quick 3dcore 3drender 3drender-private 3dinput 3dlogic 3dquickscene2d 3dquickscene2d-private diff --git a/src/quick3d/imports/scene2d/qtquickscene2dplugin.cpp b/src/quick3d/imports/scene2d/qtquickscene2dplugin.cpp index 4e6245d2d..0c410e84b 100644 --- a/src/quick3d/imports/scene2d/qtquickscene2dplugin.cpp +++ b/src/quick3d/imports/scene2d/qtquickscene2dplugin.cpp @@ -53,6 +53,9 @@ Q_COREAPP_STARTUP_FUNCTION(initScene2dPlugin) void QtQuickScene2DPlugin::registerTypes(const char *uri) { qmlRegisterExtendedType<Qt3DRender::Quick::QScene2D, Qt3DRender::Render::Quick::QQuick3DScene2D>(uri, 2, 9, "Scene2D"); + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/scene2d/qtquickscene2dplugin.h b/src/quick3d/imports/scene2d/qtquickscene2dplugin.h index 7e97fd662..22a4e9b7a 100644 --- a/src/quick3d/imports/scene2d/qtquickscene2dplugin.h +++ b/src/quick3d/imports/scene2d/qtquickscene2dplugin.h @@ -39,13 +39,6 @@ #include <QtQml/qqmlextensionplugin.h> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_QtQuick_Scene2D); -#endif -} - QT_BEGIN_NAMESPACE class QtQuickScene2DPlugin : public QQmlExtensionPlugin @@ -53,7 +46,7 @@ class QtQuickScene2DPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - QtQuickScene2DPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } + QtQuickScene2DPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override; }; diff --git a/src/quick3d/imports/scene3d/importsscene3d.pro b/src/quick3d/imports/scene3d/importsscene3d.pro index e41dc8c84..cf8d7cacf 100644 --- a/src/quick3d/imports/scene3d/importsscene3d.pro +++ b/src/quick3d/imports/scene3d/importsscene3d.pro @@ -1,7 +1,7 @@ CXX_MODULE = qml TARGET = qtquickscene3dplugin TARGETPATH = QtQuick/Scene3D -IMPORT_VERSION = 2.0 +IMPORT_VERSION = 2.$$QT_MINOR_VERSION QT += qml quick 3dcore 3drender 3drender-private diff --git a/src/quick3d/imports/scene3d/qtquickscene3dplugin.cpp b/src/quick3d/imports/scene3d/qtquickscene3dplugin.cpp index 6b9ec96f8..d7b985e9f 100644 --- a/src/quick3d/imports/scene3d/qtquickscene3dplugin.cpp +++ b/src/quick3d/imports/scene3d/qtquickscene3dplugin.cpp @@ -48,6 +48,9 @@ QT_BEGIN_NAMESPACE void QtQuickScene3DPlugin::registerTypes(const char *uri) { qmlRegisterType<Qt3DRender::Scene3DItem>(uri, 2, 0, "Scene3D"); + + // Auto-increment the import to stay in sync with ALL future Qt minor versions + qmlRegisterModule(uri, 2, QT_VERSION_MINOR); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/scene3d/qtquickscene3dplugin.h b/src/quick3d/imports/scene3d/qtquickscene3dplugin.h index 44a69a805..c70b8358b 100644 --- a/src/quick3d/imports/scene3d/qtquickscene3dplugin.h +++ b/src/quick3d/imports/scene3d/qtquickscene3dplugin.h @@ -42,13 +42,6 @@ #include <QtQml/QQmlExtensionPlugin> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_QtQuick_Scene3D); -#endif -} - QT_BEGIN_NAMESPACE class QtQuickScene3DPlugin : public QQmlExtensionPlugin @@ -56,7 +49,7 @@ class QtQuickScene3DPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - QtQuickScene3DPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } + QtQuickScene3DPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override; }; diff --git a/src/quick3d/quick3d/items/quick3dentityloader.cpp b/src/quick3d/quick3d/items/quick3dentityloader.cpp index 48f2af658..61801e8df 100644 --- a/src/quick3d/quick3d/items/quick3dentityloader.cpp +++ b/src/quick3d/quick3d/items/quick3dentityloader.cpp @@ -192,6 +192,24 @@ void Quick3DEntityLoader::setSource(const QUrl &url) d->loadFromSource(); } +QQmlComponent *Quick3DEntityLoader::sourceComponent() const +{ + Q_D(const Quick3DEntityLoader); + return d->m_sourceComponent; +} + +void Quick3DEntityLoader::setSourceComponent(QQmlComponent *component) +{ + Q_D(Quick3DEntityLoader); + if (d->m_sourceComponent == component) + return; + + d->clear(); + d->m_sourceComponent = component; + emit sourceComponentChanged(); + d->loadComponent(d->m_sourceComponent); +} + /*! \qmlproperty Status Qt3DCore::EntityLoader::status @@ -214,6 +232,7 @@ Quick3DEntityLoaderPrivate::Quick3DEntityLoaderPrivate() m_incubator(nullptr), m_context(nullptr), m_component(nullptr), + m_sourceComponent(nullptr), m_entity(nullptr), m_status(Quick3DEntityLoader::Null) { @@ -233,10 +252,11 @@ void Quick3DEntityLoaderPrivate::clear() m_entity = nullptr; } - if (m_component) { + // Only delete m_component if we were loading from a URL otherwise it means + // m_component = m_sourceComponent which we don't own. + if (m_component && m_component != m_sourceComponent) delete m_component; - m_component = nullptr; - } + m_component = nullptr; if (m_context) { delete m_context; @@ -271,17 +291,36 @@ void Quick3DEntityLoaderPrivate::loadComponent(const QUrl &source) m_component->loadUrl(source, QQmlComponent::Asynchronous); } +void Quick3DEntityLoaderPrivate::loadComponent(QQmlComponent *component) +{ + Q_Q(Quick3DEntityLoader); + + Q_ASSERT(m_entity == nullptr); + Q_ASSERT(m_component == nullptr); + Q_ASSERT(m_context == nullptr); + + m_component = component; + _q_componentStatusChanged(m_component ? m_component->status() : QQmlComponent::Null); +} + void Quick3DEntityLoaderPrivate::_q_componentStatusChanged(QQmlComponent::Status status) { Q_Q(Quick3DEntityLoader); Q_ASSERT(m_entity == nullptr); - Q_ASSERT(m_component != nullptr); Q_ASSERT(m_context == nullptr); Q_ASSERT(m_incubator == nullptr); - auto owner = _q_findQmlOwner(q); + qDebug() << Q_FUNC_INFO << status; + + if (!m_component) { + clear(); + emit q->entityChanged(); + return; + } + + auto owner = _q_findQmlOwner(q); if (!m_component->errors().isEmpty()) { QQmlEnginePrivate::warning(owner.engine, m_component->errors()); clear(); diff --git a/src/quick3d/quick3d/items/quick3dentityloader_p.h b/src/quick3d/quick3d/items/quick3dentityloader_p.h index 6a2fe5473..beb72ba79 100644 --- a/src/quick3d/quick3d/items/quick3dentityloader_p.h +++ b/src/quick3d/quick3d/items/quick3dentityloader_p.h @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE +class QQmlComponent; + namespace Qt3DCore { class QEntity; @@ -74,6 +76,7 @@ class QT3DQUICKSHARED_PRIVATE_EXPORT Quick3DEntityLoader : public QEntity Q_PROPERTY(QObject *entity READ entity NOTIFY entityChanged) Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) + Q_PROPERTY(QQmlComponent *sourceComponent WRITE setSourceComponent NOTIFY sourceComponentChanged REVISION 12) public: enum Status { Null = 0, @@ -91,11 +94,15 @@ public: QUrl source() const; void setSource(const QUrl &url); + QQmlComponent *sourceComponent() const; + void setSourceComponent(QQmlComponent *components); + Status status() const; Q_SIGNALS: void entityChanged(); void sourceChanged(); + void sourceComponentChanged(); void statusChanged(Status status); private: diff --git a/src/quick3d/quick3d/items/quick3dentityloader_p_p.h b/src/quick3d/quick3d/items/quick3dentityloader_p_p.h index 4d067f0e6..b37990d34 100644 --- a/src/quick3d/quick3d/items/quick3dentityloader_p_p.h +++ b/src/quick3d/quick3d/items/quick3dentityloader_p_p.h @@ -79,6 +79,7 @@ public: void clear(); void loadFromSource(); void loadComponent(const QUrl &source); + void loadComponent(QQmlComponent *component); void _q_componentStatusChanged(QQmlComponent::Status status); void setStatus(Quick3DEntityLoader::Status status); @@ -89,6 +90,7 @@ public: Quick3DEntityLoaderIncubator *m_incubator; QQmlContext *m_context; QQmlComponent *m_component; + QQmlComponent *m_sourceComponent; QEntity *m_entity; Quick3DEntityLoader::Status m_status; }; diff --git a/src/quick3d/quick3d/qt3dquick_global.cpp b/src/quick3d/quick3d/qt3dquick_global.cpp index cef480240..aa2a94860 100644 --- a/src/quick3d/quick3d/qt3dquick_global.cpp +++ b/src/quick3d/quick3d/qt3dquick_global.cpp @@ -276,7 +276,7 @@ public: float matVals[16]; QV4::ScopedValue v(scope); for (quint32 i = 0; i < 16; ++i) { - v = array->getIndexed(i); + v = array->get(i); if (!v->isNumber()) return QMatrix4x4(); matVals[i] = v->asDouble(); diff --git a/src/render/backend/managers.cpp b/src/render/backend/managers.cpp index 6e8c1376d..3b1f8e910 100644 --- a/src/render/backend/managers.cpp +++ b/src/render/backend/managers.cpp @@ -88,7 +88,7 @@ void SkeletonManager::addDirtySkeleton(DirtyFlag dirtyFlag, HSkeleton skeletonHa } } -QVector<HSkeleton> SkeletonManager::dirtySkeletons(DirtyFlag dirtyFlag) +QVector<HSkeleton> SkeletonManager::takeDirtySkeletons(DirtyFlag dirtyFlag) { switch (dirtyFlag) { case SkeletonDataDirty: diff --git a/src/render/backend/managers_p.h b/src/render/backend/managers_p.h index 312889a43..b62e2f3e0 100644 --- a/src/render/backend/managers_p.h +++ b/src/render/backend/managers_p.h @@ -414,7 +414,7 @@ public: }; void addDirtySkeleton(DirtyFlag dirtyFlag, HSkeleton skeletonHandle); - QVector<HSkeleton> dirtySkeletons(DirtyFlag dirtyFlag); + QVector<HSkeleton> takeDirtySkeletons(DirtyFlag dirtyFlag); private: QVector<HSkeleton> m_dirtyDataSkeletons; diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp index 0a60edef7..3cf19d0d8 100644 --- a/src/render/framegraph/qframegraphnode.cpp +++ b/src/render/framegraph/qframegraphnode.cpp @@ -41,6 +41,12 @@ #include "qframegraphnode_p.h" #include <Qt3DRender/qframegraphnodecreatedchange.h> +#include <Qt3DCore/QNode> + +#include <QQueue> + +using namespace Qt3DCore; + QT_BEGIN_NAMESPACE namespace Qt3DRender { @@ -190,7 +196,10 @@ QFrameGraphNode::~QFrameGraphNode() } /*! - Returns a pointer to the parent. + Returns a pointer to the parent frame graph node. + + If the parent of this node is not a frame graph node, + this method will recursively look for a parent node that is a frame graph node. */ QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const { @@ -205,6 +214,31 @@ QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const return parentFGNode; } +/*! + * Returns a list of the children that are frame graph nodes. + * If this function encounters a child node that is not a frame graph node, + * it will go through the children of the child node and look for frame graph nodes. + * If any of these are not frame graph nodes, they will be further searched as + * if they were direct children of this node. + */ +QVector<QFrameGraphNode *> QFrameGraphNodePrivate::childFrameGraphNodes() const +{ + Q_Q(const QFrameGraphNode); + QVector<QFrameGraphNode *> result; + QQueue<QNode *> queue; + queue.append(q->childNodes().toList()); + result.reserve(queue.size()); + while (!queue.isEmpty()) { + auto *child = queue.dequeue(); + auto *childFGNode = qobject_cast<QFrameGraphNode *>(child); + if (childFGNode != nullptr) + result.push_back(childFGNode); + else + queue.append(child->childNodes().toList()); + } + return result; +} + /*! \internal */ QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent) : QNode(dd, parent) diff --git a/src/render/framegraph/qframegraphnode_p.h b/src/render/framegraph/qframegraphnode_p.h index 00cc53626..c03017638 100644 --- a/src/render/framegraph/qframegraphnode_p.h +++ b/src/render/framegraph/qframegraphnode_p.h @@ -65,9 +65,12 @@ class QFrameGraphNodePrivate : public Qt3DCore::QNodePrivate { public: QFrameGraphNodePrivate(); + QVector<QFrameGraphNode *> childFrameGraphNodes() const; + + static QFrameGraphNodePrivate *get(QFrameGraphNode *node) { return node->d_func(); } + static const QFrameGraphNodePrivate *get(const QFrameGraphNode *node) { return node->d_func(); } Q_DECLARE_PUBLIC(QFrameGraphNode) - QList<QFrameGraphNode *> m_fgChildren; }; } // namespace Qt3DRender diff --git a/src/render/framegraph/qframegraphnodecreatedchange.cpp b/src/render/framegraph/qframegraphnodecreatedchange.cpp index ef51d5228..464c98bc3 100644 --- a/src/render/framegraph/qframegraphnodecreatedchange.cpp +++ b/src/render/framegraph/qframegraphnodecreatedchange.cpp @@ -36,7 +36,9 @@ #include "qframegraphnodecreatedchange.h" #include "qframegraphnodecreatedchange_p.h" + #include <Qt3DRender/qframegraphnode.h> +#include <Qt3DRender/private/qframegraphnode_p.h> QT_BEGIN_NAMESPACE @@ -45,6 +47,7 @@ namespace Qt3DRender { QFrameGraphNodeCreatedChangeBasePrivate::QFrameGraphNodeCreatedChangeBasePrivate(const QFrameGraphNode *node) : Qt3DCore::QNodeCreatedChangeBasePrivate(node) , m_parentFrameGraphNodeId(Qt3DCore::qIdForNode(node->parentFrameGraphNode())) + , m_childFrameGraphNodeIds(Qt3DCore::qIdsForNodes(QFrameGraphNodePrivate::get(node)->childFrameGraphNodes())) { } diff --git a/src/render/framegraph/qframegraphnodecreatedchange_p.h b/src/render/framegraph/qframegraphnodecreatedchange_p.h index 9aa396b8f..c0437afc5 100644 --- a/src/render/framegraph/qframegraphnodecreatedchange_p.h +++ b/src/render/framegraph/qframegraphnodecreatedchange_p.h @@ -49,6 +49,7 @@ // #include <Qt3DCore/private/qnodecreatedchange_p.h> +#include <Qt3DRender/qframegraphnodecreatedchange.h> QT_BEGIN_NAMESPACE @@ -62,6 +63,16 @@ public: QFrameGraphNodeCreatedChangeBasePrivate(const QFrameGraphNode *node); Qt3DCore::QNodeId m_parentFrameGraphNodeId; + Qt3DCore::QNodeIdVector m_childFrameGraphNodeIds; + + static QFrameGraphNodeCreatedChangeBasePrivate *get(QFrameGraphNodeCreatedChangeBase *change) + { + return change->d_func(); + } + static const QFrameGraphNodeCreatedChangeBasePrivate *get(const QFrameGraphNodeCreatedChangeBase *change) + { + return change->d_func(); + } }; } // Qt3DRender diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp index 09cb75e46..ccec826ff 100644 --- a/src/render/frontend/qrenderaspect.cpp +++ b/src/render/frontend/qrenderaspect.cpp @@ -481,7 +481,7 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time) // which should likely be renamed to something more generic or we introduce // another synchronizing job for skeleton loading const QVector<Render::HSkeleton> skeletonsToLoad = - manager->skeletonManager()->dirtySkeletons(Render::SkeletonManager::SkeletonDataDirty); + manager->skeletonManager()->takeDirtySkeletons(Render::SkeletonManager::SkeletonDataDirty); for (const auto &skeletonHandle : skeletonsToLoad) { auto loadSkeletonJob = Render::LoadSkeletonJobPtr::create(skeletonHandle); loadSkeletonJob->setNodeManagers(manager); diff --git a/src/render/materialsystem/shaderbuilder_p.h b/src/render/materialsystem/shaderbuilder_p.h index b76c8389f..e9378e3c5 100644 --- a/src/render/materialsystem/shaderbuilder_p.h +++ b/src/render/materialsystem/shaderbuilder_p.h @@ -61,7 +61,7 @@ namespace Qt3DRender { namespace Render { -class Q_AUTOTEST_EXPORT ShaderBuilder : public BackendNode +class QT3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilder : public BackendNode { public: enum ShaderType { diff --git a/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp b/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp index 1e2035c01..59b5701f8 100644 --- a/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp +++ b/src/render/renderers/opengl/graphicshelpers/graphicscontext.cpp @@ -226,7 +226,7 @@ QOpenGLShaderProgram *GraphicsContext::createShaderProgram(Shader *shaderNode) const auto shaderCode = shaderNode->shaderCode(); QString logs; for (int i = QShaderProgram::Vertex; i <= QShaderProgram::Compute; ++i) { - const QShaderProgram::ShaderType type = static_cast<const QShaderProgram::ShaderType>(i); + const QShaderProgram::ShaderType type = static_cast<QShaderProgram::ShaderType>(i); if (!shaderCode.at(i).isEmpty()) { // Note: logs only return the error but not all the shader code // we could append it diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp index 7319fd0e5..c9ba6409d 100644 --- a/src/render/renderers/opengl/renderer/renderer.cpp +++ b/src/render/renderers/opengl/renderer/renderer.cpp @@ -243,11 +243,9 @@ Renderer::Renderer(QRenderAspect::RenderType type) Renderer::~Renderer() { - // If using a threaded rendering approach, tell the thread to exit - // and wait for it to be done - m_running.fetchAndStoreOrdered(0); + Q_ASSERT(m_running.fetchAndStoreOrdered(0) == 0); if (m_renderThread) - m_renderThread->wait(); + Q_ASSERT(m_renderThread->isFinished()); delete m_renderQueue; delete m_defaultRenderStateSet; |