summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-04-14 21:28:07 +0200
committerGitHub <noreply@github.com>2022-04-14 21:28:07 +0200
commit97a8d0785700d4c89a58bac442651725d84b5e83 (patch)
tree5afdcc387876f2ce29ce1046f3877f5adf6363fa
parent7a4c203ce932d0f3e1f8a16bc0a7544eee95badd (diff)
parent9ab69b89f865b57282507da1780a53bf0998b79c (diff)
Merge pull request #60241 from kleonc/navmap-reset-least_cost_id
`NavMap::get_path` Fix not resetting `least_cost_id`
-rw-r--r--modules/navigation/nav_map.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp
index 70d50999f9..217e503d82 100644
--- a/modules/navigation/nav_map.cpp
+++ b/modules/navigation/nav_map.cpp
@@ -226,6 +226,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p
navigation_polys.push_back(np);
to_visit.clear();
to_visit.push_back(0);
+ least_cost_id = 0;
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.
if (is_reachable) {
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
if (navigation_polys[least_cost_id].poly == end_poly) {
found_route = true;