summaryrefslogtreecommitdiffhomepage
path: root/src/path-search.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/path-search.hpp')
-rw-r--r--src/path-search.hpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/path-search.hpp b/src/path-search.hpp
index bb72d87e..775cb618 100644
--- a/src/path-search.hpp
+++ b/src/path-search.hpp
@@ -12,6 +12,8 @@
#include <Corrade/Containers/BitArray.h>
#include <Corrade/Containers/StridedDimensions.h>
#include <Magnum/Math/Vector2.h>
+#include <Magnum/DimensionTraits.h>
+
namespace Corrade::Containers {
template<typename T> class Optional;
@@ -52,6 +54,14 @@ enum class path_search_continue : bool { pass = false, blocked = true };
class path_search final
{
+ // todo bucketize by array length
+ path_search_result* pool = nullptr;
+
+public:
+ static constexpr int subdivide_factor = 4;
+ static constexpr auto min_size = iTILE_SIZE2 / subdivide_factor / 2;
+ static constexpr size_t tile_count = Vector2i(subdivide_factor * TILE_MAX_DIM).product();
+
struct neighbors final
{
auto begin() const { return neighbors.data(); }
@@ -63,7 +73,7 @@ class path_search final
struct chunk_tiles_cache
{
- std::bitset<TILE_COUNT> can_go_north{true}, can_go_west{true};
+ std::bitset<tile_count> can_go_north{true}, can_go_west{true};
};
struct chunk_cache
@@ -74,14 +84,10 @@ class path_search final
struct obj_position { Vector2 center, size; };
- // todo bucketize by array length
- path_search_result* pool = nullptr;
-
-public:
chunk_cache cache;
Array<global_coords> output;
- struct bbox { Vector2 min, max; };
+ template<typename T> struct bbox { VectorTypeFor<2, T> min, max; };
using pred = fu2::function_view<path_search_continue(collision_data) const>;
static const pred& never_continue() noexcept;
@@ -102,8 +108,8 @@ public:
static bool is_passable(world& w, chunk_coords_ ch0, Vector2 min, Vector2 max, object_id own_id, const pred& p = never_continue());
static bool is_passable(world& w, global_coords coord, Vector2b offset, Vector2ub size, object_id own_id, const pred& p = never_continue());
- static bbox make_neighbor_tile_bbox(Vector2i coord, Vector2ub own_size, rotation r);
- static bbox bbox_union(bbox bb, Vector2i coord, Vector2b offset, Vector2ub size);
+ static bbox<float> make_neighbor_tile_bbox(Vector2i coord, Vector2ub own_size, Vector2ub div, rotation r);
+ static bbox<float> bbox_union(bbox<float> bb, Vector2i coord, Vector2b offset, Vector2ub size);
static neighbors get_walkable_neighbor_tiles(world& w, global_coords coord, Vector2ub size, object_id own_id, const pred& p = never_continue());
};