]> git.tdb.fi Git - libs/gl.git/blob - source/core/clipplane.cpp
Rearrange soucre files into subdirectories
[libs/gl.git] / source / core / clipplane.cpp
1 #include <msp/strings/format.h>
2 #include "clipplane.h"
3 #include "gl.h"
4 #include "matrix.h"
5 #include "misc.h"
6 #include "programdata.h"
7
8 namespace Msp {
9 namespace GL {
10
11 ClipPlane::ClipPlane():
12         eq(0, 0, 0, 1)
13 { }
14
15 ClipPlane::ClipPlane(const Vector4 &e):
16         eq(e)
17 { }
18
19 ClipPlane::ClipPlane(const Vector3 &p, const Vector3 &d):
20         eq(compose(d, -dot(p, d)))
21 { }
22
23 void ClipPlane::set_equation(const Vector4 &e)
24 {
25         eq = e;
26 }
27
28 void ClipPlane::set_plane(const Vector3 &p, const Vector3 &d)
29 {
30         Vector3 nd = normalize(d);
31         set_equation(compose(nd, -dot(p, nd)));
32 }
33
34 void ClipPlane::update_shader_data(ProgramData &shdata, const Matrix &view_inverse, unsigned i) const
35 {
36         shdata.uniform(format("clip_planes[%d].equation", i), eq*view_inverse);
37 }
38
39 } // namespace GL
40 } // namespace Msp