-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscenenode.cpp
74 lines (53 loc) · 1.25 KB
/
scenenode.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* START OF 'scenenode.cpp' FILE */
#include "nodevisitor.h"
#include "scenenode.h"
#include "transformnode.h"
// Visitor that collects parent's paths
class COLLECT_PARENT_PATHS : public NODE_VISITOR {
public:
COLLECT_PARENT_PATHS (const SCENE_NODE * stopNode = NULL) :
stopNode(stopNode)
{
}
void Apply (SCENE_NODE & node)
{
if (node.GetNumParents() == 0 || &node == stopNode) {
nodePathList.push_back(GetNodePath());
} else {
NODE_VISITOR::Apply(node);
}
}
public:
const SCENE_NODE * stopNode;
NODE_PATH nodePath;
NODE_PATH_LIST nodePathList;
};
SCENE_NODE::SCENE_NODE (void)
{
}
void SCENE_NODE::Accept (NODE_VISITOR & nv)
{
nv.nodePath.push_back(this);
nv.Apply(*this);
nv.nodePath.pop_back();
}
void SCENE_NODE::Ascend (NODE_VISITOR & nv)
{
for (auto it : parents) {
it->Accept(nv);
}
}
NODE_PATH_LIST SCENE_NODE::GetParentalNodePaths (SCENE_NODE * stopNode) const
{
COLLECT_PARENT_PATHS cpp(stopNode);
const_cast<SCENE_NODE *>(this)->SCENE_NODE::Accept(cpp);
return cpp.nodePathList;
}
void SCENE_NODE::AddParent (TRANSFORM_NODE * parent)
{
parents.push_back(parent);
}
SCENE_NODE::~SCENE_NODE (void)
{
}
/* END OF 'scenenode.cpp' FILE */