/
SceneSelectionTesters.h
114 lines (91 loc) · 3.11 KB
/
SceneSelectionTesters.h
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#pragma once
#include <vector>
#include "iselectiontest.h"
namespace selection
{
class SelectionTestWalker;
/**
* Filter function used when traversing the scene,
* allowing to globally filter out nodes from the set of candidates.
*/
using NodePredicate = std::function<bool(const scene::INodePtr&)>;
class SelectionTesterBase :
public ISceneSelectionTester
{
private:
std::vector<ISelectable*> _selectables;
NodePredicate _nodePredicate;
protected:
SelectionTesterBase(const NodePredicate& nodePredicate);
public:
bool hasSelectables() const override;
void foreachSelectable(const std::function<void(ISelectable*)>& functor) override;
void testSelectScene(const VolumeTest& view, SelectionTest& test) override;
protected:
// Test the given node using the given tester. The node will be forwarded to the
// tester only if it passed the predicate passed to the constructor
void testNode(const scene::INodePtr& node, SelectionTestWalker& tester);
bool nodeIsEligible(const scene::INodePtr& node) const;
void storeSelectablesInPool(Selector& selector, const std::function<bool(ISelectable*)>& predicate);
void storeSelectable(ISelectable* selectable);
};
/**
* Tests entities and worldspawn primitives in the scene
*/
class PrimitiveSelectionTester :
public SelectionTesterBase
{
public:
PrimitiveSelectionTester(const NodePredicate& nodePredicate);
void testSelectSceneWithFilter(const VolumeTest& view, SelectionTest& test,
const std::function<bool(ISelectable*)>& predicate) override;
private:
bool higherEntitySelectionPriority() const;
};
/**
* Tests just the entities in the scene, all other nodes are skipped
*/
class EntitySelectionTester :
public SelectionTesterBase
{
public:
EntitySelectionTester(const NodePredicate& nodePredicate);
void testSelectSceneWithFilter(const VolumeTest& view, SelectionTest& test,
const std::function<bool(ISelectable*)>& predicate) override;
};
/**
* Tests child primitives of group nodes only, non-worldspawn
*/
class GroupChildPrimitiveSelectionTester :
public SelectionTesterBase
{
public:
GroupChildPrimitiveSelectionTester(const NodePredicate& nodePredicate);
void testSelectSceneWithFilter(const VolumeTest& view, SelectionTest& test,
const std::function<bool(ISelectable*)>& predicate) override;
};
/**
* This tester is looking for merge action nodes only
*/
class MergeActionSelectionTester :
public SelectionTesterBase
{
public:
MergeActionSelectionTester(const NodePredicate& nodePredicate);
void testSelectSceneWithFilter(const VolumeTest& view, SelectionTest& test,
const std::function<bool(ISelectable*)>& predicate) override;
};
/**
* Tests components of selected scene elements
*/
class ComponentSelectionTester :
public SelectionTesterBase
{
private:
SelectionSystem& _selectionSystem;
public:
ComponentSelectionTester(SelectionSystem& selectionSystem, const NodePredicate& nodePredicate);
void testSelectSceneWithFilter(const VolumeTest& view, SelectionTest& test,
const std::function<bool(ISelectable*)>& predicate) override;
};
}