Skip to content

Commit 33d3385

Browse files
authored
Merge pull request TeachingTechnologistBeth#46 from joedight/master
Fix worldSpace_linkAt not choosing closest Link
2 parents b19c17d + e84b23c commit 33d3385

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/com/modsim/gui/view/ViewUtil.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,21 @@ public class ViewUtil implements MouseListener, MouseMotionListener, MouseWheelL
3636
* @return Link at point, or null if there is none
3737
*/
3838
public static Link worldSpace_linkAt(Vec2 pt) {
39+
Link closest = null;
40+
double dist = 15.0;
3941
for (Link link : Main.sim.getLinks()) {
4042
Path.PointInfo info = link.path.approxClosestPoint(pt, 6);
4143

42-
if (info.dist < 15.0) {
43-
return link;
44+
if (info.dist < dist) {
45+
if (info.dist < 2.0) {
46+
return link;
47+
}
48+
closest = link;
49+
dist = info.dist;
4450
}
4551
}
4652

47-
return null;
53+
return closest;
4854
}
4955

5056
/**

0 commit comments

Comments
 (0)