From ca2a7c93a042ef47481fe295c2a08f0e1b2a2052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 18 Sep 2025 11:03:50 -0600 Subject: [PATCH] Make ToAtlasImage a global function instead of a method on ImageDesc --- Common/Render/AtlasGen.cpp | 4 ++-- Common/Render/AtlasGen.h | 4 ++-- UI/UIAtlas.cpp | 2 +- ext/native/tools/atlastool.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Common/Render/AtlasGen.cpp b/Common/Render/AtlasGen.cpp index 0643e994a8..115e7eba46 100644 --- a/Common/Render/AtlasGen.cpp +++ b/Common/Render/AtlasGen.cpp @@ -164,9 +164,9 @@ std::vector Bucket::Resolve(int image_width, Image &dest) { return data; } -AtlasImage ImageDesc::ToAtlasImage(int id, float tw, float th, const std::vector &results) const { +AtlasImage ToAtlasImage(int id, std::string_view name, float tw, float th, const std::vector &results) { AtlasImage img{}; - const int i = id == -1 ? result_index : id; + const int i = id; const float toffx = 0.5f / tw; const float toffy = 0.5f / th; img.u1 = results[i].sx / tw + toffx; diff --git a/Common/Render/AtlasGen.h b/Common/Render/AtlasGen.h index c53131e537..66c3a64c71 100644 --- a/Common/Render/AtlasGen.h +++ b/Common/Render/AtlasGen.h @@ -104,6 +104,6 @@ struct ImageDesc { std::string name; std::string fileName; int result_index; - - AtlasImage ToAtlasImage(int id, float tw, float th, const std::vector &results) const; }; + +AtlasImage ToAtlasImage(int id, std::string_view name, float tw, float th, const std::vector &results); diff --git a/UI/UIAtlas.cpp b/UI/UIAtlas.cpp index 05389ef557..ffbcbe80b6 100644 --- a/UI/UIAtlas.cpp +++ b/UI/UIAtlas.cpp @@ -157,7 +157,7 @@ Draw::Texture *GenerateUIAtlas(Draw::DrawContext *draw, Atlas *atlas) { std::vector genAtlasImages; genAtlasImages.reserve(ARRAY_SIZE(imageDescs)); for (int i = 0; i < ARRAY_SIZE(imageDescs); i++) { - genAtlasImages.push_back(imageDescs[i].ToAtlasImage(resultIds[i], (float)dest.width(), (float)dest.height(), results)); + genAtlasImages.push_back(ToAtlasImage(resultIds[i], imageDescs[i].name, (float)dest.width(), (float)dest.height(), results)); } atlas->Clear(); diff --git a/ext/native/tools/atlastool.cpp b/ext/native/tools/atlastool.cpp index 6d0f58b879..968c62464c 100644 --- a/ext/native/tools/atlastool.cpp +++ b/ext/native/tools/atlastool.cpp @@ -670,7 +670,7 @@ int GenerateFromScript(const char *script_file, const char *atlas_name, bool hig // For each image AtlasImage *atlas_images = new AtlasImage[images.size()]; for (int i = 0; i < (int)images.size(); i++) { - atlas_images[i] = images[i].ToAtlasImage(images[i].result_index, (float)dest.width(), (float)dest.height(), results); + atlas_images[i] = ToAtlasImage(images[i].result_index, images[i].name, (float)dest.width(), (float)dest.height(), results); } WriteCompressed(atlas_images, sizeof(AtlasImage), images.size(), meta); // For each font