forked from microsoft/glTF-DXViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneManager.cpp
More file actions
60 lines (50 loc) · 1.17 KB
/
SceneManager.cpp
File metadata and controls
60 lines (50 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "pch.h"
#include "SceneManager.h"
using namespace std;
SceneManager::SceneManager()
{
_sceneNode = make_shared<RootNode>(-1);
}
shared_ptr<RootNode> SceneManager::Current()
{
return _sceneNode;
}
const shared_ptr<RootNode> SceneManager::Current() const
{
return _sceneNode;
}
void SceneManager::AddNode(shared_ptr<GraphNode> newNode)
{
Current()->AddChild(newNode);
SceneChanged.notify(*this);
}
void SceneManager::SetDevResources(const shared_ptr<DX::DeviceResources>& deviceResources)
{
_deviceResources = deviceResources;
}
void SceneManager::SetSelected(shared_ptr<GraphNode> node)
{
// De-select all other nodes in the scene..
_sceneNode->ForAllChildrenRecursive([](GraphNode& nd)
{
nd.SetSelected(false);
});
// Finally, set our node selected.
node->SetSelected(true);
SelectionChanged.notify(node);
}
shared_ptr<GraphNode> SceneManager::GetSelected()
{
// Loop through the scene to find the one and only selected node (only supporting
// single-selection for now)
shared_ptr<GraphNode> result;
_sceneNode->ForAllChildrenRecursiveUntil([&result](GraphNode& nd)
{
if (nd.IsSelected())
{
result.reset(&nd);
}
return true;
});
return result;
}