# HG changeset patch # User Santeri Piippo # Date 1375448120 -10800 # Node ID d21b0a61d3b7b36a25d11544ca06f67e76d467b6 # Parent c435027ee5cd924b88301b0334354776e98302a9 If the vertex snapper finds a vertex closer than 4 pixels, it likely is the vertex being looked for and the algorithm can terminate early, hopefully this will save a few cycles on large parts. diff -r c435027ee5cd -r d21b0a61d3b7 src/gldraw.cpp --- a/src/gldraw.cpp Fri Aug 02 13:58:14 2013 +0300 +++ b/src/gldraw.cpp Fri Aug 02 15:55:20 2013 +0300 @@ -822,9 +822,9 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void GLRenderer::mouseReleaseEvent (QMouseEvent* ev) { - const bool wasLeft = (m_lastButtons & Qt::LeftButton) && !(ev->buttons() & Qt::LeftButton); - const bool wasRight = (m_lastButtons & Qt::RightButton) && !(ev->buttons() & Qt::RightButton); - const bool wasMid = (m_lastButtons & Qt::MidButton) && !(ev->buttons() & Qt::MidButton); + const bool wasLeft = (m_lastButtons & Qt::LeftButton) && !(ev->buttons() & Qt::LeftButton), + wasRight = (m_lastButtons & Qt::RightButton) && !(ev->buttons() & Qt::RightButton), + wasMid = (m_lastButtons & Qt::MidButton) && !(ev->buttons() & Qt::MidButton); if (m_panning) m_panning = false; @@ -893,9 +893,9 @@ QPoint pos2d = coordconv3_2 (pos3d); // Measure squared distance - double dx = abs (pos2d.x() - curspos.x()); - double dy = abs (pos2d.y() - curspos.y()); - double distsq = (dx * dx) + (dy * dy); + const double dx = abs (pos2d.x() - curspos.x()), + dy = abs (pos2d.y() - curspos.y()), + distsq = (dx * dx) + (dy * dy); if (distsq >= 1024.0f) // 32.0f ** 2 continue; // too far away @@ -904,6 +904,10 @@ mindist = distsq; closest = pos3d; valid = true; + + /* If it's only 4 pixels away, I think we found our vertex now. */ + if (distsq <= 16.0f) // 4.0f ** 2 + break; } }