summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-01-25 15:20:18 +0000
committerMike Krus <mike.krus@kdab.com>2020-01-25 15:20:18 +0000
commitab365ba991ec006711550511da471e4c93e01a04 (patch)
tree9221ebfa15a59ddaa1ad5089abddb848ee837ffb /src/core
parent4ae7cc93b503cc31272f0b55c84410af30aea8b9 (diff)
parentdf5a63b059956e8a717db9110327cc86612cc934 (diff)
Merge remote-tracking branch 5.14 into 5.15
* origin/5.14: Fix usage of C++14 features Use animation rather than event to drive simulation Fix for incorrect QML property names in GeometryRenderer doc Add viewAll support for orthographic projection mode Change-Id: I397bdee907389a6f5cabb8390a805fa9a89ed4ca
Diffstat (limited to 'src/core')
-rw-r--r--src/core/aspects/qaspectmanager.cpp48
-rw-r--r--src/core/aspects/qaspectmanager_p.h9
2 files changed, 54 insertions, 3 deletions
diff --git a/src/core/aspects/qaspectmanager.cpp b/src/core/aspects/qaspectmanager.cpp
index f276d633e..662860db2 100644
--- a/src/core/aspects/qaspectmanager.cpp
+++ b/src/core/aspects/qaspectmanager.cpp
@@ -66,6 +66,7 @@
#include <Qt3DCore/private/qscene_p.h>
#include <QtCore/QCoreApplication>
+#include <QtCore/QAbstractAnimation>
#if defined(QT3D_CORE_JOB_TIMING)
#include <QElapsedTimer>
@@ -75,6 +76,23 @@ QT_BEGIN_NAMESPACE
namespace Qt3DCore {
+#if QT_CONFIG(animation)
+class RequestFrameAnimation final : public QAbstractAnimation
+{
+public:
+ RequestFrameAnimation(QObject *parent)
+ : QAbstractAnimation(parent)
+ {
+ }
+
+ ~RequestFrameAnimation() override;
+
+ int duration() const override { return 1; }
+ void updateCurrentTime(int currentTime) override { Q_UNUSED(currentTime) }
+};
+
+RequestFrameAnimation::~RequestFrameAnimation() = default;
+#else
namespace {
class RequestFrameEvent : public QEvent
@@ -93,7 +111,7 @@ private:
int RequestFrameEvent::requestEventType = QEvent::registerEventType();
} // anonymous
-
+#endif
/*!
\class Qt3DCore::QAspectManager
@@ -110,6 +128,9 @@ QAspectManager::QAspectManager(QAspectEngine *parent)
, m_simulationLoopRunning(false)
, m_driveMode(QAspectEngine::Automatic)
, m_postConstructorInit(nullptr)
+#if QT_CONFIG(animation)
+ , m_simulationAnimation(nullptr)
+#endif
, m_jobsInLastFrame(0)
{
qRegisterMetaType<QSurface *>("QSurface*");
@@ -152,8 +173,19 @@ void QAspectManager::enterSimulationLoop()
qCDebug(Aspects) << "Done calling onEngineStartup() for each aspect";
// Start running loop if Qt3D is in charge of driving it
- if (m_driveMode == QAspectEngine::Automatic)
+ if (m_driveMode == QAspectEngine::Automatic) {
+#if QT_CONFIG(animation)
+ if (!m_simulationAnimation) {
+ m_simulationAnimation = new RequestFrameAnimation(this);
+ connect(m_simulationAnimation, &QAbstractAnimation::finished, this, [this]() {
+ processFrame();
+ if (m_simulationLoopRunning && m_driveMode == QAspectEngine::Automatic)
+ requestNextFrame();
+ });
+ }
+#endif
requestNextFrame();
+ }
}
// Main thread (called by QAspectEngine)
@@ -167,6 +199,11 @@ void QAspectManager::exitSimulationLoop()
return;
}
+#if QT_CONFIG(animation)
+ if (m_simulationAnimation)
+ m_simulationAnimation->stop();
+#endif
+
QAbstractFrameAdvanceService *frameAdvanceService =
m_serviceLocator->service<QAbstractFrameAdvanceService>(QServiceLocator::FrameAdvanceService);
if (frameAdvanceService)
@@ -196,7 +233,6 @@ void QAspectManager::exitSimulationLoop()
}
qCDebug(Aspects) << "Done calling onEngineShutdown() for each aspect";
-
m_simulationLoopRunning = false;
qCDebug(Aspects) << "exitSimulationLoop completed";
}
@@ -402,6 +438,7 @@ QVector<QNode *> QAspectManager::lookupNodes(const QVector<QNodeId> &ids) const
return d->m_scene ? d->m_scene->lookupNodes(ids) : QVector<QNode *>{};
}
+#if !QT_CONFIG(animation)
/*!
\internal
\brief Drives the Qt3D simulation loop in the main thread
@@ -423,13 +460,18 @@ bool QAspectManager::event(QEvent *e)
return QObject::event(e);
}
+#endif
void QAspectManager::requestNextFrame()
{
qCDebug(Aspects) << "Requesting new Frame";
// Post event in the event loop to force
// next frame to be processed
+#if QT_CONFIG(animation)
+ m_simulationAnimation->start();
+#else
QCoreApplication::postEvent(this, new RequestFrameEvent());
+#endif
}
void QAspectManager::processFrame()
diff --git a/src/core/aspects/qaspectmanager_p.h b/src/core/aspects/qaspectmanager_p.h
index ed04b314f..2038e0822 100644
--- a/src/core/aspects/qaspectmanager_p.h
+++ b/src/core/aspects/qaspectmanager_p.h
@@ -77,6 +77,9 @@ class QAspectEngine;
class QServiceLocator;
class NodePostConstructorInit;
struct NodeTreeChange;
+#if QT_CONFIG(animation)
+class RequestFrameAnimation;
+#endif
class Q_3DCORE_PRIVATE_EXPORT QAspectManager : public QObject
{
@@ -115,7 +118,9 @@ public:
int jobsInLastFrame() const { return m_jobsInLastFrame; }
private:
+#if !QT_CONFIG(animation)
bool event(QEvent *event) override;
+#endif
void requestNextFrame();
QAspectEngine *m_engine;
@@ -130,6 +135,10 @@ private:
QAspectEngine::RunMode m_driveMode;
QVector<NodeTreeChange> m_nodeTreeChanges;
NodePostConstructorInit* m_postConstructorInit;
+
+#if QT_CONFIG(animation)
+ RequestFrameAnimation *m_simulationAnimation;
+#endif
int m_jobsInLastFrame;
};