diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2023-01-27 18:52:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-27 18:52:22 +0300 |
commit | 0f8f0ab126437ed593e6463b85a6ee25af9ee5d4 (patch) | |
tree | f3db448e649b937d5208e6643110141e173f963b /core/math/a_star.cpp | |
parent | 1bf7b84fbff4ff648ea0f56842cf287724a1c9b8 (diff) | |
parent | cc0a243ce0b459843667dbfd48be440ed7e275a6 (diff) | |
download | redot-engine-0f8f0ab126437ed593e6463b85a6ee25af9ee5d4.tar.gz |
Merge pull request #72170 from Chaosus/astar_fix
Diffstat (limited to 'core/math/a_star.cpp')
-rw-r--r-- | core/math/a_star.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 646bdea758..f0f160940d 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -327,7 +327,7 @@ bool AStar3D::_solve(Point *begin_point, Point *end_point) { bool found_route = false; - Vector<Point *> open_list; + LocalVector<Point *> open_list; SortArray<Point *, SortPoints> sorter; begin_point->g_score = 0; @@ -335,19 +335,19 @@ bool AStar3D::_solve(Point *begin_point, Point *end_point) { open_list.push_back(begin_point); while (!open_list.is_empty()) { - Point *p = open_list[0]; // The currently processed point + Point *p = open_list[0]; // The currently processed point. if (p == end_point) { found_route = true; break; } - sorter.pop_heap(0, open_list.size(), open_list.ptrw()); // Remove the current point from the open list + sorter.pop_heap(0, open_list.size(), open_list.ptr()); // Remove the current point from the open list. open_list.remove_at(open_list.size() - 1); - p->closed_pass = pass; // Mark the point as closed + p->closed_pass = pass; // Mark the point as closed. for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { - Point *e = *(it.value); // The neighbor point + Point *e = *(it.value); // The neighbor point. if (!e->enabled || e->closed_pass == pass) { continue; @@ -370,9 +370,9 @@ bool AStar3D::_solve(Point *begin_point, Point *end_point) { e->f_score = e->g_score + _estimate_cost(e->id, end_point->id); if (new_point) { // The position of the new points is already known. - sorter.push_heap(0, open_list.size() - 1, 0, e, open_list.ptrw()); + sorter.push_heap(0, open_list.size() - 1, 0, e, open_list.ptr()); } else { - sorter.push_heap(0, open_list.find(e), 0, e, open_list.ptrw()); + sorter.push_heap(0, open_list.find(e), 0, e, open_list.ptr()); } } } |