]> git.localhorst.tv Git - blank.git/blob - src/geometry.hpp
place and remove blocks via mouse
[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 struct AABB {
11         glm::vec3 min;
12         glm::vec3 max;
13
14         void Adjust() {
15                 if (max.x < min.x) std::swap(max.x, min.x);
16                 if (max.y < min.y) std::swap(max.y, min.y);
17                 if (max.z < min.z) std::swap(max.z, min.z);
18         }
19 };
20
21 struct Ray {
22         glm::vec3 orig;
23         glm::vec3 dir;
24 };
25
26 bool Intersection(
27         const Ray &,
28         const AABB &,
29         const glm::mat4 &M,
30         float *dist = nullptr,
31         glm::vec3 *normal = nullptr);
32
33 }
34
35 #endif