OpenToonz - An open-source full-featured 2D animation creation software
C
Fix Viewer Update Problems (#2049)
shun-iwasawa3c83df63ebe4
diff --git a/toonz/sources/include/toonz/strokegenerator.h b/toonz/sources/include/toonz/strokegenerator.hindex 916c2abb1..bc96dc7df 100644--- a/toonz/sources/include/toonz/strokegenerator.h+++ b/toonz/sources/include/toonz/strokegenerator.h@@ -35,6 +35,7 @@ class DVAPI StrokeGenerator {//! Rettangolo che contiene l'ultima regione modificataTRectD m_lastModifiedRegion;+ TRectD m_lastPointRect;//! Ultimo punto del frammento visualizzatoTPointD m_p0, /*! Ultimo punto del frammento visualizzato*/ m_p1;diff --git a/toonz/sources/tnztools/brushtool.cpp b/toonz/sources/tnztools/brushtool.cppindex ff4603e22..1d9063e83 100644--- a/toonz/sources/tnztools/brushtool.cpp+++ b/toonz/sources/tnztools/brushtool.cpp@@ -1351,6 +1351,8 @@ void BrushTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {} elseaddTrackPoint(TThickPoint(pos, thickness),getPixelSize() * getPixelSize());+ TRectD invalidateRect = m_track.getLastModifiedRegion();+ invalidate(invalidateRect.enlarge(2));}// updating m_brushPos is needed to refresh viewer properly@@ -1487,6 +1489,14 @@ void BrushTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {? computeThickness(e.m_pressure, m_thickness, m_isPath): m_thickness.getValue().second * 0.5;+ TRectD invalidateRect;+ TPointD halfThick(m_maxThick * 0.5, m_maxThick * 0.5);++ // In order to clear the previous snap mark+ if (m_foundLastSnap)+ invalidateRect +=+ TRectD(m_lastSnapPoint - halfThick, m_lastSnapPoint + halfThick);+m_currThickness = thickness;m_mousePos = pos;@@ -1495,22 +1505,28 @@ void BrushTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {m_foundFirstSnap = false;m_snapSelf = false;m_altPressed = e.isAltPressed() && !e.isCtrlPressed();+checkStrokeSnapping(false, m_altPressed);checkGuideSnapping(false, m_altPressed);m_brushPos = m_lastSnapPoint;+ if (m_foundLastSnap)+ invalidateRect +=+ TRectD(m_lastSnapPoint - halfThick, m_lastSnapPoint + halfThick);+if (e.isShiftPressed()) {m_smoothStroke.clearPoints();m_track.add(TThickPoint(m_brushPos, thickness),getPixelSize() * getPixelSize());m_track.removeMiddlePoints();- }-- else if (m_dragDraw)+ invalidateRect += m_track.getModifiedRegion();+ } else if (m_dragDraw) {addTrackPoint(TThickPoint(pos, thickness),getPixelSize() * getPixelSize());+ invalidateRect += m_track.getLastModifiedRegion();+ }- invalidate();+ if (!invalidateRect.isEmpty()) invalidate(invalidateRect.enlarge(2));}}@@ -1679,6 +1695,7 @@ void BrushTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e) {resetFrameRange();}}+ invalidate();} else {if (m_snapSelf) {stroke->setSelfLoop(true);@@ -1687,7 +1704,7 @@ void BrushTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e) {addStrokeToImage(getApplication(), vi, stroke, m_breakAngles.getValue(),m_isFrameCreated, m_isLevelCreated);TRectD bbox = stroke->getBBox().enlarge(2) + m_track.getModifiedRegion();- invalidate();+ invalidate(); // should use bbox?}assert(stroke);m_track.clear();diff --git a/toonz/sources/toonzlib/strokegenerator.cpp b/toonz/sources/toonzlib/strokegenerator.cppindex f1e6b99e4..ff5dd796c 100644--- a/toonz/sources/toonzlib/strokegenerator.cpp+++ b/toonz/sources/toonzlib/strokegenerator.cpp@@ -13,7 +13,9 @@ using namespace std;void StrokeGenerator::clear() {m_points.clear();- m_modifiedRegion = TRectD();+ m_modifiedRegion = TRectD();+ m_lastPointRect.empty();+ m_lastModifiedRegion.empty();m_paintedPointCount = 0;m_p0 = m_p1 = TPointD();}@@ -30,6 +32,7 @@ void StrokeGenerator::add(const TThickPoint &point, double pixelSize2) {m_points.push_back(point);TRectD rect(x - d, y - d, x + d, y + d);m_modifiedRegion = rect;+ m_lastPointRect = rect;m_lastModifiedRegion = rect;m_p0 = m_p1 = point;} else {@@ -39,7 +42,8 @@ void StrokeGenerator::add(const TThickPoint &point, double pixelSize2) {double d = std::max(point.thick, lastPoint.thick) + 3;TRectD rect(TRectD(lastPoint, point).enlarge(d));m_modifiedRegion += rect;- m_lastModifiedRegion += rect;+ m_lastModifiedRegion = m_lastPointRect + rect;+ m_lastPointRect = rect;} else {m_points.back().thick = std::max(m_points.back().thick, point.thick);}@@ -251,11 +255,7 @@ void StrokeGenerator::removeMiddlePoints() {//--------------------------------------------------------------------TRectD StrokeGenerator::getLastModifiedRegion() {- TRectD lastModifiedRegion = m_lastModifiedRegion;- m_lastModifiedRegion.empty();- return lastModifiedRegion;-}+TRectD StrokeGenerator::getLastModifiedRegion() { return m_lastModifiedRegion; }//-------------------------------------------------------------------