diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dijkstra.cpp (renamed from src/path-search-dijkstra.cpp) | 5 | ||||
-rw-r--r-- | src/path-search-result.cpp | 3 | ||||
-rw-r--r-- | src/path-search-result.hpp | 3 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/path-search-dijkstra.cpp b/src/dijkstra.cpp index 995229af..ab654660 100644 --- a/src/path-search-dijkstra.cpp +++ b/src/dijkstra.cpp @@ -4,6 +4,7 @@ #include <Corrade/Containers/StaticArray.h> #include <Magnum/Math/Vector2.h> #include <Magnum/Math/Functions.h> +#include <Magnum/Timeline.h> namespace floormat { @@ -120,6 +121,8 @@ path_search_result astar::Dijkstra(world& w, const point from_, const point to_, (void)debug; #endif + Timeline timeline; timeline.start(); + clear(); cache.allocate(from_, max_dist); @@ -314,6 +317,8 @@ path_search_result astar::Dijkstra(world& w, const point from_, const point to_, result.set_cost(nodes[goal_idx].dist); } + result.set_time(timeline.currentFrameTime()); + return result; } diff --git a/src/path-search-result.cpp b/src/path-search-result.cpp index 202a8457..ea2cc3db 100644 --- a/src/path-search-result.cpp +++ b/src/path-search-result.cpp @@ -59,6 +59,9 @@ path_search_result::node::node() noexcept = default; size_t path_search_result::size() const { return _node->vec.size(); } uint32_t path_search_result::cost() const { return _cost; } void path_search_result::set_cost(uint32_t value) { _cost = value; } +float path_search_result::time() const { return _time; } +void path_search_result::set_time(float time) { _time = time; } + auto path_search_result::data() const -> const point* { return _node->vec.data(); } path_search_result::operator bool() const { return !_node->vec.empty(); } diff --git a/src/path-search-result.hpp b/src/path-search-result.hpp index e6e2d7fd..6ae9b5be 100644 --- a/src/path-search-result.hpp +++ b/src/path-search-result.hpp @@ -17,6 +17,8 @@ struct path_search_result final size_t size() const; uint32_t cost() const; void set_cost(uint32_t value); + float time() const; + void set_time(float time); std::vector<point>& path(); const std::vector<point>& path() const; @@ -50,6 +52,7 @@ private: static std::unique_ptr<node> _pool; // NOLINT(*-avoid-non-const-global-variables) std::unique_ptr<node> _node; + float _time = 0; uint32_t _cost = 0; }; |