diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-07 22:00:01 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-07 22:00:01 +0200 |
commit | 766909047b6873b5af3f9aa98c6ed8cd53c6cc54 (patch) | |
tree | 3b32bc3035f14c2072fd687e2c9b18b7860c88e0 | |
parent | d19a44bcb53cebbee0ae51981f66b93b31cb9dcb (diff) |
a
-rw-r--r-- | anim-crop-tool/atlas.cpp | 7 | ||||
-rw-r--r-- | anim-crop-tool/main.cpp | 2 | ||||
-rw-r--r-- | compat/enum-bitset.hpp | 17 | ||||
-rw-r--r-- | main/main.cpp | 17 | ||||
-rw-r--r-- | serialize/anim.hpp | 5 | ||||
-rw-r--r-- | shaders/tile-shader.hpp | 6 | ||||
-rw-r--r-- | src/tile-iterator.hpp | 2 | ||||
-rw-r--r-- | src/tile.hpp | 2 | ||||
-rw-r--r-- | src/wall-mesh.hpp | 2 |
9 files changed, 31 insertions, 29 deletions
diff --git a/anim-crop-tool/atlas.cpp b/anim-crop-tool/atlas.cpp index 4b005d60..8ee52054 100644 --- a/anim-crop-tool/atlas.cpp +++ b/anim-crop-tool/atlas.cpp @@ -12,7 +12,7 @@ void anim_atlas_row::add_entry(const anim_atlas_entry& x) auto& frame = *x.frame; const auto& mat = x.mat; frame.offset = {xpos, ypos}; - frame.size = {mat.cols, mat.rows}; + frame.size = {(unsigned)mat.cols, (unsigned)mat.rows}; ASSERT(mat.rows > 0 && mat.cols > 0); data.push_back(x); @@ -54,8 +54,9 @@ bool anim_atlas::dump(const std::filesystem::path& filename) const for (const anim_atlas_row& row : rows) for (const anim_atlas_entry& x : row.data) { - auto offset = x.frame->offset, size = x.frame->size; - cv::Rect roi = {offset[0], offset[1], size[0], size[1]}; + auto offset = x.frame->offset; + auto size = x.frame->size; + cv::Rect roi = {offset[0], offset[1], (int)size[0], (int)size[1]}; x.mat.copyTo(mat(roi)); } diff --git a/anim-crop-tool/main.cpp b/anim-crop-tool/main.cpp index a95d3bae..d1115bdc 100644 --- a/anim-crop-tool/main.cpp +++ b/anim-crop-tool/main.cpp @@ -117,7 +117,7 @@ static bool load_file(anim_group& group, options& opts, anim_atlas& atlas, const (int)std::round((group.ground[1] - start[1]) * opts.scale), }; - group.frames.push_back({ground, atlas.offset(), {dest_size.width, dest_size.height}}); + group.frames.push_back({ground, atlas.offset(), {(unsigned)dest_size.width, (unsigned)dest_size.height}}); atlas.add_entry({&group.frames.back(), std::move(resized)}); return true; } diff --git a/compat/enum-bitset.hpp b/compat/enum-bitset.hpp new file mode 100644 index 00000000..bf705138 --- /dev/null +++ b/compat/enum-bitset.hpp @@ -0,0 +1,17 @@ +#pragma once +#include <bitset> + +namespace Magnum::Examples { + +template<typename Enum> +struct enum_bitset : std::bitset<(std::size_t)Enum::MAX> { + static_assert(std::is_same_v<std::size_t, std::common_type_t<std::size_t, std::underlying_type_t<Enum>>>); + static_assert(std::is_same_v<Enum, std::decay_t<Enum>>); + using std::bitset<(std::size_t)Enum::MAX>::bitset; + constexpr bool operator[](Enum x) const { return operator[]((std::size_t)x); } + constexpr decltype(auto) operator[](Enum x) { + return std::bitset<(std::size_t)Enum::MAX>::operator[]((std::size_t)x); + } +}; + +} // namespace Magnum::Examples diff --git a/main/main.cpp b/main/main.cpp index a579f1eb..80d85eef 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -5,10 +5,10 @@ #include "chunk.hpp" #include "floor-mesh.hpp" #include "wall-mesh.hpp" -#include "compat/defs.hpp" -#include <bitset> +#include "compat/enum-bitset.hpp" + #include <Magnum/Magnum.h> -#include <Magnum/Math/Vector.h> +#include <Magnum/Math/Vector2.h> #include <Magnum/GL/DefaultFramebuffer.h> #include <Magnum/GL/Renderer.h> #include <Magnum/Platform/Sdl2Application.h> @@ -17,17 +17,6 @@ namespace Magnum::Examples { -template<typename enum_type> -struct enum_bitset : std::bitset<(std::size_t)enum_type::MAX> { - static_assert(std::is_same_v<std::size_t, std::common_type_t<std::size_t, std::underlying_type_t<enum_type>>>); - static_assert(std::is_same_v<enum_type, std::decay_t<enum_type>>); - using std::bitset<(std::size_t)enum_type::MAX>::bitset; - constexpr bool operator[](enum_type x) const { return operator[]((std::size_t)x); } - constexpr decltype(auto) operator[](enum_type x) { - return std::bitset<(std::size_t)enum_type::MAX>::operator[]((std::size_t)x); - } -}; - struct app final : Platform::Application { using dpi_policy = Platform::Implementation::Sdl2DpiScalingPolicy; diff --git a/serialize/anim.hpp b/serialize/anim.hpp index bce88923..41ff5108 100644 --- a/serialize/anim.hpp +++ b/serialize/anim.hpp @@ -14,7 +14,8 @@ namespace Magnum::Examples::Serialize { struct anim_frame final { - Magnum::Vector2i ground, offset, size; + Vector2i ground, offset; + Vector2ui size; }; enum class anim_direction : unsigned char @@ -27,7 +28,7 @@ struct anim_group final { std::string name; std::vector<anim_frame> frames; - Magnum::Vector2i ground; + Vector2i ground; }; struct anim final diff --git a/shaders/tile-shader.hpp b/shaders/tile-shader.hpp index ee9056da..fd865208 100644 --- a/shaders/tile-shader.hpp +++ b/shaders/tile-shader.hpp @@ -1,11 +1,7 @@ #pragma once -#include <vector> -#include <utility> #include <Magnum/GL/AbstractShaderProgram.h> -#include <Magnum/GL/Texture.h> -#include <Magnum/Math/Color.h> #include <Magnum/Math/Vector2.h> -#include <Magnum/Math/Matrix4.h> +#include <Magnum/Math/Vector3.h> namespace Magnum::Examples { diff --git a/src/tile-iterator.hpp b/src/tile-iterator.hpp index 0cd6d616..3ebb53a2 100644 --- a/src/tile-iterator.hpp +++ b/src/tile-iterator.hpp @@ -66,7 +66,7 @@ namespace std { template<typename Tile> class iterator_traits<Magnum::Examples::basic_tile_iterator<Tile>> { - using T = typename Magnum::Examples::basic_tile_iterator<Tile>::value_type; + using T = Magnum::Examples::basic_tile_iterator<Tile>; public: using difference_type = std::ptrdiff_t; using value_type = T; diff --git a/src/tile.hpp b/src/tile.hpp index b3b57d08..c6d4e73d 100644 --- a/src/tile.hpp +++ b/src/tile.hpp @@ -2,8 +2,6 @@ #include "compat/defs.hpp" #include "compat/assert.hpp" #include "tile-defs.hpp" -#include <Magnum/Magnum.h> -#include <Magnum/Math/Vector3.h> #include <cstdint> #include <memory> diff --git a/src/wall-mesh.hpp b/src/wall-mesh.hpp index bf8c533e..4a4e9615 100644 --- a/src/wall-mesh.hpp +++ b/src/wall-mesh.hpp @@ -3,8 +3,8 @@ #include "tile.hpp" #include <array> #include <Corrade/Containers/ArrayViewStl.h> -#include <Magnum/Magnum.h> #include <Magnum/Math/Vector2.h> +#include <Magnum/Math/Vector3.h> #include <Magnum/GL/Mesh.h> #include <Magnum/GL/Buffer.h> |