1// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "updatetreeenabledjob_p.h"
5
6#include <Qt3DRender/private/entity_p.h>
7#include <Qt3DRender/private/job_common_p.h>
8#include <Qt3DRender/private/managers_p.h>
9#include <Qt3DRender/private/nodemanagers_p.h>
10
11#include <QThread>
12
13QT_BEGIN_NAMESPACE
14
15namespace Qt3DRender {
16namespace Render {
17
18namespace {
19
20void updateTreeEnabled(NodeManagers *manager, Entity *node, bool parentEnabled)
21{
22 const bool treeEnabled = node->isEnabled() && parentEnabled;
23 node->setTreeEnabled(treeEnabled);
24
25 const auto &childrenHandles = node->childrenHandles();
26 for (const HEntity &handle : childrenHandles) {
27 Entity *child = manager->renderNodesManager()->data(handle);
28 if (child)
29 updateTreeEnabled(manager, node: child, parentEnabled: treeEnabled);
30 }
31}
32
33}
34
35UpdateTreeEnabledJob::UpdateTreeEnabledJob()
36 : Qt3DCore::QAspectJob()
37 , m_node(nullptr)
38 , m_manager(nullptr)
39{
40 SET_JOB_RUN_STAT_TYPE(this, JobTypes::UpdateTreeEnabled, 0)
41}
42
43void UpdateTreeEnabledJob::setRoot(Entity *root)
44{
45 m_node = root;
46}
47
48void UpdateTreeEnabledJob::setManagers(NodeManagers *manager)
49{
50 m_manager = manager;
51}
52
53void UpdateTreeEnabledJob::run()
54{
55 if (m_node && m_manager)
56 updateTreeEnabled(manager: m_manager, node: m_node, parentEnabled: true);
57}
58
59} // namespace Render
60} // namespace Qt3DRender
61
62QT_END_NAMESPACE
63

source code of qt3d/src/render/jobs/updatetreeenabledjob.cpp