summaryrefslogtreecommitdiffhomepage
path: root/src/point.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-10-08 22:48:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-10-08 22:48:40 +0200
commit648f26a2fc82c4a618d68733f9f3ad6915bae37d (patch)
tree493ada6f6e365d811b66625f62527b0a035305f1 /src/point.hpp
parent864c976daa4ddc7df09271b7049ca7c18e5601dd (diff)
a
Diffstat (limited to 'src/point.hpp')
-rw-r--r--src/point.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/point.hpp b/src/point.hpp
new file mode 100644
index 00000000..99c4acdf
--- /dev/null
+++ b/src/point.hpp
@@ -0,0 +1,42 @@
+#pragma once
+#include "global-coords.hpp"
+#include <compare>
+
+namespace floormat {
+
+// todo pack this within 8 bytes
+struct point
+{
+ global_coords coord;
+ Vector2b offset;
+
+ constexpr bool operator==(const point&) const = default;
+ friend constexpr std::strong_ordering operator<=>(const point& a, const point& b) noexcept;
+};
+
+constexpr std::strong_ordering operator<=>(const point& p1, const point& p2) noexcept
+{
+ auto c1 = p1.coord.to_signed3(), c2 = p2.coord.to_signed3();
+
+ if (auto val = c1.z() <=> c2.z(); val != std::strong_ordering::equal)
+ return val;
+ if (auto val = c1.y() <=> c2.y(); val != std::strong_ordering::equal)
+ return val;
+ if (auto val = c1.x() <=> c2.x(); val != std::strong_ordering::equal)
+ return val;
+ if (auto val = p1.offset.y() <=> p2.offset.y(); val != std::strong_ordering::equal)
+ return val;
+ if (auto val = p1.offset.x() <=> p2.offset.x(); val != std::strong_ordering::equal)
+ return val;
+
+ return std::strong_ordering::equal;
+}
+
+struct packed_point
+{
+ uint64_t cx : 12, cy : 12, cz : 4,
+ tx : 8, ty : 8,
+ ox : 4, oy : 4;
+};
+
+} // namespace floormat