diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-09 05:25:16 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-09 05:25:16 +0200 |
commit | 0e9ecb5c33e35a9adceea97de637db133ffa9dbf (patch) | |
tree | c376a086ad0d268e9ab1a8ad8c14009fefc7d4d3 /src/path-search-dijkstra.cpp | |
parent | e93021bccd1f6c3d3019f8108cb2471ed926d7a6 (diff) |
a
Diffstat (limited to 'src/path-search-dijkstra.cpp')
-rw-r--r-- | src/path-search-dijkstra.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp index 417b1b55..cec44225 100644 --- a/src/path-search-dijkstra.cpp +++ b/src/path-search-dijkstra.cpp @@ -264,17 +264,23 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o if (dist >= max_dist) continue; - #ifdef FM_ASTAR_NO_EDGE_CACHE + const auto new_pt = point{.coord = new_coord, .offset = new_offset}; + + if (auto it = indexes.find(new_pt); it != indexes.end()) + if (nodes[it->second].dist >= dist) + continue; + +#ifdef FM_ASTAR_NO_EDGE_CACHE { auto vec_ = Vector2(vec); auto bb1 = bbox<float>{ bb0.min + vec_, bb0.max + vec_ }; auto bb = bbox_union(bb1, bb0); if (!path_search::is_passable(w, chunk_coords_(new_coord), bb, own_id, p)) continue; } - #endif +#endif const auto sz = nodes.size(); - auto [it, fresh] = indexes.try_emplace({.coord = new_coord, .offset = new_offset}, sz); + auto [it, fresh] = indexes.try_emplace(new_pt, sz); const auto new_idx = it.value(); if (new_idx == sz) |