From 362c9937dc036d7cf36fdc39c26c05b81bd16799 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Aug 16 2023 15:17:06 +0000 Subject: #assistants: tr: fix pencil --- diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp index 0cfacbf..539368a 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp +++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp @@ -1041,6 +1041,8 @@ void ToonzRasterBrushTool::drawEmptyCircle(TPointD pos, int thick, if (!isPencil) tglDrawCircle(pos, (thick + 1) * 0.5); else { + pos.x = floor(pos.x) + 0.5; + pos.y = floor(pos.y) + 0.5; int x = 0, y = tround((thick * 0.5) - 0.5); int d = 3 - 2 * (int)(thick * 0.5); bool horizontal = true, isDecimal = thick % 2 != 0; @@ -1372,6 +1374,7 @@ void ToonzRasterBrushTool::inputPaintTrackPoint(const TTrackPoint &point, const if (!ras) return; TPointD rasCenter = ras->getCenterD(); + TPointD fixedPosition = getCenteredCursorPos(point.position); TRectD invalidateRect; @@ -1399,7 +1402,7 @@ void ToonzRasterBrushTool::inputPaintTrackPoint(const TTrackPoint &point, const // paint stroke m_painting.myPaint.strokeSegmentRect.empty(); - handler->brush.strokeTo( point.position + rasCenter, point.pressure, + handler->brush.strokeTo( fixedPosition + rasCenter, point.pressure, point.tilt, point.time - track.previous().time ); if (lastPoint) handler->brush.endStroke(); @@ -1421,7 +1424,7 @@ void ToonzRasterBrushTool::inputPaintTrackPoint(const TTrackPoint &point, const double thickness = computeThickness(point.pressure, m_rasThickness)*2; //if (!m_painting.pencil.realPencil && !m_modifierLine->getManager()) // thickness -= 1.0; - TThickPoint thickPoint(point.position + rasCenter, thickness); + TThickPoint thickPoint(fixedPosition + rasCenter, thickness); // init brush PencilStroke *handler; @@ -1480,7 +1483,7 @@ void ToonzRasterBrushTool::inputPaintTrackPoint(const TTrackPoint &point, const // paint stroke double radius = computeThickness(point.pressure, m_rasThickness); - TThickPoint thickPoint(point.position + rasCenter, radius*2); + TThickPoint thickPoint(fixedPosition + rasCenter, radius*2); TRect strokeRect( tfloor(thickPoint.x - maxThick - 0.999), tfloor(thickPoint.y - maxThick - 0.999), tceil(thickPoint.x + maxThick + 0.999), @@ -1503,9 +1506,10 @@ void ToonzRasterBrushTool::inputPaintTrackPoint(const TTrackPoint &point, const // here we will invalidate rects for it double thickness = m_isMyPaintStyleSelected ? m_maxCursorThick : m_maxThick*0.5; TPointD thickOffset(thickness + 1, thickness + 1); - invalidateRect += TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset); - invalidateRect += TRectD(point.position - thickOffset, point.position + thickOffset); - m_brushPos = m_mousePos = point.position; + invalidateRect += TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset); + invalidateRect += TRectD(fixedPosition - thickOffset, fixedPosition + thickOffset); + m_mousePos = point.position; + m_brushPos = fixedPosition; } if (!invalidateRect.isEmpty())