diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/global-coords.hpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/global-coords.hpp b/src/global-coords.hpp index 9c2d082b..709b2a3a 100644 --- a/src/global-coords.hpp +++ b/src/global-coords.hpp @@ -19,19 +19,18 @@ constexpr Vector2i chunk_coords::operator-(chunk_coords other) const noexcept } struct global_coords final { - static constexpr std::uint32_t _0u = 1 << 15; - static constexpr auto _0s = std::int32_t(_0u); - - std::uint32_t x = _0u<<4, y = _0u<<4; + using u0 = std::integral_constant<std::uint32_t, (1<<15)>; + using s0 = std::integral_constant<std::int32_t, std::int32_t(u0::value)>; + std::uint32_t x = u0::value<<4, y = u0::value<<4; constexpr global_coords() noexcept = default; constexpr global_coords(chunk_coords c, local_coords xy) : - x{ std::uint32_t((c.x + _0s) << 4) | (xy.x & 0x0f) }, - y{ std::uint32_t((c.y + _0s) << 4) | (xy.y & 0x0f) } + x{ std::uint32_t((c.x + s0::value) << 4) | (xy.x & 0x0f) }, + y{ std::uint32_t((c.y + s0::value) << 4) | (xy.y & 0x0f) } {} constexpr global_coords(std::uint32_t x, std::uint32_t y) noexcept : x{x}, y{y} {} constexpr global_coords(std::int32_t x, std::int32_t y) noexcept : - x{std::uint32_t(x + (_0s<<4))}, y{std::uint32_t(y + (_0s<<4))} + x{std::uint32_t(x + (s0::value<<4))}, y{std::uint32_t(y + (s0::value<<4))} {} constexpr local_coords local() const noexcept; @@ -54,12 +53,12 @@ constexpr local_coords global_coords::local() const noexcept constexpr chunk_coords global_coords::chunk() const noexcept { - return { std::int16_t(std::int32_t((x>>4) - _0u)), std::int16_t(std::int32_t((y>>4) - _0u)), }; + return { std::int16_t(std::int32_t((x>>4) - u0::value)), std::int16_t(std::int32_t((y>>4) - u0::value)), }; } constexpr Vector2i global_coords::to_signed() const noexcept { - return { std::int32_t(x - (_0s<<4)), std::int32_t(y - (_0s<<4)), }; + return { std::int32_t(x - (s0::value<<4)), std::int32_t(y - (s0::value<<4)), }; } constexpr global_coords global_coords::operator+(Vector2i vec) const noexcept |