/
SceneSelectionTesters.cpp
94 lines (77 loc) · 3.09 KB
/
SceneSelectionTesters.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "SceneSelectionTesters.h"
#include "iscenegraph.h"
#include "registry/registry.h"
#include "SelectionTestWalkers.h"
#include "selection/SelectionPool.h"
namespace selection
{
void PrimitiveSelectionTester::testSelectScene(const VolumeTest& view, SelectionTest& test, Selector& selector)
{
// Cameras don't sort entities higher
if (view.fill() || !higherEntitySelectionPriority())
{
// Test for any visible elements (primitives, entities), but don't select child primitives
AnySelector anyTester(selector, test);
GlobalSceneGraph().foreachVisibleNodeInVolume(view, anyTester);
return;
}
// We have an orthoview, select entities first
SelectionPool entityPool;
SelectionPool primitivePool;
// First, obtain all the selectable entities
EntitySelector entityTester(entityPool, test);
GlobalSceneGraph().foreachVisibleNodeInVolume(view, entityTester);
// Now retrieve all the selectable primitives
PrimitiveSelector primitiveTester(primitivePool, test);
GlobalSceneGraph().foreachVisibleNodeInVolume(view, primitiveTester);
// Transfer the items of both pools to the target selector, entities first
for (const auto& [intersection, selectable] : entityPool)
{
selector.pushSelectable(*selectable);
selector.addIntersection(intersection);
selector.popSelectable();
}
for (const auto& [intersection, selectable] : primitivePool)
{
// Check for duplicates
SelectionPool::const_iterator existing;
for (existing = entityPool.begin(); existing != entityPool.end(); ++existing)
{
if (existing->second == selectable) break;
}
if (existing == entityPool.end())
{
selector.pushSelectable(*selectable);
selector.addIntersection(intersection);
selector.popSelectable();
}
}
}
bool PrimitiveSelectionTester::higherEntitySelectionPriority() const
{
return registry::getValue<bool>(RKEY_HIGHER_ENTITY_PRIORITY);
}
void EntitySelectionTester::testSelectScene(const VolumeTest& view, SelectionTest& test, Selector& selector)
{
EntitySelector tester(selector, test);
GlobalSceneGraph().foreachVisibleNodeInVolume(view, tester);
}
void GroupChildPrimitiveSelectionTester::testSelectScene(const VolumeTest& view, SelectionTest& test, Selector& selector)
{
GroupChildPrimitiveSelector tester(selector, test);
GlobalSceneGraph().foreachVisibleNodeInVolume(view, tester);
}
void MergeActionSelectionTester::testSelectScene(const VolumeTest& view, SelectionTest& test, Selector& selector)
{
MergeActionSelector tester(selector, test);
GlobalSceneGraph().foreachVisibleNodeInVolume(view, tester);
}
ComponentSelectionTester::ComponentSelectionTester(SelectionSystem& selectionSystem) :
_selectionSystem(selectionSystem)
{}
void ComponentSelectionTester::testSelectScene(const VolumeTest& view, SelectionTest& test, Selector& selector)
{
ComponentSelector selectionTester(selector, test, _selectionSystem.ComponentMode());
_selectionSystem.foreachSelected(selectionTester);
}
}