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 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DRender { |
11 | namespace Render { |
12 | |
13 | FrameGraphManager::~FrameGraphManager() |
14 | { |
15 | qDeleteAll(c: m_nodes); |
16 | } |
17 | |
18 | bool FrameGraphManager::containsNode(Qt3DCore::QNodeId id) const |
19 | { |
20 | return m_nodes.contains(key: id); |
21 | } |
22 | |
23 | void FrameGraphManager::appendNode(Qt3DCore::QNodeId id, FrameGraphNode *node) |
24 | { |
25 | m_nodes.insert(key: id, value: node); |
26 | } |
27 | |
28 | FrameGraphNode* 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 | |
37 | void 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 | |
46 | void 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 | |
59 | QList<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 | |
71 | void JointManager::addDirtyJoint(Qt3DCore::QNodeId jointId) |
72 | { |
73 | const HJoint jointHandle = lookupHandle(id: jointId); |
74 | m_dirtyJoints.push_back(t: jointHandle); |
75 | } |
76 | |
77 | void JointManager::removeDirtyJoint(Qt3DCore::QNodeId jointId) |
78 | { |
79 | const HJoint jointHandle = lookupHandle(id: jointId); |
80 | m_dirtyJoints.removeAll(t: jointHandle); |
81 | } |
82 | |
83 | QList<HJoint> JointManager::dirtyJoints() |
84 | { |
85 | return Qt3DCore::moveAndClear(data&: m_dirtyJoints); |
86 | } |
87 | |
88 | } // namespace Render |
89 | } // namespace Qt3DRender |
90 | |
91 | QT_END_NAMESPACE |
92 |