-
Notifications
You must be signed in to change notification settings - Fork 47
/
FacePlane.cpp
54 lines (43 loc) · 1.16 KB
/
FacePlane.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
#include "FacePlane.h"
#include "math/Matrix4.h"
void FacePlane::reverse()
{
m_plane.reverse();
}
void FacePlane::translate(const Vector3& translation)
{
// Translate without touching the normal vector, preserving the required
// distance negation
m_plane.dist() = -m_plane.dist();
m_plane.translate(translation);
m_plane.dist() = -m_plane.dist();
}
void FacePlane::transform(const Matrix4& matrix)
{
// Prepare the plane to be transformed (negate the distance)
m_plane.dist() = -m_plane.dist();
// Transform the plane
m_plane.transform(matrix);
// Re-negate the distance
m_plane.dist() = -m_plane.dist();
// Now normalise the plane, otherwise the next transformation will screw up
m_plane.normalise();
}
void FacePlane::offset(float offset)
{
m_plane.dist() += offset;
}
void FacePlane::setPlane(const Plane3& plane)
{
m_plane = plane;
}
const Plane3& FacePlane::getPlane() const
{
return m_plane;
}
void FacePlane::initialiseFromPoints(const Vector3& p0,
const Vector3& p1,
const Vector3& p2)
{
m_plane = Plane3(p2, p1, p0);
}