summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-12 14:07:06 +0200
committerGitHub <noreply@github.com>2017-09-12 14:07:06 +0200
commit26017499a582312f981309ac5d9ae7aa5b4cad52 (patch)
treea7a10935bae1d6fe59eceeaa4011025385dcfcfc /core/math
parent91a85d8805a4293aa37900401db19fb3f49b3801 (diff)
parent6872cc7b122e366d366a3883b462d51a8d2b00ec (diff)
Merge pull request #11049 from scayze/astar_get_points
Add get_points() method to AStar
Diffstat (limited to 'core/math')
-rw-r--r--core/math/a_star.cpp11
-rw-r--r--core/math/a_star.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 21516ac768..d1afcec18f 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -129,6 +129,16 @@ bool AStar::has_point(int p_id) const {
return points.has(p_id);
}
+Array AStar::get_points() {
+ Array point_list;
+
+ for (const Map<int, Point *>::Element *E = points.front(); E; E = E->next()) {
+ point_list.push_back(E->key());
+ }
+
+ return point_list;
+}
+
bool AStar::are_points_connected(int p_id, int p_with_id) const {
Segment s(p_id, p_with_id);
@@ -407,6 +417,7 @@ void AStar::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_point_weight_scale", "id"), &AStar::get_point_weight_scale);
ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point);
ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar::has_point);
+ ClassDB::bind_method(D_METHOD("get_points"), &AStar::get_points);
ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar::connect_points, DEFVAL(true));
ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar::disconnect_points);
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 75b860d0a4..38d13d510b 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -105,6 +105,7 @@ public:
real_t get_point_weight_scale(int p_id) const;
void remove_point(int p_id);
bool has_point(int p_id) const;
+ Array get_points();
void connect_points(int p_id, int p_with_id, bool bidirectional = true);
void disconnect_points(int p_id, int p_with_id);