]> git.localhorst.tv Git - blank.git/blob - src/geometry.hpp
move controller from camera to world
[blank.git] / src / geometry.hpp
1 #ifndef BLANK_GEOMETRY_H_
2 #define BLANK_GEOMETRY_H_
3
4 #include <algorithm>
5 #include <glm/glm.hpp>
6
7
8 namespace blank {
9
10 constexpr float PI = 3.141592653589793238462643383279502884;
11
12 struct AABB {
13         glm::vec3 min;
14         glm::vec3 max;
15
16         void Adjust() {
17                 if (max.x < min.x) std::swap(max.x, min.x);
18                 if (max.y < min.y) std::swap(max.y, min.y);
19                 if (max.z < min.z) std::swap(max.z, min.z);
20         }
21 };
22
23 struct Ray {
24         glm::vec3 orig;
25         glm::vec3 dir;
26 };
27
28 bool Intersection(
29         const Ray &,
30         const AABB &,
31         const glm::mat4 &M,
32         float *dist = nullptr,
33         glm::vec3 *normal = nullptr);
34
35 }
36
37 #endif