From 4ccc13c4687d76c43980db8558e8c71364b052ba Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Fri, 8 Jan 2016 14:29:26 +0100 Subject: Remove unused ListAllocationPolicy. Change-Id: I59a6461fd3e81d578af3cc33248fb21d8b503135 Reviewed-by: Sean Harmer --- src/core/resources/qresourcemanager.cpp | 18 - src/core/resources/qresourcemanager_p.h | 56 --- tests/auto/core/core.pro | 1 - .../listresourcesmanager/listresourcesmanager.pro | 7 - .../tst_listresourcesmanager.cpp | 434 --------------------- 5 files changed, 516 deletions(-) delete mode 100644 tests/auto/core/listresourcesmanager/listresourcesmanager.pro delete mode 100644 tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp diff --git a/src/core/resources/qresourcemanager.cpp b/src/core/resources/qresourcemanager.cpp index 5ece6a03f..8af1d5d5d 100644 --- a/src/core/resources/qresourcemanager.cpp +++ b/src/core/resources/qresourcemanager.cpp @@ -65,24 +65,6 @@ released \sa QResourceManager - \sa ListAllocatingPolicy -*/ - -/*! - \class Qt3DCore::ListAllocatingPolicy - \inmodule Qt3DCore - \since 5.5 - - \brief Allocates resources in a list. - - It is best to use it when you don't need to iterate over an entire set of resources, in which - case ArrayAllocatingPolicy is faster. It can store a non predefined amount of resources, though - there might not be enough handles at some point, depending on the INDEXBITS used. - It's main use case is to manage resources that are accessed in an independent manner from other - resources of the same type. - - \sa QResourceManager - \sa ArrayAllocatingPolicy */ /*! diff --git a/src/core/resources/qresourcemanager_p.h b/src/core/resources/qresourcemanager_p.h index 5f094881d..47f067409 100644 --- a/src/core/resources/qresourcemanager_p.h +++ b/src/core/resources/qresourcemanager_p.h @@ -286,62 +286,6 @@ private: }; -template -class ListAllocatingPolicy -{ -public: - ListAllocatingPolicy() - { - } - - T* allocateResource() - { - int idx; - T *newT; - if (!m_freeEntries.isEmpty()) { - idx = m_freeEntries.takeFirst(); - m_resourcesEntries[idx] = T(); - newT = &m_resourcesEntries[idx]; - } - else { - m_resourcesEntries.append(T()); - idx = m_resourcesEntries.size() - 1; - newT = &m_resourcesEntries.last(); - } - // If elements are added to the list, we're not sure the address - // that was returned here for previous elements stays valid - m_resourcesToIndices[newT] = idx; - return newT; - } - - void releaseResource(T *r) - { - if (m_resourcesToIndices.contains(r)) { - performCleanup(r, Int2Type::needsCleanup>()); - m_freeEntries.append(m_resourcesToIndices.take(r)); - } - } - - void reset() - { - m_resourcesEntries.clear(); - m_resourcesToIndices.clear(); - } - -private: - QList m_resourcesEntries; - QHash m_resourcesToIndices; - QList m_freeEntries; - - void performCleanup(T *r, Int2Type) - { - r->cleanup(); - } - - void performCleanup(T *, Int2Type) - {} -}; - template class AllocatingPolicy = ArrayAllocatingPolicy, template class LockingPolicy = NonLockingPolicy diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro index d33b97edc..e76a7d856 100644 --- a/tests/auto/core/core.pro +++ b/tests/auto/core/core.pro @@ -4,7 +4,6 @@ SUBDIRS = \ handle \ handlemanager \ arrayresourcesmanager \ - listresourcesmanager \ qcircularbuffer \ qboundedcircularbuffer \ nodes \ diff --git a/tests/auto/core/listresourcesmanager/listresourcesmanager.pro b/tests/auto/core/listresourcesmanager/listresourcesmanager.pro deleted file mode 100644 index ab1ea78db..000000000 --- a/tests/auto/core/listresourcesmanager/listresourcesmanager.pro +++ /dev/null @@ -1,7 +0,0 @@ -TARGET = tst_listresourcesmanager -CONFIG += testcase -TEMPLATE = app - -SOURCES += tst_listresourcesmanager.cpp - -QT += testlib 3dcore 3dcore-private diff --git a/tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp b/tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp deleted file mode 100644 index 5cbbe97bd..000000000 --- a/tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -class tst_ListResourcesManager : public QObject -{ - Q_OBJECT -public: - tst_ListResourcesManager() {} - ~tst_ListResourcesManager() {} - -private slots: - void createResourcesManager(); - void acquireResources(); - void getResources(); - void registerResourcesResize(); - void removeResource(); - void resetResource(); - void lookupResource(); - void releaseResource(); - void heavyDutyMultiThreadedAccess(); - void heavyDutyMultiThreadedAccessRelease(); - void maximumNumberOfResources(); -}; - -class tst_ListResource -{ -public: - tst_ListResource() : m_value(0) - {} - - QAtomicInt m_value; -}; - -typedef Qt3DCore::QHandle tHandle; -typedef Qt3DCore::QHandle tHandle4; -typedef Qt3DCore::QHandle tHandle8; -typedef Qt3DCore::QHandle tHandle16; - -void tst_ListResourcesManager::createResourcesManager() -{ - Qt3DCore::QResourceManager manager16; - Qt3DCore::QResourceManager manager4; - Qt3DCore::QResourceManager manager8; - - QVERIFY(manager16.maxResourcesEntries() == 65535); - QVERIFY(manager8.maxResourcesEntries() == 255); - QVERIFY(manager4.maxResourcesEntries() == 15); -} - -/*! - * Check that the handles returned when a registering resources - * have a correct index and counter. - */ -void tst_ListResourcesManager::acquireResources() -{ - Qt3DCore::QResourceManager manager; - - QList handles; - - for (int i = 0; i < 5; i++) { - handles << manager.acquire(); - } - - for (uint i = 0; i < 5; i++) { - QVERIFY(handles.at(i).index() == i); - QVERIFY(handles.at(i).counter() == 1); - } -} - -/*! - * Test that values can be properly retrieved. - */ -void tst_ListResourcesManager::getResources() -{ - - Qt3DCore::QResourceManager manager; - QList resources; - QList handles; - - for (int i = 0; i < 5; i++) { - handles << manager.acquire(); - } - - for (uint i = 0; i < 5; i++) { - QVERIFY(handles.at(i).index() == i); - QVERIFY(handles.at(i).counter() == 1); - resources << manager.data(handles.at(i)); - QVERIFY(resources.at(i) != Q_NULLPTR); - resources.at(i)->m_value = i; - } - - for (int i = 0; i < 5; i++) - QVERIFY(manager.data(handles.at(i))->m_value == i); - - // Check that an invalid resource returns NULL - tHandle8 iHandle; - QVERIFY(manager.data(iHandle) == Q_NULLPTR); - -} - -/*! - * Test that when a resize of the data vectors in the manager occurs, - * everything behaves correctly. - */ -void tst_ListResourcesManager::registerResourcesResize() -{ - Qt3DCore::QResourceManager manager; - QList handles; - - for (uint i = 0; i < 2; i++) { - handles << manager.acquire(); - manager.data(handles.at(i))->m_value = i + 2; - } - - for (uint i = 0; i < 5; i++) { - handles << manager.acquire(); - manager.data(handles.at(i + 2))->m_value = i + 2 + 5; - } - - for (int i = 0; i < 7; i++) { - QVERIFY(handles.at(i).index() == static_cast(i)); - QVERIFY(handles.at(i).counter() == 1); - if (i < 2) - QVERIFY(manager.data(handles.at(i))->m_value == i + 2); - else - QVERIFY(manager.data(handles.at(i))->m_value == i + 5); - } -} - -/*! - * Checks for the removal of resources. - */ -void tst_ListResourcesManager::removeResource() -{ - Qt3DCore::QResourceManager manager; - - QList resources; - QList handles; - - for (int i = 0; i < 32; i++) { - handles << manager.acquire(); - resources << manager.data(handles.at(i)); - } - - manager.release(handles.at(2)); - QVERIFY(manager.data(handles.at(2)) == Q_NULLPTR); - // Triggers QASSERT so commented -// manager.release(handles.at(2)); - - tHandle nHandle = manager.acquire(); - QVERIFY(manager.data(nHandle) != Q_NULLPTR); -} - -/*! - * Checks that reset behaves correctly. - */ -void tst_ListResourcesManager::resetResource() -{ - Qt3DCore::QResourceManager manager; - - QList resources; - QList handles; - - for (int i = 0; i < 5; i++) { - handles << manager.acquire(); - resources << manager.data(handles.at(i)); - resources.at(i)->m_value = 4; - } - manager.reset(); - for (uint i = 0; i < 5; i++) { - QVERIFY(manager.data(handles.at(i)) == Q_NULLPTR); - } - handles.clear(); - for (uint i = 0; i < 5; i++) - handles << manager.acquire(); - - for (uint i = 0; i < 5; i++) { - QVERIFY(handles.at(i).index() == i); - QVERIFY(handles.at(i).counter() == 1); - QVERIFY(manager.data(handles.at(i))->m_value != 4); - } -} - -void tst_ListResourcesManager::lookupResource() -{ - Qt3DCore::QResourceManager manager; - - QList resources; - QList handles; - - for (int i = 0; i < 5; i++) { - handles << manager.acquire(); - resources << manager.data(handles.at(i)); - resources.at(i)->m_value = 4; - } - - tHandle16 t = manager.lookupHandle(2); - QVERIFY(t.handle() == 0); - QVERIFY(manager.data(t) == Q_NULLPTR); - tst_ListResource *resource = manager.getOrCreateResource(2); - QVERIFY(resource != Q_NULLPTR); - t = manager.lookupHandle(2); - QVERIFY(manager.data(t) == manager.lookupResource(2)); - QVERIFY(t == manager.getOrAcquireHandle(2)); - QVERIFY(resource == manager.getOrCreateResource(2)); - QVERIFY(manager.data(t) == resource); -} - -void tst_ListResourcesManager::releaseResource() -{ - Qt3DCore::QResourceManager manager; - QList resources; - - for (int i = 0; i < 5; i++) { - resources << manager.getOrCreateResource(i); - } - - for (int i = 0; i < 5; i++) { - QVERIFY(resources.at(i) == manager.lookupResource(i)); - } - - for (int i = 0; i < 5; i++) { - manager.releaseResource(i); - QVERIFY(manager.lookupResource(i) == Q_NULLPTR); - } -} - -class tst_Thread : public QThread -{ - Q_OBJECT -public: - - typedef Qt3DCore::QResourceManager Manager; - - tst_Thread() : QThread() - { - } - - void setManager(Manager *manager) - { - m_manager = manager; - } - - // QThread interface -protected: - void run() - { - int i = 0; - int max = tHandle16::maxIndex(); - while (i < max) { - tst_ListResource *r = m_manager->getOrCreateResource(i); - i++; - QVERIFY(r != Q_NULLPTR); - r->m_value.fetchAndAddOrdered(+1); - } - qDebug() << QThread::currentThread() << "Done"; - } - - Manager *m_manager; -}; - - -void tst_ListResourcesManager::heavyDutyMultiThreadedAccess() -{ - tst_Thread::Manager *manager = new tst_Thread::Manager(); - - QList threads; - - int iterations = 8; - int max = tHandle16::maxIndex(); - - for (int i = 0; i < iterations; i++) { - tst_Thread *thread = new tst_Thread(); - thread->setManager(manager); - threads << thread; - } - - for (int i = 0; i < iterations; i++) { - threads[i]->start(); - } - - for (int i = 0; i < iterations; i++) { - threads[i]->wait(); - } - - for (int i = 0; i < max; i++) { - QVERIFY(manager->lookupResource(i) != Q_NULLPTR); - QVERIFY(manager->lookupResource(i)->m_value = iterations); - } - - qDeleteAll(threads); - delete manager; -} - -class tst_Thread2 : public QThread -{ - Q_OBJECT -public: - - typedef Qt3DCore::QResourceManager Manager; - - tst_Thread2(int releaseAbove = 7) - : QThread() - , m_releaseAbove(releaseAbove) - { - } - - void setManager(Manager *manager) - { - m_manager = manager; - } - - // QThread interface -protected: - void run() - { - int i = 0; - int max = tHandle::maxIndex(); - while (i < max) { - tst_ListResource *r = m_manager->getOrCreateResource(i); - QVERIFY(r != Q_NULLPTR); - int oldValue = r->m_value.fetchAndAddOrdered(+1); - if (oldValue == m_releaseAbove) - m_manager->releaseResource(i); - i++; - } - qDebug() << QThread::currentThread() << "Done"; - } - - Manager *m_manager; - int m_releaseAbove; -}; - -void tst_ListResourcesManager::heavyDutyMultiThreadedAccessRelease() -{ - tst_Thread2::Manager *manager = new tst_Thread2::Manager(); - - QList threads; - - int iterations = 8; - int max = tHandle16::maxIndex(); - - for (int u = 0; u < 2; u++) { - - for (int i = 0; i < iterations; i++) { - tst_Thread2 *thread = new tst_Thread2(); - thread->setManager(manager); - threads << thread; - } - - for (int i = 0; i < iterations; i++) { - threads[i]->start(); - } - - for (int i = 0; i < iterations; i++) { - threads[i]->wait(); - } - - for (int i = 0; i < max; i++) { - QVERIFY(manager->lookupResource(i) == Q_NULLPTR); - } - - qDeleteAll(threads); - threads.clear(); - } - - delete manager; -} - -void tst_ListResourcesManager::maximumNumberOfResources() -{ - Qt3DCore::QResourceManager manager; - - QList resources; - QList handles; - - QCOMPARE(tHandle16::maxIndex(), (uint)manager.maxResourcesEntries()); - - for (int i = 0; i < manager.maxResourcesEntries(); i++) { - handles << manager.acquire(); - resources << manager.data(handles.at(i)); - resources.at(i)->m_value = 4; - } -} - -QTEST_APPLESS_MAIN(tst_ListResourcesManager) - -#include "tst_listresourcesmanager.moc" -- cgit v1.2.3 From abeb0ea0dc3b9e09cd6946ddf9a9a82f4b360e36 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 12 Jan 2016 16:34:23 +0200 Subject: "cleanup" method needs to be virtual. Change-Id: I0075adf8b927a29f06be6ab883622b216cca5b44 Reviewed-by: Sean Harmer --- src/input/backend/qabstractphysicaldevicebackendnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input/backend/qabstractphysicaldevicebackendnode.h b/src/input/backend/qabstractphysicaldevicebackendnode.h index 1d7ef21bd..3846d1a1e 100644 --- a/src/input/backend/qabstractphysicaldevicebackendnode.h +++ b/src/input/backend/qabstractphysicaldevicebackendnode.h @@ -56,7 +56,7 @@ class QT3DINPUTSHARED_EXPORT QAbstractPhysicalDeviceBackendNode : public Qt3DCor public: explicit QAbstractPhysicalDeviceBackendNode(QBackendNode::Mode mode); void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE; - void cleanup(); + virtual void cleanup(); void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; void setInputAspect(QInputAspect *aspect); -- cgit v1.2.3 From 90435d6cd003c727167af002f6e9d02fdd0bb98c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 7 Jan 2016 10:02:49 +0100 Subject: qgltf: Add a short description to the help Change-Id: I978127436e197c714f7ad43c86c1c7896b94d9cd Reviewed-by: Andy Nichols --- tools/qgltf/qgltf.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/qgltf/qgltf.cpp b/tools/qgltf/qgltf.cpp index 02de0224b..cd6f23280 100644 --- a/tools/qgltf/qgltf.cpp +++ b/tools/qgltf/qgltf.cpp @@ -2458,6 +2458,14 @@ void GltfExporter::save(const QString &inputFilename) qDebug() << "Done\n"; } +static const char *description = + "qgltf uses Assimp to import a variety of 3D model formats " + "and export it into fast-to-load, optimized glTF " + "assets embedded into Qt resource files.\n\n" + "Note: this tool should typically not be invoked directly. Instead, " + "let qmake manage it based on QT3D_MODELS in the .pro file.\n\n" + "For standard Qt 3D usage the recommended options are -b -S."; + int main(int argc, char **argv) { QCoreApplication app(argc, argv); @@ -2467,6 +2475,7 @@ int main(int argc, char **argv) QCommandLineParser cmdLine; cmdLine.addHelpOption(); cmdLine.addVersionOption(); + cmdLine.setApplicationDescription(QString::fromUtf8(description)); QCommandLineOption outDirOpt(QStringLiteral("d"), QStringLiteral("Place all output data into "), QStringLiteral("dir")); cmdLine.addOption(outDirOpt); QCommandLineOption binOpt(QStringLiteral("b"), QStringLiteral("Store binary JSON data in the .qgltf file")); @@ -2517,6 +2526,9 @@ int main(int argc, char **argv) QDir().mkpath(opts.outDir); } + if (cmdLine.positionalArguments().isEmpty()) + cmdLine.showHelp(); + AssimpImporter importer; GltfExporter exporter(&importer); foreach (const QString &fn, cmdLine.positionalArguments()) { -- cgit v1.2.3 From 4a63bba7ce76801b8bea1094a7ff16a9f8029b37 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 7 Jan 2016 13:06:11 +0100 Subject: Make the qgltf example use other assets Wine is complex and not ideal for a getting started example. Instead, use three of the simpler scenes. Change-Id: I6859714e14c47c4907e85a48cde27d0ea5748ffa Reviewed-by: Andy Nichols --- examples/qt3d/qgltf/Scene.qml | 73 +++++++++++++++++++++++++++++++++++ examples/qt3d/qgltf/Wine.qml | 60 ---------------------------- examples/qt3d/qgltf/main.qml | 24 +++--------- examples/qt3d/qgltf/qgltf.pro | 9 +++-- examples/qt3d/qgltf/qgltf_example.qrc | 2 +- 5 files changed, 86 insertions(+), 82 deletions(-) create mode 100644 examples/qt3d/qgltf/Scene.qml delete mode 100644 examples/qt3d/qgltf/Wine.qml diff --git a/examples/qt3d/qgltf/Scene.qml b/examples/qt3d/qgltf/Scene.qml new file mode 100644 index 000000000..e6d0e7dd8 --- /dev/null +++ b/examples/qt3d/qgltf/Scene.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 + +Entity { + id: root + + Entity { + components: [ + Transform { + translation: Qt.vector3d(-30, 0, 0) + rotation: fromEulerAngles(-90, 180, 0) + }, + SceneLoader { + source: "qrc:/models/test_scene.qgltf" + } + ] + } + + Entity { + components: [ + SceneLoader { + source: "qrc:/models/toyplane.qgltf" + } + ] + } + + Entity { + components: [ + Transform { + translation: Qt.vector3d(0, -20, 0) + }, + SceneLoader { + source: "qrc:/models/trefoil.qgltf" + } + ] + } +} diff --git a/examples/qt3d/qgltf/Wine.qml b/examples/qt3d/qgltf/Wine.qml deleted file mode 100644 index b24e9de3f..000000000 --- a/examples/qt3d/qgltf/Wine.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Entity { - id: root - - property vector3d position: Qt.vector3d(0, 0, 0) - property real angleX: 0 - property real angleY: 0 - property real angleZ: 0 - property real scale: 1 - - components: [ - Transform { - translation: root.position - rotation: fromEulerAngles(root.angleX, root.angleY, root.angleZ) - scale: root.scale - }, - SceneLoader - { - source: "qrc:/models/wine.qgltf" - } - ] -} diff --git a/examples/qt3d/qgltf/main.qml b/examples/qt3d/qgltf/main.qml index 7f8f081ab..6ee7ae39e 100644 --- a/examples/qt3d/qgltf/main.qml +++ b/examples/qt3d/qgltf/main.qml @@ -48,8 +48,8 @@ Entity { aspectRatio: 16/9 nearPlane : 0.1 farPlane : 1000.0 - position: Qt.vector3d( 0.0, -100.0, -120.0 ) - upVector: Qt.vector3d( 0.0, -1.0, 0.0 ) + position: Qt.vector3d( 0.0, 0.0, 100.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } @@ -58,24 +58,12 @@ Entity { } components: FrameGraph { - activeFrameGraph : Viewport { - CameraSelector { - camera: camera - ClearBuffer { - buffers: ClearBuffer.ColorDepthBuffer - SortMethod { - criteria: [ - SortCriterion { sort: SortCriterion.BackToFront } - ] - } - } - } + activeFrameGraph: ForwardRenderer { + clearColor: Qt.rgba(0, 0.5, 1, 1) + camera: camera } } - Wine { - id: wineRack - position: Qt.vector3d(-60.0, 0.0, 50.0) - angleX: 180 + Scene { } } diff --git a/examples/qt3d/qgltf/qgltf.pro b/examples/qt3d/qgltf/qgltf.pro index 3ba543ec5..61361b0e6 100644 --- a/examples/qt3d/qgltf/qgltf.pro +++ b/examples/qt3d/qgltf/qgltf.pro @@ -11,10 +11,13 @@ SOURCES += \ OTHER_FILES += \ main.qml \ - Wine.qml + Scene.qml -QT3D_MODELS = ../exampleresources/assets/gltf/wine/wine.dae -QGLTF_PARAMS = -g +QT3D_MODELS = ../exampleresources/assets/test_scene.dae \ + ../exampleresources/assets/obj/toyplane.obj \ + ../exampleresources/assets/obj/trefoil.obj + +QGLTF_PARAMS = -b -S load(qgltf) RESOURCES += \ diff --git a/examples/qt3d/qgltf/qgltf_example.qrc b/examples/qt3d/qgltf/qgltf_example.qrc index 0da7ea21f..72868031a 100644 --- a/examples/qt3d/qgltf/qgltf_example.qrc +++ b/examples/qt3d/qgltf/qgltf_example.qrc @@ -1,6 +1,6 @@ main.qml - Wine.qml + Scene.qml -- cgit v1.2.3 From 825f7fe1d80583fe70c1616e1d3973cc3dc65e7b Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 14 Jan 2016 17:38:25 +0200 Subject: Make axisIdentifier & buttonIdentifier const Change-Id: Idedf3cab5d8a30d1a417ceb10555170b53b00d26 Reviewed-by: Paul Lemire --- src/input/frontend/qabstractphysicaldevice.h | 4 ++-- src/input/frontend/qkeyboardcontroller.cpp | 4 ++-- src/input/frontend/qkeyboardcontroller.h | 4 ++-- src/input/frontend/qmousecontroller.cpp | 4 ++-- src/input/frontend/qmousecontroller.h | 4 ++-- tests/auto/input/commons/testdevice.h | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/input/frontend/qabstractphysicaldevice.h b/src/input/frontend/qabstractphysicaldevice.h index 915042edc..8056a195b 100644 --- a/src/input/frontend/qabstractphysicaldevice.h +++ b/src/input/frontend/qabstractphysicaldevice.h @@ -62,8 +62,8 @@ public: virtual QStringList axisNames() const = 0; virtual QStringList buttonNames() const = 0; - virtual int axisIdentifier(const QString &name) = 0; - virtual int buttonIdentifier(const QString &name) = 0; + virtual int axisIdentifier(const QString &name) const = 0; + virtual int buttonIdentifier(const QString &name) const = 0; void addAxisSetting(QAxisSetting *axisSetting); void removeAxisSetting(QAxisSetting *axisSetting); diff --git a/src/input/frontend/qkeyboardcontroller.cpp b/src/input/frontend/qkeyboardcontroller.cpp index 77b54c7fa..09ff52066 100644 --- a/src/input/frontend/qkeyboardcontroller.cpp +++ b/src/input/frontend/qkeyboardcontroller.cpp @@ -258,13 +258,13 @@ QStringList QKeyboardController::buttonNames() const return d->m_keyNames; } -int QKeyboardController::axisIdentifier(const QString &name) +int QKeyboardController::axisIdentifier(const QString &name) const { Q_UNUSED(name); return 0; } -int QKeyboardController::buttonIdentifier(const QString &name) +int QKeyboardController::buttonIdentifier(const QString &name) const { Q_D(const QKeyboardController); return d->m_keyMap.value(name, 0); diff --git a/src/input/frontend/qkeyboardcontroller.h b/src/input/frontend/qkeyboardcontroller.h index aafbd3e57..e929629d9 100644 --- a/src/input/frontend/qkeyboardcontroller.h +++ b/src/input/frontend/qkeyboardcontroller.h @@ -62,8 +62,8 @@ public: int buttonCount() const Q_DECL_FINAL; QStringList axisNames() const Q_DECL_FINAL; QStringList buttonNames() const Q_DECL_FINAL; - int axisIdentifier(const QString &name) Q_DECL_FINAL; - int buttonIdentifier(const QString &name) Q_DECL_FINAL; + int axisIdentifier(const QString &name) const Q_DECL_FINAL; + int buttonIdentifier(const QString &name) const Q_DECL_FINAL; protected: QKeyboardController(QKeyboardControllerPrivate &dd, QNode *parent = 0); diff --git a/src/input/frontend/qmousecontroller.cpp b/src/input/frontend/qmousecontroller.cpp index a8e3cbc61..30b200629 100644 --- a/src/input/frontend/qmousecontroller.cpp +++ b/src/input/frontend/qmousecontroller.cpp @@ -107,7 +107,7 @@ QStringList QMouseController::buttonNames() const << QStringLiteral("Center"); } -int QMouseController::axisIdentifier(const QString &name) +int QMouseController::axisIdentifier(const QString &name) const { if (name == QStringLiteral("X")) return X; @@ -116,7 +116,7 @@ int QMouseController::axisIdentifier(const QString &name) return -1; } -int QMouseController::buttonIdentifier(const QString &name) +int QMouseController::buttonIdentifier(const QString &name) const { if (name == QStringLiteral("Left")) return Left; diff --git a/src/input/frontend/qmousecontroller.h b/src/input/frontend/qmousecontroller.h index 8a03d7e14..3773c652c 100644 --- a/src/input/frontend/qmousecontroller.h +++ b/src/input/frontend/qmousecontroller.h @@ -72,8 +72,8 @@ public: int buttonCount() const Q_DECL_FINAL; QStringList axisNames() const Q_DECL_FINAL; QStringList buttonNames() const Q_DECL_FINAL; - int axisIdentifier(const QString &name) Q_DECL_FINAL; - int buttonIdentifier(const QString &name) Q_DECL_FINAL; + int axisIdentifier(const QString &name) const Q_DECL_FINAL; + int buttonIdentifier(const QString &name) const Q_DECL_FINAL; float sensitivity() const; diff --git a/tests/auto/input/commons/testdevice.h b/tests/auto/input/commons/testdevice.h index d04130cfc..b8e048a86 100644 --- a/tests/auto/input/commons/testdevice.h +++ b/tests/auto/input/commons/testdevice.h @@ -54,8 +54,8 @@ public: int buttonCount() const Q_DECL_FINAL { return 0; } QStringList axisNames() const Q_DECL_FINAL { return QStringList(); } QStringList buttonNames() const Q_DECL_FINAL { return QStringList(); } - int axisIdentifier(const QString &name) Q_DECL_FINAL { Q_UNUSED(name) return 0; } - int buttonIdentifier(const QString &name) Q_DECL_FINAL { Q_UNUSED(name) return 0; } + int axisIdentifier(const QString &name) const Q_DECL_FINAL { Q_UNUSED(name) return 0; } + int buttonIdentifier(const QString &name) const Q_DECL_FINAL { Q_UNUSED(name) return 0; } protected: void copy(const Qt3DCore::QNode *ref) Q_DECL_FINAL -- cgit v1.2.3 From 27c07d859a9704bab78b989297b2d9ce5629aeef Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 23 Nov 2015 21:03:15 +0100 Subject: centralize + fix use of system assimp follow the foo.pri & foo_dependency.pri pattern found in qtbase to de-duplicate the code (and thus implicitly make it consistent) and synchronize the conditionals in the configure test. also document why we still can't enable the assimp sceneparser in all configurations. Change-Id: I3bdc30e077b6c9c7027a9311195c08a6c5f1fcf4 Reviewed-by: Joerg Bornemann --- config.tests/assimp/assimp.pro | 6 +++--- src/3rdparty/assimp/assimp_dependency.pri | 11 +++++++++++ src/plugins/sceneparsers/assimp/assimp.pro | 11 +---------- src/plugins/sceneparsers/sceneparsers.pro | 2 ++ tools/qgltf/qgltf.pro | 13 +++---------- 5 files changed, 20 insertions(+), 23 deletions(-) create mode 100644 src/3rdparty/assimp/assimp_dependency.pri diff --git a/config.tests/assimp/assimp.pro b/config.tests/assimp/assimp.pro index 5f022ced4..920c451c4 100644 --- a/config.tests/assimp/assimp.pro +++ b/config.tests/assimp/assimp.pro @@ -1,8 +1,8 @@ SOURCES += main.cpp -LIBS += -lassimp - -unix { +unix:!contains(QT_CONFIG, no-pkg-config) { CONFIG += link_pkgconfig PKGCONFIG += assimp +} else { + LIBS += -lassimp } diff --git a/src/3rdparty/assimp/assimp_dependency.pri b/src/3rdparty/assimp/assimp_dependency.pri new file mode 100644 index 000000000..4fe0df54e --- /dev/null +++ b/src/3rdparty/assimp/assimp_dependency.pri @@ -0,0 +1,11 @@ +config_assimp:!if(cross_compile:host_build) { + unix:!contains(QT_CONFIG, no-pkg-config) { + CONFIG += link_pkgconfig + PKGCONFIG_PRIVATE += assimp + } else { + LIBS += -lassimp + } + return() +} else { + include(assimp.pri) +} diff --git a/src/plugins/sceneparsers/assimp/assimp.pro b/src/plugins/sceneparsers/assimp/assimp.pro index 215941071..3660b1f6d 100644 --- a/src/plugins/sceneparsers/assimp/assimp.pro +++ b/src/plugins/sceneparsers/assimp/assimp.pro @@ -5,16 +5,7 @@ PLUGIN_TYPE = sceneparsers PLUGIN_CLASS_NAME = AssimpParserPlugin load(qt_plugin) -config_assimp { - LIBS += -lassimp - - unix { - CONFIG += link_pkgconfig - PKGCONFIG_PRIVATE += assimp - } -} else { - include(../../../3rdparty/assimp/assimp.pri) -} +include(../../../3rdparty/assimp/assimp_dependency.pri) HEADERS += \ assimphelpers.h \ diff --git a/src/plugins/sceneparsers/sceneparsers.pro b/src/plugins/sceneparsers/sceneparsers.pro index 9271659db..ccb7a96aa 100644 --- a/src/plugins/sceneparsers/sceneparsers.pro +++ b/src/plugins/sceneparsers/sceneparsers.pro @@ -1,3 +1,5 @@ TEMPLATE = subdirs +# QNX is not supported, and Linux GCC 4.9 on ARM chokes on the assimp +# sources (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66964). config_assimp|!cross_compile: SUBDIRS += assimp SUBDIRS += gltf diff --git a/tools/qgltf/qgltf.pro b/tools/qgltf/qgltf.pro index b6aa6f048..de0f1cdd5 100644 --- a/tools/qgltf/qgltf.pro +++ b/tools/qgltf/qgltf.pro @@ -3,14 +3,9 @@ option(host_build) SOURCES = qgltf.cpp -config_assimp:!cross_compile { - !contains(QT_CONFIG, no-pkg-config) { - CONFIG += link_pkgconfig - PKGCONFIG_PRIVATE += assimp - } else { - LIBS += -lassimp - } -} else { +include(../../src/3rdparty/assimp/assimp_dependency.pri) + +force_bootstrap { # Fix for using bootstrap module on OSX outside of qtbase contains(QT_CONFIG, qt_framework) { # Add framework headers directly to make bootstrap lib work @@ -18,8 +13,6 @@ config_assimp:!cross_compile { # Extend framework search path to make #include work QMAKE_CXXFLAGS += -F$$QT.core.libs } - - include(../../src/3rdparty/assimp/assimp.pri) } load(qt_tool) -- cgit v1.2.3 From c1dc4aaa3b9ec08510ef4246b779d999391a3b3d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 24 Nov 2015 11:28:19 +0100 Subject: remove workaround for framework builds the bootstrap library is supposed to work out of the box now. Change-Id: Ida1d181b55a37dc9f1b049bc2586aca5a9d9dc9c Reviewed-by: Joerg Bornemann --- tools/qgltf/qgltf.pro | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tools/qgltf/qgltf.pro b/tools/qgltf/qgltf.pro index de0f1cdd5..a61607204 100644 --- a/tools/qgltf/qgltf.pro +++ b/tools/qgltf/qgltf.pro @@ -5,14 +5,4 @@ SOURCES = qgltf.cpp include(../../src/3rdparty/assimp/assimp_dependency.pri) -force_bootstrap { - # Fix for using bootstrap module on OSX outside of qtbase - contains(QT_CONFIG, qt_framework) { - # Add framework headers directly to make bootstrap lib work - INCLUDEPATH += $$QT.core.libs/QtCore.framework/Headers - # Extend framework search path to make #include work - QMAKE_CXXFLAGS += -F$$QT.core.libs - } -} - load(qt_tool) -- cgit v1.2.3 From 8b820e8f93c851c08941a4eead519588d2135c3d Mon Sep 17 00:00:00 2001 From: Mauro Persano Date: Fri, 15 Jan 2016 18:31:19 +0000 Subject: Revert "Fix crash when Scene3DItem is removed from scene" This reverts commit 658d7bee705224c9e2fbbab1d5e79d32c99858f7. The problem that this commit tried to fix still exists, but the commit seems to have just replaced a kind of shutdown crash with a different one. Change-Id: Ic34b4da9798269c2ed8b02992c811c2129eb5673 Reviewed-by: Sean Harmer --- src/quick3d/imports/scene3d/scene3ditem.cpp | 65 ++++++++++++++--------------- src/quick3d/imports/scene3d/scene3ditem_p.h | 1 - 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index 2e55c52ee..ef839ae87 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -96,8 +96,9 @@ class Scene3DSGNode; \li The window is closed - \li Scene3DItem is notified via itemChange() and calls shutdown() on Scene3DRenderer, - which performs the necessary cleanups in the QSGRenderThread (destroys DebugLogger ...). + \li This triggers the windowsChanged signal which the Scene3DRenderer + uses to perform the necessary cleanups in the QSGRenderThread (destroys + DebugLogger ...) with the shutdown slot (queued connection). \li The destroyed signal of the window is also connected to the Scene3DRenderer. When triggered in the context of the main thread, the @@ -162,6 +163,7 @@ public: Q_CHECK_PTR(m_item->window()); QObject::connect(m_item->window(), &QQuickWindow::beforeRendering, this, &Scene3DRenderer::render, Qt::DirectConnection); + QObject::connect(m_item, &QQuickItem::windowChanged, this, &Scene3DRenderer::onWindowChangedQueued, Qt::QueuedConnection); ContextSaver saver; @@ -213,12 +215,37 @@ public: void synchronize(); - // Executed in the QtQuick render thread. - void shutdown(); - public Q_SLOTS: void render(); + // Executed in the QtQuick render thread. + void shutdown() + { + qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread(); + + // Set to null so that subsequent calls to render + // would return early + m_item = Q_NULLPTR; + + // Shutdown the Renderer Aspect while the OpenGL context + // is still valid + if (m_renderAspect) + m_renderAspect->renderShutdown(); + } + + // SGThread + void onWindowChangedQueued(QQuickWindow *w) + { + if (w == Q_NULLPTR) { + qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread(); + shutdown(); + // Will only trigger something with the Loader case + // The window closed cases is handled by the window's destroyed + // signal + QMetaObject::invokeMethod(m_cleaner, "cleanup"); + } + } + private: Scene3DItem *m_item; // Will be released by the QQuickWindow/QML Engine Qt3DCore::QAspectEngine *m_aspectEngine; // Will be released by the Scene3DRendererCleaner @@ -538,15 +565,6 @@ void Scene3DItem::setMultisample(bool enable) } } -void Scene3DItem::itemChange(ItemChange change, const ItemChangeData& value) -{ - // Are we being removed from the scene? - if (change == QQuickItem::ItemSceneChange && value.window == Q_NULLPTR) - m_renderer->shutdown(); - - QQuickItem::itemChange(change, value); -} - QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *) { // If the node already exists @@ -576,25 +594,6 @@ void Scene3DRenderer::synchronize() m_multisample = m_item->multisample(); } -void Scene3DRenderer::shutdown() -{ - qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread(); - - // Set to null so that subsequent calls to render - // would return early - m_item = Q_NULLPTR; - - // Shutdown the Renderer Aspect while the OpenGL context - // is still valid - if (m_renderAspect) - m_renderAspect->renderShutdown(); - - // Will only trigger something with the Loader case - // The window closed cases is handled by the window's destroyed - // signal - QMetaObject::invokeMethod(m_cleaner, "cleanup"); -} - void Scene3DRenderer::setSGNode(Scene3DSGNode *node) Q_DECL_NOEXCEPT { m_node = node; diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h index 1b9335203..edb0b7b00 100644 --- a/src/quick3d/imports/scene3d/scene3ditem_p.h +++ b/src/quick3d/imports/scene3d/scene3ditem_p.h @@ -93,7 +93,6 @@ private Q_SLOTS: void applyRootEntityChange(); private: - void itemChange(ItemChange change, const ItemChangeData& value); QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) Q_DECL_OVERRIDE; QStringList m_aspects; -- cgit v1.2.3