summaryrefslogtreecommitdiffhomepage
path: root/src/rect-intersects.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rect-intersects.hpp')
-rw-r--r--src/rect-intersects.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rect-intersects.hpp b/src/rect-intersects.hpp
new file mode 100644
index 00000000..25d838d6
--- /dev/null
+++ b/src/rect-intersects.hpp
@@ -0,0 +1,14 @@
+#pragma once
+#include <mg/Vector.h>
+
+namespace floormat {
+
+template<typename T>
+requires (std::is_same_v<Int, T> || std::is_same_v<float, T>)
+constexpr bool rect_intersects(Math::Vector<2, T> min1, Math::Vector<2, T> max1, Math::Vector<2, T> min2, Math::Vector<2, T> max2)
+{
+ return min1.data()[0] < max2.data()[0] && max1.data()[0] > min2.data()[0] &&
+ min1.data()[1] < max2.data()[1] && max1.data()[1] > min2.data()[1];
+}
+
+} // namespace floormat