diff options
-rw-r--r-- | src/point.cpp | 29 | ||||
-rw-r--r-- | src/point.inl | 1 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/point.cpp b/src/point.cpp index 3e970ba3..7b810fca 100644 --- a/src/point.cpp +++ b/src/point.cpp @@ -1,5 +1,6 @@ -#include "point.hpp" #include "compat/int-hash.hpp" +#include "point.inl" +#include "tile-constants.hpp" namespace floormat { @@ -35,4 +36,30 @@ Debug& operator<<(Debug& dbg, const point& pt) return dbg; } +namespace { + +constexpr auto chunk_size = iTILE_SIZE2 * TILE_MAX_DIM; + +static_assert(point::distance_l2( + point{{ 1, 2, 0}, {3, 4}, {32, 32}}, + point{{ 0, 0, 0}, {0, 0}, {32, 32}} +) == (uint32_t)Math::abs((Vector2i(1, 2)*chunk_size + Vector2i{3, 4} * iTILE_SIZE2 + Vector2i{0, 0}).sum())); + +static_assert(point::distance_l2( + point{{ 0, 0, 0}, {0, 0}, {30, 30}}, + point{{ 1, 2, 0}, {3, 4}, {31, 31}} +) == (uint32_t)Math::abs((Vector2i(1, 2)*chunk_size + Vector2i{3, 4} * iTILE_SIZE2 + Vector2i{1, 1}).sum())); + +static_assert(point::distance_l2( + point{{ 2, 3, 0}, {4, 5}, {32, 32}}, + point{{ 1, 2, 0}, {3, 4}, {31, 31}} +) == (uint32_t)Math::abs((Vector2i(1, 1)*chunk_size + Vector2i{1, 1} * iTILE_SIZE2 + Vector2i{1, 1}).sum())); + +static_assert(point::distance_l2( + point{{ 1, 2, 0}, {3, 4}, {31, 31}}, + point{{ 2, 3, 0}, {4, 5}, {32, 32}} +) == (uint32_t)Math::abs((Vector2i(1, 1)*chunk_size + Vector2i{1, 1} * iTILE_SIZE2 + Vector2i{1, 1}).sum())); + +} // namespace + } // namespace floormat diff --git a/src/point.inl b/src/point.inl index dbcfd124..4fd4bb07 100644 --- a/src/point.inl +++ b/src/point.inl @@ -1,4 +1,5 @@ #pragma once +#include "src/tile-constants.hpp" #include "point.hpp" #include <mg/Functions.h> |