diff options
-rw-r--r-- | editor/editor.cpp | 4 | ||||
-rw-r--r-- | main/draw.cpp | 2 | ||||
-rw-r--r-- | src/global-coords.cpp | 6 | ||||
-rw-r--r-- | src/global-coords.hpp | 9 |
4 files changed, 10 insertions, 11 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index f09030dc..2d52d715 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -70,10 +70,10 @@ void editor::on_mouse_move(world& world, global_coords& pos, int mods) const auto [miny, maxy] = std::minmax(draw_coord.y, last.draw_coord.y); if (draw_offset[0]) for (uint32_t i = minx; i <= maxx; i++) - on_click_(world, { i, draw_coord.y }, last.btn); + on_click_(world, { i, draw_coord.y, nullptr }, last.btn); else for (uint32_t j = miny; j <= maxy; j++) - on_click_(world, { draw_coord.x, j }, last.btn); + on_click_(world, { draw_coord.x, j, nullptr }, last.btn); } else on_click_(world, draw_coord, last.btn); diff --git a/main/draw.cpp b/main/draw.cpp index 44785f61..9adb38a2 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -66,7 +66,7 @@ global_coords main_impl::pixel_to_tile(Vector2d position) const noexcept { auto vec = pixel_to_tile_(position); const auto x = (int32_t)std::floor(vec[0]), y = (int32_t)std::floor(vec[1]); - return { x, y }; + return { x, y, 0 }; } Vector2d main_impl::pixel_to_tile_(Vector2d position) const noexcept diff --git a/src/global-coords.cpp b/src/global-coords.cpp index 7df70fe0..87a2c79c 100644 --- a/src/global-coords.cpp +++ b/src/global-coords.cpp @@ -11,9 +11,9 @@ static_assert(std::is_same_v<decltype(chunk_coords::x), decltype(chunk_coords::y static_assert(TILE_MAX_DIM == (1 << 4)); -static_assert(global_coords{(int)TILE_MAX_DIM-1, (int)TILE_MAX_DIM-1}.chunk() == global_coords{}.chunk()); -static_assert(global_coords{(int)TILE_MAX_DIM-1, (int)TILE_MAX_DIM}.chunk() != global_coords{}.chunk()); -static_assert(global_coords{(1u + (1<<15)) << 4 | 3, (2u + (1<<15)) << 4 | 4} == global_coords{{1, 2}, {3, 4}, -8}); +static_assert(global_coords{(int)TILE_MAX_DIM-1, (int)TILE_MAX_DIM-1, 0}.chunk() == global_coords{}.chunk()); +static_assert(global_coords{(int)TILE_MAX_DIM-1, (int)TILE_MAX_DIM, 0}.chunk() == chunk_coords{0, 1}); +static_assert(global_coords{(1u + (1<<15)) << 4 | 3, (2u + (1<<15)) << 4 | 4, nullptr} == global_coords{{1, 2}, {3, 4}, -8}); static_assert(global_coords{-123, 456, 1}.z() == 1); static_assert(global_coords{-123, 511, 5}.chunk() == chunk_coords{-8, 31}); diff --git a/src/global-coords.hpp b/src/global-coords.hpp index 3e9ac983..1bf79e4a 100644 --- a/src/global-coords.hpp +++ b/src/global-coords.hpp @@ -31,7 +31,6 @@ struct chunk_coords_ final { int16_t x = 0, y = 0; int8_t z = 0; - explicit constexpr operator chunk_coords() const noexcept { return {x, y}; } constexpr chunk_coords_() noexcept = default; constexpr chunk_coords_(int16_t x, int16_t y, int8_t z) noexcept : x{x}, y{y}, z{z} {} constexpr chunk_coords_(chunk_coords c, int8_t z) noexcept : x{c.x}, y{c.y}, z{z} {} @@ -55,8 +54,8 @@ struct global_coords final { }, y{ uint32_t((c.y + s0::value) << 4) | (xy.y & 0x0f) } {} - constexpr global_coords(uint32_t x, uint32_t y) noexcept : x{x}, y{y} {} - constexpr global_coords(int32_t x, int32_t y, int8_t z = 0) noexcept : + constexpr global_coords(uint32_t x, uint32_t y, std::nullptr_t) noexcept : x{x}, y{y} {} + constexpr global_coords(int32_t x, int32_t y, int8_t z) noexcept : x{uint32_t(x + (s0::value<<4)) | uint32_t(((z + z0::value) & 0x0f) << 20)}, y{uint32_t(y + (s0::value<<4))} {} @@ -106,7 +105,7 @@ constexpr Vector3i global_coords::to_signed3() const noexcept constexpr global_coords global_coords::operator+(Vector2i vec) const noexcept { - return { uint32_t((int64_t)x+vec[0]), uint32_t((int64_t)y+vec[1]) }; + return { uint32_t((int64_t)x+vec[0]), uint32_t((int64_t)y+vec[1]), nullptr }; } constexpr global_coords& global_coords::operator+=(Vector2i vec) noexcept @@ -118,7 +117,7 @@ constexpr global_coords& global_coords::operator+=(Vector2i vec) noexcept constexpr global_coords global_coords::operator-(Vector2i vec) const noexcept { - return { uint32_t((int64_t)x-vec[0]), uint32_t((int64_t)y-vec[1]) }; + return { uint32_t((int64_t)x-vec[0]), uint32_t((int64_t)y-vec[1]), nullptr }; } constexpr global_coords& global_coords::operator-=(Vector2i vec) noexcept |