From 5f032f0e71f8382034c729577450e48721cfdc93 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 6 Nov 2022 13:42:05 +0100 Subject: switch anim atlas ground to unsigned --- anim-crop-tool/main.cpp | 10 ++++++++-- serialize/anim.hpp | 5 ++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/anim-crop-tool/main.cpp b/anim-crop-tool/main.cpp index c6472186..48a1e0c7 100644 --- a/anim-crop-tool/main.cpp +++ b/anim-crop-tool/main.cpp @@ -121,9 +121,15 @@ static bool load_file(anim_group& group, options& opts, anim_atlas& atlas, const (int)std::round(((int)group.ground[1] - start[1]) * opts.scale), }; - const Magnum::Vector2ui dest_size_ = { (unsigned)dest_size.width, (unsigned)dest_size.height }; + if (ground[0] < 0 || ground[1] < 0 || ground[0] >= dest_size.width || ground[1] >= dest_size.height) + { + Error{} << "ground marker for group" << group.name << "beyond image bounds"; + return false; + } + + const Vector2ui dest_size_ = { (unsigned)dest_size.width, (unsigned)dest_size.height }; - group.frames.push_back({ground, atlas.offset(), dest_size_}); + group.frames.push_back({Vector2ui(ground), atlas.offset(), dest_size_}); atlas.add_entry({&group.frames.back(), std::move(resized)}); return true; } diff --git a/serialize/anim.hpp b/serialize/anim.hpp index fb4b2f80..8915e8f1 100644 --- a/serialize/anim.hpp +++ b/serialize/anim.hpp @@ -10,8 +10,7 @@ namespace floormat::Serialize { struct anim_frame final { - Vector2i ground; - Vector2ui offset, size; + Vector2ui ground, offset, size; }; enum class anim_direction : unsigned char @@ -24,7 +23,7 @@ struct anim_group final { String name; std::vector frames; - Vector2i ground; + Vector2ui ground; }; struct anim final -- cgit v1.2.3