-
Notifications
You must be signed in to change notification settings - Fork 47
/
SelectableComponents.h
90 lines (74 loc) · 1.71 KB
/
SelectableComponents.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
#ifndef SELECTABLECOMPONENTS_H_
#define SELECTABLECOMPONENTS_H_
#include "Winding.h"
#include "Face.h"
class FaceVertexId {
std::size_t m_face;
std::size_t m_vertex;
public:
FaceVertexId(std::size_t face, std::size_t vertex)
: m_face(face), m_vertex(vertex)
{}
std::size_t getFace() const {
return m_face;
}
std::size_t getVertex() const {
return m_vertex;
}
};
class SelectableEdge
{
Vector3 getEdge() const
{
const Winding& winding = getFace().getWinding();
return winding[m_faceVertex.getVertex()].vertex.mid(winding[winding.next(m_faceVertex.getVertex())].vertex);
}
public:
Faces& m_faces;
FaceVertexId m_faceVertex;
SelectableEdge(Faces& faces, FaceVertexId faceVertex)
: m_faces(faces), m_faceVertex(faceVertex)
{
}
SelectableEdge& operator=(const SelectableEdge& other)
{
m_faceVertex = other.m_faceVertex;
return *this;
}
Face& getFace() const
{
return *m_faces[m_faceVertex.getFace()];
}
void testSelect(SelectionTest& test, SelectionIntersection& best)
{
test.TestPoint(getEdge(), best);
}
};
class SelectableVertex
{
Vector3 getVertex() const
{
return getFace().getWinding()[m_faceVertex.getVertex()].vertex;
}
public:
Faces& m_faces;
FaceVertexId m_faceVertex;
SelectableVertex(Faces& faces, FaceVertexId faceVertex)
: m_faces(faces), m_faceVertex(faceVertex)
{
}
SelectableVertex& operator=(const SelectableVertex& other)
{
m_faceVertex = other.m_faceVertex;
return *this;
}
Face& getFace() const
{
return *m_faces[m_faceVertex.getFace()];
}
void testSelect(SelectionTest& test, SelectionIntersection& best)
{
test.TestPoint(getVertex(), best);
}
};
#endif /*SELECTABLECOMPONENTS_H_*/