diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-25 17:39:52 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-25 17:39:52 +0100 |
commit | 33642dd230009231e81b88b237991378b6ca1123 (patch) | |
tree | dab120b002956d33fa0eaa91be1ef8410c559445 | |
parent | 7b756134b3a5fd9ca0ec700af0eafac91b5d4ee7 (diff) |
a
-rw-r--r-- | editor/editor.hpp | 1 | ||||
-rw-r--r-- | loader/vobj.cpp | 4 | ||||
-rw-r--r-- | src/anim.hpp | 20 | ||||
-rw-r--r-- | src/wall-atlas.hpp | 8 | ||||
-rw-r--r-- | wall-tileset-tool/main.cpp | 54 | ||||
-rw-r--r-- | wall-tileset-tool/main.hpp | 27 |
6 files changed, 74 insertions, 40 deletions
diff --git a/editor/editor.hpp b/editor/editor.hpp index d877288d..4a7292ea 100644 --- a/editor/editor.hpp +++ b/editor/editor.hpp @@ -8,7 +8,6 @@ #include "scenery-editor.hpp" #include "vobj-editor.hpp" -#include <map> #include <Corrade/Containers/Optional.h> #include <Corrade/Containers/StringView.h> diff --git a/loader/vobj.cpp b/loader/vobj.cpp index aa3be207..b48275ab 100644 --- a/loader/vobj.cpp +++ b/loader/vobj.cpp @@ -44,10 +44,6 @@ void nlohmann::adl_serializer<vobj>::from_json(const json& j, vobj& val) namespace floormat::loader_detail { -#if defined __GNUG__ && !defined __clang__ -#pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif - std::shared_ptr<class anim_atlas> loader_impl::make_vobj_anim_atlas(StringView name, StringView image_filename) { auto tex = texture(VOBJ_PATH, image_filename); diff --git a/src/anim.hpp b/src/anim.hpp index d1f413ae..e505f29f 100644 --- a/src/anim.hpp +++ b/src/anim.hpp @@ -10,8 +10,8 @@ namespace floormat { struct anim_frame final { - Vector2i ground; - Vector2ui offset, size; + Vector2i ground{}; + Vector2ui offset{}, size{}; }; enum class anim_direction : unsigned char @@ -22,11 +22,11 @@ enum class anim_direction : unsigned char struct anim_group final { - String name, mirror_from; - std::vector<anim_frame> frames; - Vector2ui ground; // for use in anim-crop-tool only - Vector2s z_offset, depth_offset; - Vector3b offset; + String name{}, mirror_from{}; + std::vector<anim_frame> frames{}; + Vector2ui ground{}; // for use in anim-crop-tool only + Vector2s z_offset{}, depth_offset{}; + Vector3b offset{}; }; enum class anim_scale_type : unsigned char { invalid, ratio, fixed, }; @@ -53,9 +53,9 @@ struct anim_scale final struct anim_def final { - String object_name, anim_name; - std::vector<anim_group> groups; - Vector2ui pixel_size; + String object_name{}, anim_name{}; + std::vector<anim_group> groups{}; + Vector2ui pixel_size{}; anim_scale scale = anim_scale::ratio{1}; size_t nframes = 0, fps = 0, action_frame = 0, action_frame2 = 0; }; diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp index 4dcc0e59..257df02d 100644 --- a/src/wall-atlas.hpp +++ b/src/wall-atlas.hpp @@ -28,8 +28,8 @@ struct Group Color4 tint_mult{1,1,1,1}; Color3 tint_add; uint8_t from_rotation = (uint8_t)-1; // applies only to images - bool mirrored : 1 = false, - default_tint : 1 = true; + bool mirrored : 1 = false, + default_tint : 1 = true; explicit operator bool() const noexcept { return !is_empty(); } bool is_empty() const noexcept { return count == 0; } @@ -49,8 +49,8 @@ struct Direction explicit operator bool() const noexcept { return !is_empty(); } bool is_empty() const noexcept; - Group wall, overlay, side, top; - Group corner_L, corner_R; + Group wall{}, overlay{}, side{}, top{}; + Group corner_L{}, corner_R{}; pass_mode passability = pass_mode::blocked; const Group& group(Group_ i) const; diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp index 9245cd8c..aac56490 100644 --- a/wall-tileset-tool/main.cpp +++ b/wall-tileset-tool/main.cpp @@ -1,14 +1,14 @@ +#include "main.hpp" #include "compat/assert.hpp" #include "compat/sysexits.hpp" #include "compat/fix-argv0.hpp" #include "compat/strerror.hpp" #include "compat/format.hpp" #include "src/wall-atlas.hpp" -#include "serialize/wall-atlas.hpp" -#include "serialize/json-helper.hpp" +//#include "serialize/wall-atlas.hpp" +//#include "serialize/json-helper.hpp" #include "loader/loader.hpp" #include <utility> -#include <tuple> #include <Corrade/Containers/StringView.h> #include <Corrade/Containers/String.h> #include <Corrade/Containers/TripleStl.h> @@ -16,12 +16,11 @@ #include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/Arguments.h> #include <Magnum/Math/Functions.h> -//#include <nlohmann/json.hpp> #include <opencv2/core/mat.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> -namespace floormat { +namespace floormat::wall_tool { using Corrade::Utility::Arguments; using namespace std::string_literals; @@ -55,19 +54,26 @@ Vector2i get_buffer_size(const wall_atlas_def& a) return size; } -struct options +const Direction& get_direction(const wall_atlas_def& atlas, size_t i) { - String input_dir, input_file, output_dir; -}; + fm_assert(atlas.direction_mask[i]); + auto idx = atlas.direction_map[i]; + fm_assert(idx); + return atlas.direction_array[idx.val]; +} + +Direction& get_direction(wall_atlas_def& atlas, size_t i) +{ + return const_cast<Direction&>(get_direction(const_cast<const wall_atlas_def&>(atlas), i)); +} -struct state +bool do_group(state& st, size_t i, size_t j) { - options& opts; - cv::Mat4b& buffer; - const wall_atlas_def& old_atlas; - wall_atlas_def& new_atlas; - int& error; -}; + const auto& old_dir = get_direction(st.old_atlas, i); + auto& new_dir = get_direction(st.new_atlas, i); + + return true; +} bool do_direction(state& st, size_t i) { @@ -75,6 +81,10 @@ bool do_direction(state& st, size_t i) auto& atlas = st.new_atlas; DBG << "-" << name; + const auto& old_dir = get_direction(st.old_atlas, i); + +#if 0 + // todo from_rotation auto path = Path::join(st.opts.input_dir, name); if (!Path::isDirectory(path)) { @@ -82,22 +92,23 @@ bool do_direction(state& st, size_t i) auto error = errno; auto errstr = get_error_string(errbuf, error); auto dbg = WARN_nospace; - dbg << "error: direction '" << name << "' needs directory '" << path << "'"; + dbg << "error: direction \"" << name << "\" needs directory '" << path << "'"; if (error) dbg << ": " << errstr; return false; } +#endif + fm_assert(!atlas.direction_mask[i]); + fm_assert(!atlas.direction_map[i]); const auto dir_idx = atlas.direction_array.size(); fm_assert(dir_idx == (uint8_t)dir_idx); - fm_assert(!atlas.direction_mask[i]); atlas.direction_mask[i] = 1; - fm_assert(!atlas.direction_map[i]); atlas.direction_map[i] = DirArrayIndex{(uint8_t)dir_idx}; - auto dir = Direction{ - + auto dir = Direction { + .passability = old_dir.passability, }; st.new_atlas.direction_array.push_back(std::move(dir)); @@ -185,9 +196,10 @@ Triple<options, Arguments, bool> parse_cmdline(int argc, const char* const* argv } // namespace -} // namespace floormat +} // namespace floormat::wall_tool using namespace floormat; +using namespace floormat::wall_tool; int main(int argc, char** argv) { diff --git a/wall-tileset-tool/main.hpp b/wall-tileset-tool/main.hpp new file mode 100644 index 00000000..b826d634 --- /dev/null +++ b/wall-tileset-tool/main.hpp @@ -0,0 +1,27 @@ +#pragma once +#include "src/wall-atlas.hpp" + +namespace cv { +template<typename T> class Mat_; +template<typename T, int cn> class Vec; +typedef Vec<unsigned char, 4> Vec4b; +typedef Mat_<Vec4b> Mat4b; +} // namespace cv + +namespace floormat::wall_tool { + +struct options +{ + String input_dir, input_file, output_dir; +}; + +struct state +{ + options& opts; + cv::Mat4b& buffer; + const wall_atlas_def& old_atlas; + wall_atlas_def& new_atlas; + int& error; +}; + +} // namespace floormat::wall_tool |