mirror of https://github.com/aseprite/aseprite.git
Remove tag range adjust when exporting sprite sheets (fix #3210)
Before this fix, tag ranges were adjusted in the json data file, in the 'meta' sector, when the --list-tags and --ignore-empty flags were set. Particularlly, when --split-layers, --list-tags, and --ignore-empty were on, the calculation of tag ranges could fail with cels with pure mask pixels.
This commit is contained in:
parent
b70a29269d
commit
683747f412
|
@ -603,7 +603,6 @@ void DocExporter::reset()
|
||||||
m_listLayers = false;
|
m_listLayers = false;
|
||||||
m_listSlices = false;
|
m_listSlices = false;
|
||||||
m_documents.clear();
|
m_documents.clear();
|
||||||
m_tagDelta.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocExporter::setDocImageBuffer(const doc::ImageBufferPtr& docBuf)
|
void DocExporter::setDocImageBuffer(const doc::ImageBufferPtr& docBuf)
|
||||||
|
@ -961,15 +960,8 @@ void DocExporter::captureSamples(Samples& samples,
|
||||||
|
|
||||||
// Should we ignore this empty frame? (i.e. don't include
|
// Should we ignore this empty frame? (i.e. don't include
|
||||||
// the frame in the sprite sheet)
|
// the frame in the sprite sheet)
|
||||||
if (m_ignoreEmptyCels) {
|
if (m_ignoreEmptyCels)
|
||||||
for (Tag* tag : sprite->tags()) {
|
|
||||||
auto& delta = m_tagDelta[tag->id()];
|
|
||||||
|
|
||||||
if (frame < tag->fromFrame()) --delta.first;
|
|
||||||
if (frame <= tag->toFrame()) --delta.second;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
// Create an entry with Size(1, 1) for this completely
|
// Create an entry with Size(1, 1) for this completely
|
||||||
// trimmed frame anyway so we conserve the frame information
|
// trimmed frame anyway so we conserve the frame information
|
||||||
|
@ -1340,13 +1332,9 @@ void DocExporter::createDataFile(const Samples& samples,
|
||||||
else
|
else
|
||||||
os << ",";
|
os << ",";
|
||||||
|
|
||||||
std::pair<int, int> delta(0, 0);
|
|
||||||
if (!m_tagDelta.empty())
|
|
||||||
delta = m_tagDelta[tag->id()];
|
|
||||||
|
|
||||||
os << "\n { \"name\": \"" << escape_for_json(tag->name()) << "\","
|
os << "\n { \"name\": \"" << escape_for_json(tag->name()) << "\","
|
||||||
<< " \"from\": " << (tag->fromFrame()+delta.first) << ","
|
<< " \"from\": " << (tag->fromFrame()) << ","
|
||||||
<< " \"to\": " << (tag->toFrame()+delta.second) << ","
|
<< " \"to\": " << (tag->toFrame()) << ","
|
||||||
<< " \"direction\": \"" << escape_for_json(convert_anidir_to_string(tag->aniDir())) << "\" }";
|
<< " \"direction\": \"" << escape_for_json(convert_anidir_to_string(tag->aniDir())) << "\" }";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019 Igara Studio S.A.
|
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
@ -21,7 +21,6 @@
|
||||||
#include "gfx/rect.h"
|
#include "gfx/rect.h"
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <map>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -163,11 +162,6 @@ namespace app {
|
||||||
bool m_listSlices;
|
bool m_listSlices;
|
||||||
Items m_documents;
|
Items m_documents;
|
||||||
|
|
||||||
// Displacement for each tag from/to frames in case we export
|
|
||||||
// them. It's used in case we trim frames outside tags and they
|
|
||||||
// will not be exported at all in the final result.
|
|
||||||
std::map<doc::ObjectId, std::pair<int, int> > m_tagDelta;
|
|
||||||
|
|
||||||
// Buffers used
|
// Buffers used
|
||||||
doc::ImageBufferPtr m_docBuf;
|
doc::ImageBufferPtr m_docBuf;
|
||||||
doc::ImageBufferPtr m_sampleBuf;
|
doc::ImageBufferPtr m_sampleBuf;
|
||||||
|
|
Loading…
Reference in New Issue