summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-10-09 01:04:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-10-09 01:04:52 +0200
commit71360025b4329234248992fcb1700da30a414820 (patch)
treecd766cee3f3b0a7d808d888f33b444b8082f55f5 /src
parent6d7da3689d58cf93b3697814f4637e0e29d3b656 (diff)
a
Diffstat (limited to 'src')
-rw-r--r--src/path-search-dijkstra.cpp23
-rw-r--r--src/path-search.hpp2
2 files changed, 17 insertions, 8 deletions
diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp
index fe0f2b70..5b43e5c9 100644
--- a/src/path-search-dijkstra.cpp
+++ b/src/path-search-dijkstra.cpp
@@ -168,8 +168,8 @@ size_t astar::edge_hash::operator()(const edge& e) const
#endif
}
-path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id own_id, uint32_t max_dist,
- Vector2ub own_size, const pred& p)
+path_search_result astar::Dijkstra(world& w, point from_, point to_,object_id own_id, uint32_t max_dist,
+ Vector2ub own_size, int debug, const pred& p)
{
const auto [from, from_offset] = from_;
const auto [to, to_offset] = to_;
@@ -238,7 +238,11 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o
closest_path_len = n_dist;
}
- //Debug{} << "node" << id << "|" << node.coord.to_signed3() << node.offset << "|" << node.dist;
+ if (debug >= 2) [[unlikely]]
+ DBG_nospace << "node"
+ << " px:" << closest << " path:" << closest_path_len
+ << " pos:" << closest_pos.coord.to_signed()
+ << ";" << closest_pos.offset;
const auto bb0 = bbox_from_pos(Vector2(n_coord.local()), n_offset, own_size);
for (auto [vec, len] : directions)
@@ -284,16 +288,21 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o
}
}
- //Debug{} << (fresh ? " new" : " old") << new_idx << "|" << node.coord.to_signed3() << node.offset << "|" << node.dist;
+ if (debug >= 3) [[unlikely]]
+ DBG_nospace << (fresh ? "" : " old")
+ << " path:" << closest_path_len
+ << " pos:" << closest_pos.coord.to_signed()
+ << ";" << closest_pos.offset;
add_to_heap(new_idx);
}
}
fm_debug_assert(nodes.size() == indexes.size());
- DBG_nospace << "dijkstra: closest px:" << closest << " path:" << closest_path_len
- << " pos:" << closest_pos.coord.to_signed() << ";" << closest_pos.offset
- << " nodes:" << nodes.size() << " edges:" << edges.size();
+ if (debug)
+ DBG_nospace << "dijkstra: closest px:" << closest << " path:" << closest_path_len
+ << " pos:" << closest_pos.coord.to_signed() << ";" << closest_pos.offset
+ << " nodes:" << nodes.size() << " edges:" << edges.size();
// todo...
return result;
diff --git a/src/path-search.hpp b/src/path-search.hpp
index f705c251..35c00404 100644
--- a/src/path-search.hpp
+++ b/src/path-search.hpp
@@ -91,7 +91,7 @@ struct astar
// todo add simple bresenham short-circuit
path_search_result Dijkstra(world& w, point from, point to,
object_id own_id, uint32_t max_dist, Vector2ub own_size,
- const pred& p = path_search::never_continue());
+ int debug = 0, const pred& p = path_search::never_continue());
static constexpr auto div_factor = path_search::div_factor;
static constexpr auto initial_capacity = TILE_COUNT * 16 * div_factor*div_factor;