diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-01 23:02:59 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-09-01 23:02:59 +0200 |
commit | 8b44178ab0ce155db89ff9ef93dc02944149414e (patch) | |
tree | 6a009d9e040868f2631884ead9fc02099bcb0632 | |
parent | d90c38ce59d406cdfd4303c836ee524a71ad0979 (diff) |
src: convert global_coords to chunk_coords_
-rw-r--r-- | src/global-coords.hpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/global-coords.hpp b/src/global-coords.hpp index d1fd2b8d..3ed4a855 100644 --- a/src/global-coords.hpp +++ b/src/global-coords.hpp @@ -90,6 +90,7 @@ struct global_coords final { constexpr local_coords local() const noexcept; constexpr chunk_coords chunk() const noexcept; + constexpr operator chunk_coords_() const noexcept; constexpr int8_t z() const noexcept; constexpr Vector2i to_signed() const noexcept; @@ -113,6 +114,11 @@ constexpr chunk_coords global_coords::chunk() const noexcept return { int16_t(int32_t(((x & ~z_mask::value)>>4) - u0::value)), int16_t(int32_t((y>>4) - u0::value)), }; } +constexpr global_coords::operator chunk_coords_() const noexcept +{ + return chunk_coords_{ chunk(), z() }; +} + constexpr int8_t global_coords::z() const noexcept { return ((x >> 20) & 0x0f) - z0::value; |