Skip to content

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

C

Feat(refer fill): support vector level

Abel Youaae2012f3e64
diff --git a/toonz/sources/include/toonz/txshsimplelevel.h b/toonz/sources/include/toonz/txshsimplelevel.h
index 6ac685451..6e417df6c 100644
--- a/toonz/sources/include/toonz/txshsimplelevel.h
+++ b/toonz/sources/include/toonz/txshsimplelevel.h
@@ -212,6 +212,7 @@ table) it returns the proper insertion index
TRasterImageP getFrameToCleanup(const TFrameId &fid,
bool toBeLineProcessed) const;
+ TRasterImageP getFrameRasterized(const TFrameId& fid, TPointD dpi) const;
std::string getImageId(const TFrameId &fid, int frameStatus = -1) const;
std::string getIconId(const TFrameId &fid, int frameStatus = -1) const;
diff --git a/toonz/sources/tnztools/filltool.cpp b/toonz/sources/tnztools/filltool.cpp
index 5d04c460f..37e17a767 100644
--- a/toonz/sources/tnztools/filltool.cpp
+++ b/toonz/sources/tnztools/filltool.cpp
@@ -11,6 +11,8 @@
#include "tools/toolhandle.h"
#include "tools/toolutils.h"
#include "toonz/tonionskinmaskhandle.h"
+#include "toonz/toonzscene.h"
+#include "toonz/tcamera.h"
#include "timagecache.h"
#include "tundo.h"
#include "tpalette.h"
@@ -399,7 +401,7 @@ public:
void undo() const override {
TRasterUndo::undo();
TToonzImageP image = getImage();
- if(m_refGapFill) TRop::eraseRefInks(image->getRaster());
+ if (m_refGapFill) TRop::eraseRefInks(image->getRaster());
if (!image) return;
if (m_saveboxOnly && !m_savebox.isEmpty()) image->setSavebox(m_savebox);
}
@@ -995,12 +997,12 @@ void drawReferImage(TRaster32P &ras, TXsheet *xsh, int col, int row,
TStageObject *pegbar =
xsh->getStageObject(TStageObjectId::ColumnId(colIndex));
TAffine aff = pegbar->getPlacement(row);
+ // Dpi scale (dpi = 0 if vector)
TPointD dpi = sl->getDpi();
- // From stageInch to pixel
aff.a13 *= dpi.x / Stage::inch;
aff.a23 *= dpi.y / Stage::inch;
- if (sl->getType() & (TZP_XSHLEVEL | OVL_XSHLEVEL)) {
+ if (sl->getType() & (TZP_XSHLEVEL | OVL_XSHLEVEL | PLI_XSHLEVEL)) {
TImageP img = sl->getFrame(cell.m_frameId, false);
TToonzImageP ti = img;
TRasterImageP ri = img;
@@ -1009,10 +1011,17 @@ void drawReferImage(TRaster32P &ras, TXsheet *xsh, int col, int row,
r = ti->getRaster();
else if (ri)
r = ri->getRaster();
+ else {
+ ri = sl->getFrameRasterized(
+ cell.m_frameId, TPointD(Stage::standardDpi, Stage::standardDpi));
+ if (!ri) continue;
+ r = ri->getRaster();
+ }
if (!r.getPointer()) continue;
TPointD offset = ras->getCenterD() - r->getCenterD() + saveboxoffset;
r32->clear();
- if (ri) TRop::quickPut(r32, r, TTranslation(offset));
+ if (ri)
+ TRop::quickPut(r32, r, TTranslation(offset + convert(ri->getOffset())));
if (ti) {
TRop::CmappedQuickputSettings st;
st.m_inksOnly = true;
@@ -1022,8 +1031,6 @@ void drawReferImage(TRaster32P &ras, TXsheet *xsh, int col, int row,
TTranslation(-ras->getCenterD());
assert(r32->getSize() == ras->getSize());
TRop::quickPut(ras, r32, aff);
- } else if (sl->getType() == PLI_XSHLEVEL) {
- // TODO: ToonzVector?
}
}
};
@@ -2078,6 +2085,8 @@ void FillTool::computeRefImgsIfNeeded(const FillParameters &params) {
// Caculate every refImg
bool fillOnlySavebox = Preferences::instance()->getFillOnlySavebox();
+ TPointD cameraDpi =
+ app->getCurrentScene()->getScene()->getCurrentCamera()->getDpi();
for (auto [sl, fid] : m_slFidsPairs) {
if (sl->getType() != TXshLevelType::TZP_XSHLEVEL) continue;
diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp
index acf536db4..6dabc84aa 100644
--- a/toonz/sources/toonzlib/txshsimplelevel.cpp
+++ b/toonz/sources/toonzlib/txshsimplelevel.cpp
@@ -698,6 +698,24 @@ TImageP TXshSimpleLevel::getFullsampledFrame(const TFrameId &fid,
//-----------------------------------------------------------------------------
+TRasterImageP TXshSimpleLevel::getFrameRasterized(const TFrameId &fid,
+ TPointD dpi) const {
+ assert(m_type == PLI_XSHLEVEL);
+
+ FramesSet::const_iterator it = m_frames.find(fid);
+ if (it == m_frames.end()) return TRasterImageP();
+
+ std::string imageId = getImageId(fid);
+ imageId = rasterized(imageId);
+ ImageLoader::BuildExtData extData(this, fid, 1);
+ extData.m_cameraDPI = dpi;
+ TImageP img =
+ ImageManager::instance()->getImage(imageId, ImageManager::none, &extData);
+ return img;
+}
+
+//-----------------------------------------------------------------------------
+
std::string TXshSimpleLevel::getIconId(const TFrameId &fid,
int frameStatus) const {
return "icon:" + getImageId(fid, frameStatus);
@@ -1972,7 +1990,7 @@ void TXshSimpleLevel::initializePalette() {
TFilePath fullPath;
TPalette *palette = new TPalette();
- int type = getType();
+ int type = getType();
switch (type) {
case TZP_XSHLEVEL:
fullPath =
@@ -2014,11 +2032,10 @@ void TXshSimpleLevel::initializePalette() {
break;
}
-
if (palette && type != OVL_XSHLEVEL) {
palette->setPaletteName(getName());
}
-
+
palette->setDirtyFlag(true);
setPalette(palette);
}