From 1e1713198459bd1e80d828f894f96c27d5189beb Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Sun, 27 Nov 2022 15:42:20 +0000 Subject: [PATCH] add comparison and startship operators to hexagon --- include/fggl/grid/hexagon.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/fggl/grid/hexagon.hpp b/include/fggl/grid/hexagon.hpp index be21107..955961e 100644 --- a/include/fggl/grid/hexagon.hpp +++ b/include/fggl/grid/hexagon.hpp @@ -22,6 +22,7 @@ #include <array> #include <vector> #include <cmath> +#include <compare> #include <fggl/math/fmath.hpp> @@ -83,6 +84,12 @@ namespace fggl::grid { return { m_pos[0] - other.m_pos[0], m_pos[1] - other.m_pos[1] }; } + bool operator==(const HexPointT<T>& other) const { + return m_pos[0] == other.m_pos[0] && m_pos[1] == m_pos[1]; + } + + auto operator<=>(const HexPointT<T>& other) const = default; + T distance(const HexPointT& other) const { auto vec = *this - other; return ( -- GitLab