diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-22 20:04:30 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-22 20:04:30 +0200 |
commit | 7a7a7a79d03902ddab6484ac3566ef3b9f7e8fec (patch) | |
tree | 936e8172e6e76c30c2280140a560912526810933 /src/path-search.hpp | |
parent | 0dd45783d24f3c6ebde0fadcd616148c4dfbd97b (diff) |
fix 2 pathfinding bugs
1. bboxes crossing the chunk boundary
2. `max = min + size`, incorrectly was `max = center + size`
Diffstat (limited to 'src/path-search.hpp')
-rw-r--r-- | src/path-search.hpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/path-search.hpp b/src/path-search.hpp index 4ca5b7b4..6391181b 100644 --- a/src/path-search.hpp +++ b/src/path-search.hpp @@ -35,7 +35,21 @@ public: static constexpr auto div_size = iTILE_SIZE2 / div_factor; static constexpr auto min_size = Vector2ui(div_size * 2); - template<typename T> struct bbox { VectorTypeFor<2, T> min, max; }; + 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>; |