Patch from Chris Moore to improve the generality of

grid_nearest_edge(), by having it search harder for a better dot to
move to in the first loop.

[originally from svn r9106]
This commit is contained in:
Simon Tatham
2011-02-23 20:05:40 +00:00
parent b2e4437d5b
commit 1a628aebd8

6
grid.c
View File

@ -141,13 +141,11 @@ grid_edge *grid_nearest_edge(grid *g, int x, int y)
grid_dot *d = f->dots[j]; grid_dot *d = f->dots[j];
if (d == cur) continue; if (d == cur) continue;
new_dist = SQ((long)d->x - (long)x) + SQ((long)d->y - (long)y); new_dist = SQ((long)d->x - (long)x) + SQ((long)d->y - (long)y);
if (new_dist < dist) { if (new_dist < dist) { /* found closer dot */
new = d; new = d;
break; /* found closer dot */ dist = new_dist;
} }
} }
if (new != cur)
break; /* found closer dot */
} }
if (new == cur) { if (new == cur) {