Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Autoclose: Connect to image bounds

Abel You40b8c6c9b44c
diff --git a/toonz/sources/toonzfarm/include/tlog.h b/toonz/sources/toonzfarm/include/tlog.h
index e714812f3..a7bc24c2b 100644
--- a/toonz/sources/toonzfarm/include/tlog.h
+++ b/toonz/sources/toonzfarm/include/tlog.h
@@ -7,6 +7,7 @@
#include "tcommon.h"
#include <QString>
+#include <string>
class TFilePath;
diff --git a/toonz/sources/toonzfarm/tfarm/tlog.cpp b/toonz/sources/toonzfarm/tfarm/tlog.cpp
index 36ffe5504..9c5b51b87 100644
--- a/toonz/sources/toonzfarm/tfarm/tlog.cpp
+++ b/toonz/sources/toonzfarm/tfarm/tlog.cpp
@@ -1,7 +1,7 @@
#include "tlog.h"
-//#include "tfilepath.h"
+// #include "tfilepath.h"
#include "tfilepath_io.h"
#include <QDateTime>
diff --git a/toonz/sources/toonzlib/autoclose.cpp b/toonz/sources/toonzlib/autoclose.cpp
index 057928624..6e30751cf 100644
--- a/toonz/sources/toonzlib/autoclose.cpp
+++ b/toonz/sources/toonzlib/autoclose.cpp
@@ -233,7 +233,8 @@ unsigned char buildPaintnInkNeighborPattern(int x, int y, TRasterCM32P r,
}
// qDebug() << "Pattern:"
// << QString::number(pattern, 2).rightJustified(8, '0');
- }
+ } else
+ pattern |= (1 << 7 - i);
}
// qDebug() << "Final pattern: decimal =" << (int)pattern << "| binary = 0b"
// << QString::number(pattern, 2).rightJustified(8, '0');
@@ -928,10 +929,10 @@ continue;
if (p1.y < 0) {
p1.x = tround(p0.x - (float)((p0.x - p1.x) * p0.y) / (p0.y - p1.y));
p1.y = 0;
- } else if (p1.y > ly) {
+ } else if (p1.y >= ly) {
p1.x =
tround(p0.x - (float)((p0.x - p1.x) * (p0.y - ly)) / (p0.y - p1.y));
- p1.y = ly;
+ p1.y = ly - 1;
}
it++;
}
@@ -983,7 +984,11 @@ bool TAutocloser::Imp::exploreSpot(const Segment &s, TPoint &p) {
y1 = s.first.y;
x2 = s.second.x;
y2 = s.second.y;
-
+ if (x2 == 0 || x2 == lx || y2 == 0 || y2 == ly - 1) {
+ p.x = x2;
+ p.y = y2;
+ return true;
+ }
if (x1 == x2 && y1 == y2) return 0;
if (exploreRay(getPtr(x1, y1), s, p)) return true;
diff --git a/toonz/sources/toonzlib/stagevisitor.cpp b/toonz/sources/toonzlib/stagevisitor.cpp
index 606bc3168..f2c852c42 100644
--- a/toonz/sources/toonzlib/stagevisitor.cpp
+++ b/toonz/sources/toonzlib/stagevisitor.cpp
@@ -424,7 +424,7 @@ TRasterP RasterPainter::getRaster(int index, QTransform &matrix) {
rect = rect * TRect(0, 0, m_dim.lx - 1, m_dim.ly - 1);
TAffine aff = TTranslation(-rect.x0, -rect.y0) * m_nodes[index].m_aff;
- matrix = QTransform(aff.a11, aff.a21, aff.a12, aff.a22, aff.a13, aff.a23);
+ matrix = QTransform(aff.a11, aff.a21, aff.a12, aff.a22, aff.a13, aff.a23);
return m_nodes[index].m_raster;
}
@@ -560,20 +560,23 @@ void RasterPainter::flushRasterImages() {
int gapCheckIndex = -1;
if ((tc & ToonzCheck::eGap || tc & ToonzCheck::eAutoclose) &&
m_nodes[i].m_isCurrentColumn) {
- srcCm = srcCm->clone();
- plt = m_nodes[i].m_palette->clone();
- gapCheckIndex = plt->addStyle(TPixel::Magenta);
+ TRasterCM32P aux = srcCm->clone();
+ srcCm = Preferences::instance()->getFillOnlySavebox()
+ ? (TRasterCM32P)aux->extract(m_nodes[i].m_savebox)
+ : aux;
+ plt = m_nodes[i].m_palette->clone();
+ gapCheckIndex = plt->addStyle(TPixel::Magenta);
if (tc & ToonzCheck::eGap)
AreaFiller(srcCm).rectFastFill(m_nodes[i].m_savebox, 1);
- if (tc & ToonzCheck::eAutoclose && m_nodes[i].m_onionMode == Node::eOnionSkinNone) {
+ if (tc & ToonzCheck::eAutoclose &&
+ m_nodes[i].m_onionMode == Node::eOnionSkinNone) {
auto settings = ToonzCheck::instance()->getAutocloseSettings();
std::set<int> autoPaints;
if (settings.m_ignoreAPInks) {
for (int i = 0; i < plt->getStyleCount(); i++)
- if (plt->getStyle(i)->getFlags() != 0)
- autoPaints.insert(i);
+ if (plt->getStyle(i)->getFlags() != 0) autoPaints.insert(i);
}
- TAutocloser ac(srcCm, gapCheckIndex,settings, std::move(autoPaints));
+ TAutocloser ac(srcCm, gapCheckIndex, settings, std::move(autoPaints));
if (ac.hasSegmentCache(m_currentImageId))
ac.draw(ac.getSegmentCache(m_currentImageId));
else
@@ -585,6 +588,7 @@ void RasterPainter::flushRasterImages() {
AreaFiller(srcCm).rectFastFill(m_nodes[i].m_savebox, gapFillIndex);
}
}
+ srcCm = aux;
} else
plt = m_nodes[i].m_palette;
@@ -723,7 +727,8 @@ void RasterPainter::drawRasterImages(QPainter &p, QPolygon cameraPol) {
p.resetTransform();
TRasterP ras = m_nodes[i].m_raster;
TAffine aff = TTranslation(-rect.x0, -rect.y0) * flipY * m_nodes[i].m_aff;
- QTransform matrix(aff.a11, aff.a12, aff.a21, aff.a22, aff.a13, aff.a23); // Updated line
+ QTransform matrix(aff.a11, aff.a12, aff.a21, aff.a22, aff.a13,
+ aff.a23); // Updated line
QImage image = rasterToQImage(ras);
if (image.isNull()) continue;
p.setWorldTransform(matrix);
@@ -1003,11 +1008,11 @@ void RasterPainter::onRasterImage(TRasterImage *ri,
TAffine aff;
aff = m_viewAff * player.m_placement * player.m_dpiAff;
-
+
aff = TTranslation(m_dim.lx * 0.5, m_dim.ly * 0.5) * aff *
TTranslation(-r->getCenterD() +
convert(ri->getOffset())); // this offset is !=0 only if
- // in cleanup camera test mode
+ // in cleanup camera test mode
TRectD bbox = TRectD(0, 0, m_dim.lx, m_dim.ly);
bbox *= convert(m_clipRect);