1// Copyright (C) 2016 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 "managers_p.h"
5
6#include <Qt3DRender/private/framegraphnode_p.h>
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DRender {
11namespace Render {
12
13FrameGraphManager::~FrameGraphManager()
14{
15 qDeleteAll(c: m_nodes);
16}
17
18bool FrameGraphManager::containsNode(Qt3DCore::QNodeId id) const
19{
20 return m_nodes.contains(key: id);
21}
22
23void FrameGraphManager::appendNode(Qt3DCore::QNodeId id, FrameGraphNode *node)
24{
25 m_nodes.insert(key: id, value: node);
26}
27
28FrameGraphNode* FrameGraphManager::lookupNode(Qt3DCore::QNodeId id) const
29{
30 const QHash<Qt3DCore::QNodeId, FrameGraphNode*>::const_iterator it = m_nodes.find(key: id);
31 if (it == m_nodes.end())
32 return nullptr;
33 else
34 return *it;
35}
36
37void FrameGraphManager::releaseNode(Qt3DCore::QNodeId id)
38{
39 auto node = m_nodes.take(key: id);
40 if (node) {
41 node->cleanup();
42 delete node;
43 }
44}
45
46void SkeletonManager::addDirtySkeleton(DirtyFlag dirtyFlag, HSkeleton skeletonHandle)
47{
48 switch (dirtyFlag) {
49 case SkeletonDataDirty:
50 m_dirtyDataSkeletons.push_back(t: skeletonHandle);
51 break;
52
53 case SkeletonTransformsDirty:
54 m_dirtyTransformSkeletons.push_back(t: skeletonHandle);
55 break;
56 }
57}
58
59QList<HSkeleton> SkeletonManager::takeDirtySkeletons(DirtyFlag dirtyFlag)
60{
61 switch (dirtyFlag) {
62 case SkeletonDataDirty:
63 return Qt3DCore::moveAndClear(data&: m_dirtyDataSkeletons);
64
65 case SkeletonTransformsDirty:
66 return Qt3DCore::moveAndClear(data&: m_dirtyTransformSkeletons);
67 }
68 return { };
69}
70
71void JointManager::addDirtyJoint(Qt3DCore::QNodeId jointId)
72{
73 const HJoint jointHandle = lookupHandle(id: jointId);
74 m_dirtyJoints.push_back(t: jointHandle);
75}
76
77void JointManager::removeDirtyJoint(Qt3DCore::QNodeId jointId)
78{
79 const HJoint jointHandle = lookupHandle(id: jointId);
80 m_dirtyJoints.removeAll(t: jointHandle);
81}
82
83QList<HJoint> JointManager::dirtyJoints()
84{
85 return Qt3DCore::moveAndClear(data&: m_dirtyJoints);
86}
87
88} // namespace Render
89} // namespace Qt3DRender
90
91QT_END_NAMESPACE
92

source code of qt3d/src/render/backend/managers.cpp