From f5038f16a15cdd4579417ef499bb8ddcb9fc6269 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 4 Feb 2024 13:21:27 +0100 Subject: a --- src/path-search.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/path-search.cpp') diff --git a/src/path-search.cpp b/src/path-search.cpp index 94da7f10..739826be 100644 --- a/src/path-search.cpp +++ b/src/path-search.cpp @@ -7,11 +7,12 @@ namespace floormat { +using namespace detail_astar; + namespace { -constexpr auto div = path_search::div_factor; constexpr int div_BITS = 2; -static_assert(1 << div_BITS == div); +static_assert(1 << div_BITS == div_factor); constexpr auto never_continue_1 = [](collision_data) constexpr { return path_search_continue::blocked; }; constexpr auto never_continue_ = path_search::pred{never_continue_1}; @@ -84,31 +85,32 @@ bool path_search::is_passable_(chunk* c0, const std::array& bb, object_id own_id, const pred& p) { - return is_passable(w, coord, offset, Vector2ui(size), own_id, p); + auto* c = w.at(ch); + auto neighbors = w.neighbors(ch); + return is_passable_(c, neighbors, bb.min, bb.max, own_id, p); } -bool path_search::is_passable(world& w, chunk_coords_ ch, const bbox& bb, object_id own_id, const pred& p) +bool path_search::is_passable(world& w, struct detail_astar::cache& cache, chunk_coords_ ch0, const bbox& bb, object_id own_id, const pred& p) { - return is_passable(w, ch, bb.min, bb.max, own_id, p); + fm_debug_assert(!cache.size.isZero()); + std::array neighbors; + for (auto i = 0uz; const auto& x : world::neighbor_offsets) + { + auto ch = ch0 + x; + neighbors[i++] = { cache.try_get_chunk(w, ch), ch0 }; + } + return is_passable_(cache.try_get_chunk(w, ch0), neighbors, bb.min, bb.max, own_id, p); } } // namespace floormat -- cgit v1.2.3