Skip to content

Commit

Permalink
Fix spritesheets not supporting single image
Browse files Browse the repository at this point in the history
Issue lies is an oversight with how `max_width` is calculated. When having only a single image, it equals the `largest_size` and that leads to this particular if statement being skipped.

As a result, `TexturePacker` was trying to fit (for example) a 64x64 image, with `max_width` being 64. This, and the fact that default `TexturePackerConfig` has `texture_padding` set to 2 leads to an error message `TextureTooLargeToFitIntoAtlas`.

Tested different scenarious, including 127x128 and 128x127 images with no issues detected.
  • Loading branch information
Prevter committed Apr 8, 2024
1 parent c10d04a commit 2f40792
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/spritesheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn initialize_spritesheet_bundle(

let mut max_width = (width_sum * mean_height).sqrt() as u32;

if max_width < largest_width {
if max_width < largest_width || sprites.len() == 1 {
max_width = largest_width + 2;
}

Expand Down

0 comments on commit 2f40792

Please sign in to comment.