diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-07 21:11:34 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-07 21:11:34 +0200 |
commit | 4e36541f57c872c0f1308e559e5bddf367124aba (patch) | |
tree | 0e1c72ce5c4b15e9b80a033d122b17710c88f102 /src/global-coords.hpp | |
parent | b9c715abb0ae43f58e5d03333d8858e6ab4904f2 (diff) |
src: set global_coords data members as private
Diffstat (limited to 'src/global-coords.hpp')
-rw-r--r-- | src/global-coords.hpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/global-coords.hpp b/src/global-coords.hpp index 9df9e5de..4d420534 100644 --- a/src/global-coords.hpp +++ b/src/global-coords.hpp @@ -66,13 +66,19 @@ struct chunk_coords_ final { constexpr inline int8_t chunk_z_min = -1, chunk_z_max = 14; -struct global_coords final { +struct global_coords final +{ + struct raw_coords final { uint32_t &x, &y; }; // NOLINT + struct raw_coords_ final { uint32_t x, y; }; + +private: using u0 = std::integral_constant<uint32_t, (1<<15)>; using s0 = std::integral_constant<int32_t, int32_t(u0::value)>; using z0 = std::integral_constant<int32_t, (1 << 0)>; using z_mask = std::integral_constant<uint32_t, (1u << 4) - 1u << 20>; uint32_t x = u0::value<<4|z0::value<<20, y = u0::value<<4; +public: constexpr global_coords() noexcept = default; constexpr global_coords(chunk_coords c, local_coords xy, int8_t z) noexcept : x{ @@ -94,6 +100,8 @@ struct global_coords final { constexpr local_coords local() const noexcept; constexpr chunk_coords chunk() const noexcept; constexpr operator chunk_coords_() const noexcept; + constexpr raw_coords_ raw() const noexcept; + constexpr raw_coords raw() noexcept; constexpr int8_t z() const noexcept; constexpr Vector2i to_signed() const noexcept; @@ -122,6 +130,9 @@ constexpr global_coords::operator chunk_coords_() const noexcept return chunk_coords_{ chunk(), z() }; } +constexpr auto global_coords::raw() const noexcept -> raw_coords_ { return {x, y}; } +constexpr auto global_coords::raw() noexcept -> raw_coords { return {x, y}; } + constexpr int8_t global_coords::z() const noexcept { return ((x >> 20) & 0x0f) - z0::value; |