mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
NavMap::get_path Fix not resetting least_cost_id
This commit is contained in:
parent
12cb05b304
commit
9ab69b89f8
1 changed files with 3 additions and 2 deletions
|
@ -226,6 +226,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
|
||||||
navigation_polys.push_back(np);
|
navigation_polys.push_back(np);
|
||||||
to_visit.clear();
|
to_visit.clear();
|
||||||
to_visit.push_back(0);
|
to_visit.push_back(0);
|
||||||
|
least_cost_id = 0;
|
||||||
|
|
||||||
reachable_end = nullptr;
|
reachable_end = nullptr;
|
||||||
|
|
||||||
|
@ -245,6 +246,8 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ERR_BREAK(least_cost_id == -1);
|
||||||
|
|
||||||
// Stores the further reachable end polygon, in case our goal is not reachable.
|
// Stores the further reachable end polygon, in case our goal is not reachable.
|
||||||
if (is_reachable) {
|
if (is_reachable) {
|
||||||
float d = navigation_polys[least_cost_id].entry.distance_to(p_destination);
|
float d = navigation_polys[least_cost_id].entry.distance_to(p_destination);
|
||||||
|
@ -254,8 +257,6 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ERR_BREAK(least_cost_id == -1);
|
|
||||||
|
|
||||||
// Check if we reached the end
|
// Check if we reached the end
|
||||||
if (navigation_polys[least_cost_id].poly == end_poly) {
|
if (navigation_polys[least_cost_id].poly == end_poly) {
|
||||||
found_route = true;
|
found_route = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue