mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
Merge pull request #97843 from detomon/optimize-a-star-grid-2d-solve
Reduce allocations when solving path in `AStarGrid2D`
This commit is contained in:
@@ -503,6 +503,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point, bool p_allow_
|
|||||||
|
|
||||||
LocalVector<Point *> open_list;
|
LocalVector<Point *> open_list;
|
||||||
SortArray<Point *, SortPoints> sorter;
|
SortArray<Point *, SortPoints> sorter;
|
||||||
|
LocalVector<Point *> nbors;
|
||||||
|
|
||||||
p_begin_point->g_score = 0;
|
p_begin_point->g_score = 0;
|
||||||
p_begin_point->f_score = _estimate_cost(p_begin_point->id, p_end_point->id);
|
p_begin_point->f_score = _estimate_cost(p_begin_point->id, p_end_point->id);
|
||||||
@@ -528,7 +529,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point, bool p_allow_
|
|||||||
open_list.remove_at(open_list.size() - 1);
|
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.
|
||||||
|
|
||||||
LocalVector<Point *> nbors;
|
nbors.clear();
|
||||||
_get_nbors(p, nbors);
|
_get_nbors(p, nbors);
|
||||||
|
|
||||||
for (Point *e : nbors) {
|
for (Point *e : nbors) {
|
||||||
|
|||||||
Reference in New Issue
Block a user