From 8b67a492f459a47a1d2eeebc852c9741a77708d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Jan 2024 10:59:44 +0100 Subject: a --- wall-tileset-tool/main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'wall-tileset-tool/main.cpp') diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp index f233941f..6287066c 100644 --- a/wall-tileset-tool/main.cpp +++ b/wall-tileset-tool/main.cpp @@ -11,6 +11,7 @@ #include "loader/loader.hpp" #include #include +#include #include #include #include @@ -86,7 +87,9 @@ bool convert_to_bgra32(const cv::Mat& src, cv::Mat4b& dest) bool save_image(state st) { - fm_assert(st.new_atlas.frames.empty()); + fm_assert(st.new_atlas.frames.isEmpty()); + arrayReserve(st.new_atlas.frames, 64); + uint32_t max_height = 0; for (const auto& group : st.groups) { @@ -136,7 +139,9 @@ bool save_image(state st) auto rect = cv::Rect{(int)frame.offset.x(), (int)frame.offset.y(), (int)frame.size.x(), (int)frame.size.y()}; frame.mat.copyTo(st.dest(rect)); - st.new_atlas.frames.push_back({.offset = frame.offset, .size = frame.size}); + arrayAppend(st.new_atlas.frames, Wall::Frame { + .offset = frame.offset, .size = frame.size + }); } } @@ -155,7 +160,7 @@ bool save_image(state st) bool save_json(state st) { using namespace floormat::Wall::detail; - fm_assert(!st.new_atlas.frames.empty()); + fm_assert(!st.new_atlas.frames.isEmpty()); fm_assert(st.new_atlas.header.depth > 0); auto filename = ""_s.join({Path::join(st.opts.output_dir, st.new_atlas.header.name), ".json"_s}); st.new_atlas.serialize(filename); @@ -286,7 +291,7 @@ bool do_direction(state& st, size_t i) return false; } - st.new_atlas.direction_array.push_back(std::move(dir)); + arrayAppend(st.new_atlas.direction_array, std::move(dir)); return true; } @@ -304,7 +309,8 @@ bool do_input_file(state& st) fm_assert(!atlas.frames.size()); fm_assert(!atlas.direction_mask.any()); fm_assert(atlas.direction_map == std::array{}); - fm_assert(atlas.direction_array.empty()); + fm_assert(atlas.direction_array.isEmpty()); + arrayReserve(atlas.direction_array, Direction_COUNT); for (auto i = 0uz; i < Direction_COUNT; i++) { @@ -399,7 +405,7 @@ int main(int argc, char** argv) uint32_t n_frames = 0; auto groups = std::vector{}; - groups.reserve(std::size(Wall::Direction::groups)); + groups.reserve(Wall::Group_COUNT); for (auto [name, ptr, val] : Wall::Direction::groups) { -- cgit v1.2.3