Skip to content

Commit

Permalink
Fixed output of texture.filename when path is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
houmain committed Jun 15, 2024
1 parent d09493d commit 78ac37c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ std::string make_identifier(std::string string) {

// remove duplicate underscores and also from front and back
auto after_underscore = true;
for (auto i = 0; i < string.size(); ) {
for (auto i = 0u; i < string.size(); ) {
if (string[i] == '_') {
if (after_underscore) {
string.erase(i, 1);
Expand Down
3 changes: 2 additions & 1 deletion src/output_description.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ namespace {
json_texture["spriteIndices"] = slice_sprites[slice.index];
json_texture["path"] = path_to_utf8(settings.output_path);
json_texture["filename"] = path_to_utf8(
std::filesystem::relative(texture.filename, settings.output_path));
settings.output_path.empty() ? texture.filename :
std::filesystem::relative(texture.filename, settings.output_path));
json_texture["scale"] = output.scale;
json_texture["width"] = to_int(slice.width * output.scale);
json_texture["height"] = to_int(slice.height * output.scale);
Expand Down
2 changes: 0 additions & 2 deletions src/pack_binpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ void pack_binpack(const SheetPtr& sheet_ptr, SpriteSpan sprites,

// update sprite rects
auto slice_index = 0;
auto packed_sprites = size_t{ };
for (const auto& pack_sheet : pack_sheets) {
for (const auto& pack_rect : pack_sheet.rects) {
auto& sprite = sprites[to_unsigned(pack_rect.id)];
sprite.rotated = pack_rect.rotated;
sprite.slice_index = slice_index;
sprite.trimmed_rect.x = pack_rect.x;
sprite.trimmed_rect.y = pack_rect.y;
++packed_sprites;
}
++slice_index;
}
Expand Down

0 comments on commit 78ac37c

Please sign in to comment.