From 9e57df3c35bbdf5dd5851e57521b1a64b8a89b9c Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Aug 09 2023 05:10:40 +0000 Subject: #assistants: tr: m_painting.mypaint.brush --- diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp index aa2fd74..12c78db 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp +++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp @@ -1343,17 +1343,15 @@ void ToonzRasterBrushTool::leftButtonDown(const TPointD &pos, mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC, baseSize + modifierSize); } - m_toonz_brush = - new MyPaintToonzBrush(m_workRas, *this, mypaintBrush, true); + m_painting.myPaint.brush = new MyPaintToonzBrush(m_workRas, *this, mypaintBrush); m_strokeRect.empty(); m_strokeSegmentRect.empty(); - m_toonz_brush->beginStroke(); - m_toonz_brush->strokeTo(point, pressure, TPointD(), restartBrushTimer()); + m_painting.myPaint.brush->beginStroke(); + m_painting.myPaint.brush->strokeTo(point, pressure, TPointD(), restartBrushTimer()); TRect updateRect = m_strokeSegmentRect * ras->getBounds(); if (!updateRect.isEmpty()) { - // ras->extract(updateRect)->copy(m_workRas->extract(updateRect)); - m_toonz_brush->updateDrawing(ri->getRaster(), m_backupRas, m_strokeRect, - m_painting.styleId, m_modifierLockAlpha.getValue()); + m_painting.myPaint.brush->updateDrawing( ri->getRaster(), m_backupRas, m_strokeRect, + m_painting.styleId, m_modifierLockAlpha.getValue() ); } m_lastRect = m_strokeRect; @@ -1501,12 +1499,11 @@ void ToonzRasterBrushTool::leftButtonDrag(const TPointD &pos, TPointD point(centeredPos + rasCenter); m_strokeSegmentRect.empty(); - m_toonz_brush->strokeTo(point, pressure, TPointD(), restartBrushTimer()); + m_painting.myPaint.brush->strokeTo(point, pressure, TPointD(), restartBrushTimer()); TRect updateRect = m_strokeSegmentRect * ras->getBounds(); if (!updateRect.isEmpty()) { - // ras->extract(updateRect)->copy(m_workRaster->extract(updateRect)); - m_toonz_brush->updateDrawing(ras, m_backupRas, m_strokeSegmentRect, - m_painting.styleId, m_modifierLockAlpha.getValue()); + m_painting.myPaint.brush->updateDrawing( ras, m_backupRas, m_strokeSegmentRect, + m_painting.styleId, m_modifierLockAlpha.getValue() ); } m_lastRect = m_strokeRect; @@ -1671,13 +1668,12 @@ void ToonzRasterBrushTool::finishRasterBrush(const TPointD &pos, double pressure = m_pressure.getValue() ? pressureVal : 0.5; m_strokeSegmentRect.empty(); - m_toonz_brush->strokeTo(point, pressure, TPointD(), restartBrushTimer()); - m_toonz_brush->endStroke(); + m_painting.myPaint.brush->strokeTo(point, pressure, TPointD(), restartBrushTimer()); + m_painting.myPaint.brush->endStroke(); TRect updateRect = m_strokeSegmentRect * ras->getBounds(); if (!updateRect.isEmpty()) { - // ras->extract(updateRect)->copy(m_workRaster->extract(updateRect)); - m_toonz_brush->updateDrawing(ras, m_backupRas, m_strokeSegmentRect, - m_painting.styleId, m_modifierLockAlpha.getValue()); + m_painting.myPaint.brush->updateDrawing( ras, m_backupRas, m_strokeSegmentRect, + m_painting.styleId, m_modifierLockAlpha.getValue() ); } TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5); // TODO @@ -1685,10 +1681,8 @@ void ToonzRasterBrushTool::finishRasterBrush(const TPointD &pos, invalidateRect += TRectD(pos - thickOffset, pos + thickOffset); invalidate(invalidateRect.enlarge(2.0)); - if (m_toonz_brush) { - delete m_toonz_brush; - m_toonz_brush = 0; - } + delete m_painting.myPaint.brush; + m_painting.myPaint.brush = nullptr; m_lastRect.empty(); m_workRas->unlock(); diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.h b/toonz/sources/tnztools/toonzrasterbrushtool.h index f760b3d..453dd7b 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.h +++ b/toonz/sources/tnztools/toonzrasterbrushtool.h @@ -186,7 +186,7 @@ protected: TTileSaverCM32 *tileSaver = nullptr; struct MyPaint { - + MyPaintToonzBrush *brush = nullptr; } myPaint; // straight variables @@ -245,7 +245,6 @@ protected: ToonzRasterBrushToolNotifier *m_notifier; bool m_isMyPaintStyleSelected = false; - MyPaintToonzBrush *m_toonz_brush = 0; QElapsedTimer m_brushTimer; int m_minCursorThick, m_maxCursorThick;