fixed bugs in polygon_path_finder for finding nearest points
This commit is contained in:
parent
a36a774897
commit
8ff61b4d0e
|
@ -142,6 +142,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
|
||||||
if (d<closest_dist) {
|
if (d<closest_dist) {
|
||||||
ignore_from_edge=E->get();
|
ignore_from_edge=E->get();
|
||||||
closest_dist=d;
|
closest_dist=d;
|
||||||
|
closest_point=closest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +169,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
|
||||||
if (d<closest_dist) {
|
if (d<closest_dist) {
|
||||||
ignore_to_edge=E->get();
|
ignore_to_edge=E->get();
|
||||||
closest_dist=d;
|
closest_dist=d;
|
||||||
|
closest_point=closest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +531,7 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2& p_point) const {
|
||||||
|
|
||||||
float d = p_point.distance_squared_to(points[i].pos);
|
float d = p_point.distance_squared_to(points[i].pos);
|
||||||
if (d<closest_dist) {
|
if (d<closest_dist) {
|
||||||
d=closest_dist;
|
closest_dist=d;
|
||||||
closest_idx=i;
|
closest_idx=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue