diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-30 07:33:27 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-30 07:33:27 +0100 |
commit | c472b8d4d2719537ccf7b11f80717ca0cf3c22c2 (patch) | |
tree | dda45dd4ae81186dac18f72da0cbb4f28282ae39 | |
parent | 37cfaa7cee2dcd32e7c7305056e224e87e752ebe (diff) |
a
-rw-r--r-- | serialize/wall-atlas.cpp | 2 | ||||
-rw-r--r-- | src/wall-atlas.hpp | 2 | ||||
-rw-r--r-- | wall-tileset-tool/main.cpp | 7 | ||||
-rw-r--r-- | wall-tileset-tool/main.hpp | 4 |
4 files changed, 6 insertions, 9 deletions
diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp index cc14499e..dfc77bc3 100644 --- a/serialize/wall-atlas.cpp +++ b/serialize/wall-atlas.cpp @@ -348,7 +348,7 @@ void write_info_header(json& jroot, const Info& info) namespace floormat::Wall { -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Frame, offset) +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Frame, offset, size) NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Info, name, depth) } // namespace floormat::Wall diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp index a0103b2d..31f62388 100644 --- a/src/wall-atlas.hpp +++ b/src/wall-atlas.hpp @@ -16,7 +16,7 @@ namespace floormat::Wall { struct Frame { - Vector2ui offset = { (unsigned)-1, (unsigned)-1 }; + Vector2ui offset = { (unsigned)-1, (unsigned)-1 }, size; bool operator==(const Frame&) const noexcept; }; diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp index d616324b..a7fc0b6e 100644 --- a/wall-tileset-tool/main.cpp +++ b/wall-tileset-tool/main.cpp @@ -74,7 +74,7 @@ bool convert_to_bgra32(const cv::Mat& src, cv::Mat4b& dest) { fm_assert(dest.empty() || dest.size == src.size); - switch (auto type = src.type()) + switch (src.type()) { default: return false; @@ -122,6 +122,7 @@ bool save_image(state st) auto rect = cv::Rect{(int)xpos, 0, (int)x.size.x(), (int)x.size.y()}; xpos += x.size.x(); src.copyTo(st.dest(rect)); + st.new_atlas.frames.push_back({.offset = x.offset, .size = x.size}); } auto filename = ""_s.join({Path::join(st.opts.output_dir, st.new_atlas.header.name), ".png"_s}); if (!st.opts.use_alpha) @@ -138,10 +139,6 @@ bool save_image(state st) bool save_json(state st) { using namespace floormat::Wall::detail; - std::vector<Frame> frames; frames.reserve(st.frames.size()); - for (const auto& x : st.frames) - frames.push_back({.offset = x.offset}); - st.new_atlas.frames = std::move(frames); auto filename = ""_s.join({Path::join(st.opts.output_dir, st.new_atlas.header.name), ".json"_s}); st.new_atlas.serialize(filename); return true; diff --git a/wall-tileset-tool/main.hpp b/wall-tileset-tool/main.hpp index 7584797a..b7bc54e2 100644 --- a/wall-tileset-tool/main.hpp +++ b/wall-tileset-tool/main.hpp @@ -13,8 +13,8 @@ struct options struct frame { - cv::Mat4b mat; - Vector2ui offset, size; + cv::Mat4b mat{}; + Vector2ui offset{}, size{}; }; struct state |