src/glRenderer.cc

changeset 717
fdc285e5952f
parent 715
56f1b77951c8
child 718
a2cbef633673
equal deleted inserted replaced
716:639a900999bc 717:fdc285e5952f
1009 Vertex closest; 1009 Vertex closest;
1010 bool valid = false; 1010 bool valid = false;
1011 1011
1012 QPoint curspos = coordconv3_2 (m_hoverpos); 1012 QPoint curspos = coordconv3_2 (m_hoverpos);
1013 1013
1014 for (const Vertex& pos3d: m_knownVerts) 1014 for (auto it = document()->vertices().begin(); it != document()->vertices().end(); ++it)
1015 { 1015 {
1016 QPoint pos2d = coordconv3_2 (pos3d); 1016 QPoint pos2d = coordconv3_2 (it.key());
1017 1017
1018 // Measure squared distance 1018 // Measure squared distance
1019 const double dx = abs (pos2d.x() - curspos.x()), 1019 const double dx = abs (pos2d.x() - curspos.x()),
1020 dy = abs (pos2d.y() - curspos.y()), 1020 dy = abs (pos2d.y() - curspos.y()),
1021 distsq = (dx * dx) + (dy * dy); 1021 distsq = (dx * dx) + (dy * dy);
1024 continue; // too far away 1024 continue; // too far away
1025 1025
1026 if (distsq < mindist) 1026 if (distsq < mindist)
1027 { 1027 {
1028 mindist = distsq; 1028 mindist = distsq;
1029 closest = pos3d; 1029 closest = it.key();
1030 valid = true; 1030 valid = true;
1031 1031
1032 // If it's only 4 pixels away, I think we found our vertex now. 1032 // If it's only 4 pixels away, I think we found our vertex now.
1033 if (distsq <= 16.0f) // 4.0f ** 2 1033 if (distsq <= 16.0f) // 4.0f ** 2
1034 break; 1034 break;

mercurial