OpenToonz - An open-source full-featured 2D animation creation software
C
Fix Plastic Rendering on 16 bit (#314)
Jeremy Bullockd934eafe4585
diff --git a/toonz/sources/include/toonz/plasticdeformerfx.h b/toonz/sources/include/toonz/plasticdeformerfx.hindex 8f2e82cb6..512817b31 100644--- a/toonz/sources/include/toonz/plasticdeformerfx.h+++ b/toonz/sources/include/toonz/plasticdeformerfx.h@@ -28,6 +28,8 @@ class TXsheet;class PlasticDeformerFx final : public TRasterFx {FX_DECLARATION(PlasticDeformerFx)+ bool m_was64bit = false;+public:TXsheet *m_xsh; //!< The Fx's enclosing Xsheetint m_col; //!< The input column indexdiff --git a/toonz/sources/toonzlib/plasticdeformerfx.cpp b/toonz/sources/toonzlib/plasticdeformerfx.cppindex 2a2b98193..069ec845b 100644--- a/toonz/sources/toonzlib/plasticdeformerfx.cpp+++ b/toonz/sources/toonzlib/plasticdeformerfx.cpp@@ -176,8 +176,11 @@ void PlasticDeformerFx::buildRenderSettings(double frame,// So, the best choice is to let the *input fx* decide the appropriate// reference, by invoking// its handledAffine() method.-- info.m_bpp = 32; // We need to fix the input to 32-bpp+ m_was64bit = false;+ if (info.m_bpp == 64) {+ m_was64bit = true;+ info.m_bpp = 32; // We need to fix the input to 32-bpp+ }info.m_affine = m_port->handledAffine(info, frame);}@@ -402,13 +405,33 @@ void PlasticDeformerFx::doCompute(TTile &tile, double frame,QImage img = fb.toImage().scaled(QSize(d.lx, d.ly), Qt::IgnoreAspectRatio,Qt::SmoothTransformation);int wrap = tile.getRaster()->getLx() * sizeof(TPixel32);- uchar *srcPix = img.bits();- uchar *dstPix = tile.getRaster()->getRawData() + wrap * (d.ly - 1);- for (int y = 0; y < d.ly; y++) {- memcpy(dstPix, srcPix, wrap);- dstPix -= wrap;- srcPix += wrap;+ if (!m_was64bit) {+ uchar *srcPix = img.bits();+ uchar *dstPix = tile.getRaster()->getRawData() + wrap * (d.ly - 1);+ for (int y = 0; y < d.ly; y++) {+ memcpy(dstPix, srcPix, wrap);+ dstPix -= wrap;+ srcPix += wrap;+ }+ }+ else if (m_was64bit) {+ TRaster64P newRaster(tile.getRaster()->getSize());+ TRaster32P tempRaster(tile.getRaster()->getSize());+ uchar *srcPix = img.bits();+ uchar *dstPix = tempRaster.getPointer()->getRawData() + wrap * (d.ly - 1);+ for (int y = 0; y < d.ly; y++) {+ memcpy(dstPix, srcPix, wrap);+ dstPix -= wrap;+ srcPix += wrap;+ }+ TRop::convert(newRaster, tempRaster);+ int size = tile.getRaster()->getLx() * tile.getRaster()->getLy() * sizeof(TPixel64);+ srcPix = newRaster.getPointer()->getRawData();+ dstPix = tile.getRaster()->getRawData();+ memcpy(dstPix, srcPix, size);+ texInfo.m_bpp = 64;}+fb.release();// context->getRaster(tile.getRaster());