From 4bafbe461ac6a6c7efce731040934b638375c52c Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 24 Oct 2019 19:01:48 -0300 Subject: [PATCH] Don't include empty samples in the sprite sheet when the whole sprite is trimmed We have to include at least one pixel for each sample. --- src/app/doc_exporter.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/doc_exporter.cpp b/src/app/doc_exporter.cpp index 2c9846272..d02def591 100644 --- a/src/app/doc_exporter.cpp +++ b/src/app/doc_exporter.cpp @@ -222,8 +222,17 @@ public: return m_bounds->trimmed(); } - void setTrimmedBounds(const gfx::Rect& bounds) { m_bounds->setTrimmedBounds(bounds); } - void setInTextureBounds(const gfx::Rect& bounds) { m_bounds->setInTextureBounds(bounds); } + void setTrimmedBounds(const gfx::Rect& bounds) { + // TODO we cannot assign an empty rectangle (samples that are + // completely trimmed out should be included as a sample of size 1x1) + ASSERT(!bounds.isEmpty()); + m_bounds->setTrimmedBounds(bounds); + } + + void setInTextureBounds(const gfx::Rect& bounds) { + ASSERT(!bounds.isEmpty()); + m_bounds->setInTextureBounds(bounds); + } bool isLinked() const { return m_isLinked; } bool isDuplicated() const { return m_isDuplicated; } @@ -870,6 +879,8 @@ void DocExporter::captureSamples(Samples& samples, } else { spriteBounds = get_trimmed_bounds(sprite, m_trimByGrid); + if (spriteBounds.isEmpty()) + spriteBounds = gfx::Rect(0, 0, 1, 1); // Cache trimmed bounds so we don't have to recalculate them // in the next iteration/preview.