OpenToonz - An open-source full-featured 2D animation creation software
C
Fix Z=0 Camera Preview crash (#2405)
manongjohn54e85db21d02
diff --git a/toonz/sources/common/tgeometry/tgeometry.cpp b/toonz/sources/common/tgeometry/tgeometry.cppindex 065e270d4..e34ee3a1b 100644--- a/toonz/sources/common/tgeometry/tgeometry.cpp+++ b/toonz/sources/common/tgeometry/tgeometry.cpp@@ -56,16 +56,22 @@ TAffine TAffine::operator*=(const TAffine &b) { return *this = *this * b; }//--------------------------------------------------------------------------------------------------TAffine TAffine::inv() const {if (a12 == 0.0 && a21 == 0.0) {- assert(a11 != 0.0);- assert(a22 != 0.0);- double inv_a11 = 1.0 / a11;- double inv_a22 = 1.0 / a22;+ double inv_a11 =+ (a11 == 0.0 ? std::numeric_limits<double>::max() / (1 << 16)+ : 1.0 / a11);+ double inv_a22 =+ (a22 == 0.0 ? std::numeric_limits<double>::max() / (1 << 16)+ : 1.0 / a22);return TAffine(inv_a11, 0, -a13 * inv_a11, 0, inv_a22, -a23 * inv_a22);} else if (a11 == 0.0 && a22 == 0.0) {assert(a12 != 0.0);assert(a21 != 0.0);- double inv_a21 = 1.0 / a21;- double inv_a12 = 1.0 / a12;+ double inv_a21 =+ (a21 == 0.0 ? std::numeric_limits<double>::max() / (1 << 16)+ : 1.0 / a21);+ double inv_a12 =+ (a12 == 0.0 ? std::numeric_limits<double>::max() / (1 << 16)+ : 1.0 / a12);return TAffine(0, inv_a21, -a23 * inv_a21, inv_a12, 0, -a13 * inv_a12);} else {double d = 1. / det();diff --git a/toonz/sources/toonzlib/imagepainter.cpp b/toonz/sources/toonzlib/imagepainter.cppindex e624282e9..77badcf8a 100644--- a/toonz/sources/toonzlib/imagepainter.cpp+++ b/toonz/sources/toonzlib/imagepainter.cpp@@ -425,7 +425,10 @@ void Painter::doFlushRasterImages(const TRasterP &rin, int bg,int lx = (m_imageSize.lx == 0 ? _rin->getLx() : m_imageSize.lx);int ly = (m_imageSize.ly == 0 ? _rin->getLy() : m_imageSize.ly);- TRect rect = convert(aff * TRectD(0, 0, lx - 1, ly - 1));+ TRect rect = convert(aff * TRectD(0, 0, lx - 1, ly - 1));+ // Image size is a 0 point. Do nothing+ if (rect.x0 == rect.x1 && rect.y0 == rect.y1) return;+TRaster32P raux = ras->extract(rect);raux->fill(bg == 0x40000 ? TPixel::Black : TPixel::White);}