diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dijkstra.cpp | 2 | ||||
-rw-r--r-- | src/path-search-bbox.hpp | 25 | ||||
-rw-r--r-- | src/path-search.cpp | 1 | ||||
-rw-r--r-- | src/path-search.hpp | 25 |
4 files changed, 31 insertions, 22 deletions
diff --git a/src/dijkstra.cpp b/src/dijkstra.cpp index f3b07172..4ec71248 100644 --- a/src/dijkstra.cpp +++ b/src/dijkstra.cpp @@ -1,8 +1,10 @@ #include "astar.hpp" +#include "path-search-bbox.hpp" #include "compat/format.hpp" #include "compat/vector-wrapper.hpp" #include "compat/heap.hpp" #include "object.hpp" +#include "world.hpp" #include "point.hpp" #include <cstdio> #include <Corrade/Containers/GrowableArray.h> diff --git a/src/path-search-bbox.hpp b/src/path-search-bbox.hpp new file mode 100644 index 00000000..05ed726d --- /dev/null +++ b/src/path-search-bbox.hpp @@ -0,0 +1,25 @@ +#pragma once +#include "path-search.hpp" +#include <concepts> +#include <Magnum/Math/Vector2.h> +#include <Magnum/DimensionTraits.h> + +namespace floormat::detail_astar { + +template<typename T> struct bbox +{ + static_assert(std::is_arithmetic_v<T>); + + VectorTypeFor<2, T> min, max; + + constexpr bool operator==(const bbox<T>&) const = default; + + template<typename U> + requires std::is_arithmetic_v<U> + explicit constexpr operator bbox<U>() const { + using Vec = VectorTypeFor<2, U>; + return bbox<U>{ Vec(min), Vec(max) }; + } +}; + +} // namespace floormat::detail_astar diff --git a/src/path-search.cpp b/src/path-search.cpp index 54f0b112..615b040e 100644 --- a/src/path-search.cpp +++ b/src/path-search.cpp @@ -1,4 +1,5 @@ #include "path-search.hpp" +#include "path-search-bbox.hpp" #include "astar.hpp" #include "global-coords.hpp" #include "world.hpp" diff --git a/src/path-search.hpp b/src/path-search.hpp index 3a32dbff..c48b5532 100644 --- a/src/path-search.hpp +++ b/src/path-search.hpp @@ -2,13 +2,10 @@ #include "tile-constants.hpp" #include "global-coords.hpp" #include "object-id.hpp" -#include "world.hpp" +#include "collision.hpp" #include "compat/function2.fwd.hpp" #include "path-search-result.hpp" -#include <concepts> #include <array> -#include <Magnum/Math/Vector2.h> -#include <Magnum/DimensionTraits.h> namespace floormat { class world; @@ -20,6 +17,7 @@ class chunk; namespace floormat::detail_astar { +template<typename T> struct bbox; struct cache; struct chunk_cache; static constexpr int div_factor = 4; @@ -36,24 +34,9 @@ enum class path_search_continue : bool { pass = false, blocked = true }; class path_search final { friend struct path_search_result; + template<typename T> using bbox = detail_astar::bbox<T>; public: - template<typename T> - requires std::is_arithmetic_v<T> - struct bbox - { - VectorTypeFor<2, T> min, max; - - template<typename U> - requires std::is_arithmetic_v<U> - explicit constexpr operator bbox<U>() const { - using Vec = VectorTypeFor<2, U>; - return bbox<U>{ Vec(min), Vec(max) }; - } - - constexpr bool operator==(const bbox<T>&) const = default; - }; - using pred = fu2::function_view<path_search_continue(collision_data) const>; static const pred& never_continue() noexcept; @@ -68,6 +51,4 @@ public: static bool is_passable(world& w, struct detail_astar::cache& cache, chunk_coords_ ch0, const bbox<float>& bb, object_id own_id, const pred& p = never_continue()); }; - - } // namespace floormat |