summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-24 11:20:43 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-24 11:20:43 +0100
commita3d2775168f28cf294800b2a873ac20e3a87ddad (patch)
treea58e92d199d4c59040b066a4740cbcf1165e0476 /src
parent6a71040c0b28a5b9520d59b6c1d5fa51956e2b5f (diff)
w
Diffstat (limited to 'src')
-rw-r--r--src/search-astar.hpp2
-rw-r--r--src/search-node.hpp10
-rw-r--r--src/search-result.hpp25
3 files changed, 24 insertions, 13 deletions
diff --git a/src/search-astar.hpp b/src/search-astar.hpp
index c31b348f..ea150c76 100644
--- a/src/search-astar.hpp
+++ b/src/search-astar.hpp
@@ -11,7 +11,7 @@ namespace floormat {
class world;
struct point;
-struct path_search_result;
+class path_search_result;
class astar
{
diff --git a/src/search-node.hpp b/src/search-node.hpp
index c2977f84..c911e735 100644
--- a/src/search-node.hpp
+++ b/src/search-node.hpp
@@ -1,14 +1,21 @@
#pragma once
#include "compat/defs.hpp"
#include "search-result.hpp"
+#include "point.hpp"
#include <vector>
#include <Corrade/Containers/Pointer.h>
namespace floormat {
+struct path_search_result::pair
+{
+ point pt;
+ uint32_t length = 0;
+};
+
struct path_search_result::node
{
- friend struct path_search_result;
+ friend class path_search_result;
friend struct test_app;
node() noexcept;
@@ -16,6 +23,7 @@ struct path_search_result::node
fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(node);
std::vector<point> vec;
+ std::vector<pair> vec_;
private:
Pointer<node> _next;
diff --git a/src/search-result.hpp b/src/search-result.hpp
index 257d25a3..fc5397a0 100644
--- a/src/search-result.hpp
+++ b/src/search-result.hpp
@@ -8,10 +8,20 @@ namespace floormat {
struct point;
-struct path_search_result final
+class path_search_result final
{
friend struct test_app;
+ struct pair;
+ struct node;
+ Pointer<node> _node;
+ float _time = 0;
+ uint32_t _cost = 0, _distance = (uint32_t)-1;
+ bool _found : 1 = false;
+
+ static Pointer<node> _pool; // NOLINT(*-avoid-non-const-global-variables)
+
+public:
const point* data() const;
const point& operator[](size_t index) const;
size_t size() const;
@@ -23,8 +33,11 @@ struct path_search_result final
void set_found(bool value);
uint32_t distance() const;
void set_distance(uint32_t dist);
+ bool is_simplified() const;
+ const pair& simplified();
vector_wrapper<point, vector_wrapper_repr::ref> raw_path();
+ vector_wrapper<point, vector_wrapper_repr::ref> raw_simplified_path();
ArrayView<const point> path() const;
explicit operator ArrayView<const point>() const;
explicit operator bool() const;
@@ -35,16 +48,6 @@ struct path_search_result final
path_search_result(path_search_result&&) noexcept;
path_search_result& operator=(path_search_result&&) noexcept;
~path_search_result() noexcept;
-
-private:
- struct node;
-
- static Pointer<node> _pool; // NOLINT(*-avoid-non-const-global-variables)
-
- Pointer<node> _node;
- float _time = 0;
- uint32_t _cost = 0, _distance = (uint32_t)-1;
- bool _found : 1 = false;
};
} // namespace floormat