diff options
Diffstat (limited to 'core/math/a_star.h')
-rw-r--r-- | core/math/a_star.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/core/math/a_star.h b/core/math/a_star.h index 93e6c381f6..4d69822254 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -40,8 +40,8 @@ A* pathfinding algorithm. */ -class AStar : public RefCounted { - GDCLASS(AStar, RefCounted); +class AStar3D : public RefCounted { + GDCLASS(AStar3D, RefCounted); friend class AStar2D; struct Point { @@ -92,7 +92,10 @@ class AStar : public RefCounted { }; unsigned char direction = NONE; - bool operator<(const Segment &p_s) const { return key < p_s.key; } + static uint32_t hash(const Segment &p_seg) { + return hash_one_uint64(p_seg.key); + } + bool operator==(const Segment &p_s) const { return key == p_s.key; } Segment() {} Segment(int p_from, int p_to) { @@ -112,7 +115,7 @@ class AStar : public RefCounted { uint64_t pass = 1; OAHashMap<int, Point *> points; - Set<Segment> segments; + HashSet<Segment, Segment> segments; bool _solve(Point *begin_point, Point *end_point); @@ -156,15 +159,15 @@ public: Vector<Vector3> get_point_path(int p_from_id, int p_to_id); Vector<int> get_id_path(int p_from_id, int p_to_id); - AStar() {} - ~AStar(); + AStar3D() {} + ~AStar3D(); }; class AStar2D : public RefCounted { GDCLASS(AStar2D, RefCounted); - AStar astar; + AStar3D astar; - bool _solve(AStar::Point *begin_point, AStar::Point *end_point); + bool _solve(AStar3D::Point *begin_point, AStar3D::Point *end_point); protected: static void _bind_methods(); |