Commit 92de02b1 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Added checks for 'zero'ness of the scale of the brush

When using tablet, the last events coming from it are almost zero,
so the resulting scale is zero as well. Default mask generator will get
crazy if it gets zero scale due to division by zero. So we need to check
in most of the tools whether the scale is not zero.

BUG:289145
parent 9aabe12b
......@@ -87,6 +87,8 @@ qreal KisComplexOp::paintAt(const KisPaintInformation& info)
return 1.0;
qreal scale = m_sizeOption.apply(info);
if ((scale * brush->width()) <= 0.01 || (scale * brush->height()) <= 0.01) return spacing(info.pressure());
KisPaintDeviceSP device = painter()->device();
......
......@@ -127,6 +127,8 @@ qreal KisDuplicateOp::paintAt(const KisPaintInformation& info)
return 1.0;
qreal scale = m_sizeOption.apply(info);
if ((scale * brush->width()) <= 0.01 || (scale * brush->height()) <= 0.01) return spacing(info.pressure());
QPointF hotSpot = brush->hotSpot(scale, scale);
QPointF pt = info.pos() - hotSpot;
......
......@@ -105,6 +105,9 @@ qreal KisDeformPaintOp::paintAt(const KisPaintInformation& info)
}
qreal rotation = m_rotationOption.apply(info);
// Deform Brush is capable of working with zero scale,
// so no additional checks for 'zero'ness are needed
qreal scale = m_sizeOption.apply(info);
setCurrentRotation(rotation);
......
......@@ -125,6 +125,8 @@ KisDistanceInformation KisHairyPaintOp::paintLine(const KisPaintInformation &pi1
m_dab->clear();
}
// Hairy Brush is capable of working with zero scale,
// so no additional checks for 'zero'ness are needed
qreal scale = m_sizeOption.apply(pi2);
qreal rotation = m_rotationOption.apply(pi2);
quint8 origOpacity = m_opacityOption.apply(painter(), pi2);
......
......@@ -134,6 +134,11 @@ KisDistanceInformation KisSketchPaintOp::paintLine(const KisPaintInformation& pi
const double currentLineWidth = m_lineWidthOption.apply(pi2, m_sketchProperties.lineWidth);
const double currentOffsetScale = m_offsetScaleOption.apply(pi2, m_sketchProperties.offset);
KisVector2D endVec = toKisVector2D(pi2.pos());
KisVector2D startVec = toKisVector2D(pi1.pos());
KisVector2D dragVec = endVec - startVec;
if ((scale * m_brush->width()) <= 0.01 || (scale * m_brush->height()) <= 0.01) return KisDistanceInformation(0, dragVec.norm());;
// shaded: does not draw this line, chrome does, fur does
if (m_sketchProperties.makeConnection){
drawConnection(prevMouse, mousePosition, currentLineWidth);
......@@ -262,10 +267,6 @@ KisDistanceInformation KisSketchPaintOp::paintLine(const KisPaintInformation& pi
painter()->renderMirrorMask(rc, m_dab);
painter()->setOpacity(origOpacity);
KisVector2D end = toKisVector2D(pi2.pos());
KisVector2D start = toKisVector2D(pi1.pos());
KisVector2D dragVec = end - start;
return KisDistanceInformation(0, dragVec.norm());
}
......
......@@ -92,6 +92,8 @@ qreal KisSprayPaintOp::paintAt(const KisPaintInformation& info)
qreal rotation = m_rotationOption.apply(info);
quint8 origOpacity = m_opacityOption.apply(painter(), info);
// Spray Brush is capable of working with zero scale,
// so no additional checks for 'zero'ness are needed
qreal scale = m_sizeOption.apply(info);
setCurrentRotation(rotation);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment