Don't discard empty frames if the cel is empty but the user doesn't want to discard empty frames (fix #2116)

E.g. Useful to match frames with tags information.
This commit is contained in:
David Capello 2019-10-01 20:39:02 -03:00
parent 1c8b8051a8
commit 01821ed989

View File

@ -37,6 +37,7 @@
#include "doc/sprite.h"
#include "doc/tag.h"
#include "gfx/packing_rects.h"
#include "gfx/rect_io.h"
#include "gfx/size.h"
#include "render/dithering.h"
#include "render/ordered_dither.h"
@ -49,6 +50,8 @@
#include <list>
#include <memory>
#define DX_TRACE(...) // TRACEARGS
using namespace doc;
namespace {
@ -482,6 +485,8 @@ gfx::Size DocExporter::calculateSheetSize()
void DocExporter::captureSamples(Samples& samples)
{
DX_TRACE("DX: Capture samples");
for (auto& item : m_documents) {
Doc* doc = item.doc;
Sprite* sprite = doc->sprite();
@ -490,6 +495,11 @@ void DocExporter::captureSamples(Samples& samples)
Tag* tag = item.tag;
int frames = item.frames();
DX_TRACE("DX: - Item:", doc->filename(),
"Frames:", frames,
"Layer:", layer ? layer->name(): "-",
"Tag:", tag ? tag->name(): "-");
std::string format = m_filenameFormat;
if (format.empty()) {
format = get_default_filename_format_for_sheet(
@ -548,7 +558,7 @@ void DocExporter::captureSamples(Samples& samples)
if (!done && (m_ignoreEmptyCels || m_trimCels)) {
// Ignore empty cels
if (layer && layer->isImage() && !cel)
if (layer && layer->isImage() && !cel && m_ignoreEmptyCels)
continue;
std::unique_ptr<Image> sampleRender(
@ -595,9 +605,11 @@ void DocExporter::captureSamples(Samples& samples)
continue;
}
// Create an empty entry for this completely trimmed frame
// anyway to get its duration in the list of frames.
sample.setTrimmedBounds(frameBounds = gfx::Rect(0, 0, 0, 0));
// Create an entry with Size(1, 1) for this completely
// trimmed frame anyway so we conserve the frame information
// (position and duration of the frame in the JSON data, and
// the relative position of the frame in frame tags).
sample.setTrimmedBounds(frameBounds = gfx::Rect(0, 0, 1, 1));
}
if (m_trimCels) {
@ -619,6 +631,12 @@ void DocExporter::captureSamples(Samples& samples)
}
samples.addSample(sample);
DX_TRACE("DX: - Sample:",
sample.document()->filename(),
"Layer:", sample.layer() ? sample.layer()->name(): "-",
"TrimmedBounds:", sample.trimmedBounds(),
"InTextureBounds:", sample.inTextureBounds());
}
}
}