summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-24 05:16:58 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-24 05:16:58 +0100
commitdb09342af865ac5df7d4c35f25115ed39fbd0ddd (patch)
tree06216a603a8d1629c690e8dd6ef0ce06eae965cd
parentee2f8ee5e5d4e97d7dcaaaf2d7753d1fb6deeadd (diff)
src: split bbox into its own header
-rw-r--r--bench/dijkstra.cpp1
-rw-r--r--src/dijkstra.cpp2
-rw-r--r--src/path-search-bbox.hpp25
-rw-r--r--src/path-search.cpp1
-rw-r--r--src/path-search.hpp25
-rw-r--r--test/dijkstra.cpp1
-rw-r--r--test/path-search.cpp4
7 files changed, 35 insertions, 24 deletions
diff --git a/bench/dijkstra.cpp b/bench/dijkstra.cpp
index 0c771528..8567796a 100644
--- a/bench/dijkstra.cpp
+++ b/bench/dijkstra.cpp
@@ -1,5 +1,6 @@
#include "src/astar.hpp"
#include "src/path-search-result.hpp"
+#include "src/world.hpp"
#include "loader/loader.hpp"
#include <benchmark/benchmark.h>
#include <Corrade/Containers/Optional.h>
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
diff --git a/test/dijkstra.cpp b/test/dijkstra.cpp
index b608f5fe..14015ade 100644
--- a/test/dijkstra.cpp
+++ b/test/dijkstra.cpp
@@ -1,5 +1,6 @@
#include "app.hpp"
#include "src/astar.hpp"
+#include "src/world.hpp"
#include "loader/loader.hpp"
#include "loader/wall-cell.hpp"
#include <Magnum/Math/Functions.h>
diff --git a/test/path-search.cpp b/test/path-search.cpp
index caaa55f2..99a2b0a8 100644
--- a/test/path-search.cpp
+++ b/test/path-search.cpp
@@ -5,14 +5,14 @@
#include "loader/wall-cell.hpp"
#include "src/world.hpp"
#include "src/scenery.hpp"
-#include "src/path-search.hpp"
+#include "src/path-search-bbox.hpp"
#include <Magnum/Math/Functions.h>
namespace floormat {
using namespace floormat::detail_astar;
-template<typename T> using bbox = path_search::bbox<T>;
using pred = path_search::pred;
+using detail_astar::bbox;
namespace {