diff --git a/libs/util/include/psemek/util/atlas.hpp b/libs/util/include/psemek/util/atlas.hpp index c93139d6..5c9c0076 100644 --- a/libs/util/include/psemek/util/atlas.hpp +++ b/libs/util/include/psemek/util/atlas.hpp @@ -53,14 +53,24 @@ namespace psemek::util part.begin[1] = 0; part.end[1] = part_height; - std::size_t new_width = std::max(array_.width(), free_start_ + part_width); - std::size_t new_height = std::max(array_.height(), part_height); + std::size_t new_width = array_.width(); + std::size_t new_height = array_.height(); - if (new_width > array_.width()) - new_width = std::max(new_width, array_.width() * 2); + while (new_width < free_start_ + part_width) + { + if (new_width == 0) + new_width = 1; + else + new_width *= 2; + } - if (new_height > array_.height()) - new_height = std::max(new_height, array_.height() * 2); + while (new_height < part_height) + { + if (new_height == 0) + new_height = 1; + else + new_height *= 2; + } array_.resize({new_width, new_height}, default_value_);