diff --git a/toonz/sources/toonzlib/stagevisitor.cpp b/toonz/sources/toonzlib/stagevisitor.cpp index b73077e..9f45f51 100644 --- a/toonz/sources/toonzlib/stagevisitor.cpp +++ b/toonz/sources/toonzlib/stagevisitor.cpp @@ -250,9 +250,25 @@ void Picker::onImage(const Stage::Player &player) { if (r) styleId = r->getStyle(); if (styleId != 0) picked = true; - else if (vi->getNearestStroke(point, w, strokeIndex, dist2) && - dist2 < m_minDist2) - picked = true; + else if (vi->getNearestStroke(point, w, strokeIndex, dist2)) { + // based on TTool::Viewer::doPickGuideStroke + + // m_minDist2 seems to be the pixel size to the power 4, so take the + // square root of the square root. + // Use abs() just in case m_minDist2 is negative, to avoid math errors. + double pixelSize = sqrt(sqrt(abs(m_minDist2))); + double maxDist = 5 * pixelSize; + double maxDist2 = maxDist * maxDist; + double checkDist = maxDist2 * 4; + + TStroke *stroke = vi->getStroke(strokeIndex); + TThickPoint thickPoint = stroke->getThickPoint(w); + double thickness = thickPoint.thick; + double len = thickness * pixelSize * sqrt(m_viewAff.det()); + checkDist = std::max(checkDist, (len * len)); + if (dist2 < checkDist) + picked = true; + } } else if (TRasterImageP ri = img) { TRaster32P ras = ri->getRaster(); if (!ras) return;