From f0fa34cf4aab73772da9bb177686d518367b34a9 Mon Sep 17 00:00:00 2001 From: David Capello <davidcapello@gmail.com> Date: Tue, 12 Aug 2014 08:09:09 -0300 Subject: [PATCH] ExportSpriteSheet: fix getting the best fit size for long animations --- src/app/commands/cmd_export_sprite_sheet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp index 1ce5c8a53..94228d25f 100644 --- a/src/app/commands/cmd_export_sprite_sheet.cpp +++ b/src/app/commands/cmd_export_sprite_sheet.cpp @@ -84,10 +84,12 @@ namespace { ; int z = 0; - while (z++ < nframes*2) { + bool fully_contained = false; + while (!fully_contained) { // TODO at this moment we're not + // getting the best fit for less + // freearea, just the first one. gfx::Region rgn(gfx::Rect(w, h)); int contained_frames = 0; - bool fully_contained = false; for (int v=0; v+frameh <= h && !fully_contained; v+=frameh) { for (int u=0; u+framew <= w; u+=framew) { @@ -115,7 +117,7 @@ namespace { result = fit; } - if (z & 1) w *= 2; + if ((++z) & 1) w *= 2; else h *= 2; }