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.hpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/path-search.hpp b/src/path-search.hpp
index 35c00404..2705b1f6 100644
--- a/src/path-search.hpp
+++ b/src/path-search.hpp
@@ -65,40 +65,46 @@ struct astar
Vector2b offset;
};
- struct edge
- {
- global_coords from, to;
- Vector2b from_offset, to_offset;
-
- bool operator==(const edge& other) const;
- };
-
using pred = path_search::pred;
- enum class edge_status : uint8_t { unknown, good, bad, };
template<typename T> using bbox = path_search::bbox<T>;
struct point_hash { size_t operator()(point pt) const; };
- struct edge_hash { size_t operator()(const edge& e) const; };
fm_DECLARE_DELETED_COPY_ASSIGNMENT(astar);
astar();
void reserve(size_t capacity);
void clear();
- void add_to_heap(uint32_t id);
- uint32_t pop_from_heap();
- static edge make_edge(const point& a, const point& b);
// 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,
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;
+//#define FM_ASTAR_NO_EDGE_CACHE
private:
- std::vector<visited> nodes;
+ static constexpr auto div_factor = (int8_t)path_search::div_factor;
+ static constexpr auto initial_capacity = TILE_COUNT * 16 * div_factor*div_factor;
+
+ void add_to_heap(uint32_t id);
+ uint32_t pop_from_heap();
+
+#ifndef FM_ASTAR_NO_EDGE_CACHE
+ struct edge
+ {
+ global_coords from, to;
+ Vector2b from_offset, to_offset;
+
+ bool operator==(const edge& other) const;
+ };
+ enum class edge_status : uint8_t { unknown, good, bad, };
+ struct edge_hash { size_t operator()(const edge& e) const; };
+ static edge make_edge(const point& a, const point& b);
+
tsl::robin_map<edge, edge_status, edge_hash> edges;
+#endif
+
+ std::vector<visited> nodes;
tsl::robin_map<point, uint32_t, point_hash> indexes;
std::vector<uint32_t> Q;
};