diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-08-26 16:24:53 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-08-27 10:41:31 +0100 |
commit | 66b06525c57342016ba94c9e081f1c6eadbdb431 (patch) | |
tree | cf5e1d25f3725ff30a0acfaa10dff129695dac87 /src/core/jobs | |
parent | f9920b285767bceb7b771df000742c277ac9da91 (diff) |
Add QCoreSettings class
Adds the ability to disable bounding volume updates from the core
aspect.
Change-Id: I6d8a4c6f8fd880c9fca015cd40eaf7316747a2c6
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/jobs')
-rw-r--r-- | src/core/jobs/calcboundingvolumejob.cpp | 28 | ||||
-rw-r--r-- | src/core/jobs/calcboundingvolumejob_p.h | 5 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/core/jobs/calcboundingvolumejob.cpp b/src/core/jobs/calcboundingvolumejob.cpp index daab9e35a..4e9339912 100644 --- a/src/core/jobs/calcboundingvolumejob.cpp +++ b/src/core/jobs/calcboundingvolumejob.cpp @@ -43,7 +43,9 @@ #include <Qt3DCore/qboundingvolume.h> #include <Qt3DCore/qbuffer.h> #include <Qt3DCore/qgeometryview.h> +#include <Qt3DCore/qcoreaspect.h> #include <Qt3DCore/private/job_common_p.h> +#include <Qt3DCore/private/qcoreaspect_p.h> #include <Qt3DCore/private/qaspectjob_p.h> #include <Qt3DCore/private/qaspectmanager_p.h> #include <Qt3DCore/private/qattribute_p.h> @@ -203,15 +205,39 @@ BoundingVolumeComputeResult BoundingVolumeComputeData::compute() const } -CalculateBoundingVolumeJob::CalculateBoundingVolumeJob() +CalculateBoundingVolumeJob::CalculateBoundingVolumeJob(QCoreAspect *aspect) : Qt3DCore::QAspectJob() + , m_aspect(aspect) , m_root(nullptr) { SET_JOB_RUN_STAT_TYPE(this, JobTypes::CalcBoundingVolume, 0) } +bool CalculateBoundingVolumeJob::isRequired() +{ + if (!m_aspect) + return true; + + auto daspect = QCoreAspectPrivate::get(m_aspect); + return daspect->m_boundingVolumesEnabled; +} + void CalculateBoundingVolumeJob::run() { + // There's 2 bounding volume jobs, one here in Core, the other in Render. + // - This one computes bounding volumes for entities that have QBoundingVolume + // components and use QGeometryViews. + // In that case the component is updated directly by this job (since core + // aspect does not maintain backend objects for the component) + // - The one in render does 2 things: + // . Copy the results of this job to the backend object for entities that + // use QBoundingVolume and QGeometryView (computed results arrive one + // frame later, explicit results arrive on time) + // . Compute the BV for old style QGeometryRenderer which use a QGeometry + // directly without a QGeometryView + // + // (see more details in Qt3DRender::CalculateBoundingVolumeJob::run) + m_results.clear(); QHash<QEntity *, BoundingVolumeComputeData> dirtyEntities; diff --git a/src/core/jobs/calcboundingvolumejob_p.h b/src/core/jobs/calcboundingvolumejob_p.h index 95213df75..b245308ae 100644 --- a/src/core/jobs/calcboundingvolumejob_p.h +++ b/src/core/jobs/calcboundingvolumejob_p.h @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE namespace Qt3DCore { +class QCoreAspect; class CalculateBoundingVolumeJobPrivate; class QEntity; class QAttribute; @@ -96,14 +97,16 @@ struct Q_3DCORE_PRIVATE_EXPORT BoundingVolumeComputeData { class Q_3DCORE_PRIVATE_EXPORT CalculateBoundingVolumeJob : public Qt3DCore::QAspectJob { public: - explicit CalculateBoundingVolumeJob(); + explicit CalculateBoundingVolumeJob(QCoreAspect *aspect); void setRoot(QEntity *root) { m_root = root; } + bool isRequired() override; void run() override; void postFrame(QAspectEngine *aspectEngine) override; private: Q_DECLARE_PRIVATE(CalculateBoundingVolumeJob) + QCoreAspect *m_aspect; QEntity *m_root; std::vector<BoundingVolumeComputeResult> m_results; }; |