summaryrefslogtreecommitdiffstats
path: root/src/render/jobs/calcboundingvolumejob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/jobs/calcboundingvolumejob.cpp')
-rw-r--r--src/render/jobs/calcboundingvolumejob.cpp73
1 files changed, 49 insertions, 24 deletions
diff --git a/src/render/jobs/calcboundingvolumejob.cpp b/src/render/jobs/calcboundingvolumejob.cpp
index 4fed1e9f0..b906bf9af 100644
--- a/src/render/jobs/calcboundingvolumejob.cpp
+++ b/src/render/jobs/calcboundingvolumejob.cpp
@@ -1,13 +1,12 @@
/****************************************************************************
**
** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2021 The Qt Company Ltd and/or its subsidiary(-ies).
+** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:COMM$
-**
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
@@ -16,25 +15,26 @@
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
-** $QT_END_LICENSE$
-**
-**
-**
-**
-**
-**
-**
-**
-**
-**
-**
-**
-**
-**
-**
-**
+** 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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -53,6 +53,7 @@
#include <Qt3DRender/private/buffervisitor_p.h>
#include <Qt3DRender/private/entityvisitor_p.h>
#include <Qt3DCore/private/qaspectmanager_p.h>
+#include <Qt3DRender/private/qgeometry_p.h>
#include <QtCore/qmath.h>
#if QT_CONFIG(concurrent)
@@ -399,8 +400,33 @@ public:
} // anonymous
+class CalculateBoundingVolumeJobPrivate : public Qt3DCore::QAspectJobPrivate
+{
+public:
+ CalculateBoundingVolumeJobPrivate(CalculateBoundingVolumeJob *q) : q_ptr(q) {}
+ ~CalculateBoundingVolumeJobPrivate() override = default;
+
+ void postFrame(Qt3DCore::QAspectManager *aspectManager) override
+ {
+ for (Geometry *backend : m_updatedGeometries) {
+ Qt3DRender::QGeometry *node = qobject_cast<Qt3DRender::QGeometry *>(aspectManager->lookupNode(backend->peerId()));
+ if (!node)
+ continue;
+ Qt3DRender::QGeometryPrivate *dNode = static_cast<Qt3DRender::QGeometryPrivate *>(Qt3DCore::QNodePrivate::get(node));
+ dNode->setExtent(backend->min(), backend->max());
+ }
+
+ m_updatedGeometries.clear();
+ }
+
+ QVector<Geometry *> m_updatedGeometries;
+ CalculateBoundingVolumeJob *q_ptr;
+ Q_DECLARE_PUBLIC(CalculateBoundingVolumeJob)
+};
+
CalculateBoundingVolumeJob::CalculateBoundingVolumeJob()
- : m_manager(nullptr)
+ : Qt3DCore::QAspectJob(*new CalculateBoundingVolumeJobPrivate(this))
+ , m_manager(nullptr)
, m_node(nullptr)
{
SET_JOB_RUN_STAT_TYPE(this, JobTypes::CalcBoundingVolume, 0)
@@ -429,9 +455,8 @@ void CalculateBoundingVolumeJob::run()
updatedGeometries += calculateLocalBoundingVolume(m_manager, data);
}
- // Send extent updates to frontend
- for (Geometry *geometry : updatedGeometries)
- geometry->notifyExtentChanged();
+ Q_D(CalculateBoundingVolumeJob);
+ d->m_updatedGeometries = std::move(updatedGeometries);
}
void CalculateBoundingVolumeJob::setRoot(Entity *node)