]> git.localhorst.tv Git - blank.git/blobdiff - src/geometry.hpp
basic aiming
[blank.git] / src / geometry.hpp
diff --git a/src/geometry.hpp b/src/geometry.hpp
new file mode 100644 (file)
index 0000000..e8ead98
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef BLANK_GEOMETRY_H_
+#define BLANK_GEOMETRY_H_
+
+#include <algorithm>
+#include <glm/glm.hpp>
+
+
+namespace blank {
+
+struct AABB {
+       glm::vec3 min;
+       glm::vec3 max;
+
+       void Adjust() {
+               if (max.x < min.x) std::swap(max.x, min.x);
+               if (max.y < min.y) std::swap(max.y, min.y);
+               if (max.z < min.z) std::swap(max.z, min.z);
+       }
+};
+
+struct Ray {
+       glm::vec3 orig;
+       glm::vec3 dir;
+};
+
+bool Intersection(const Ray &, const AABB &, const glm::mat4 &M, float *dist = nullptr);
+
+}
+
+#endif