summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/navigation_2d.cpp12
-rw-r--r--scene/2d/navigation_2d.h4
-rw-r--r--scene/3d/navigation.cpp22
-rw-r--r--scene/3d/navigation.h6
4 files changed, 40 insertions, 4 deletions
diff --git a/scene/2d/navigation_2d.cpp b/scene/2d/navigation_2d.cpp
index de01d97ad9..45574d4a5a 100644
--- a/scene/2d/navigation_2d.cpp
+++ b/scene/2d/navigation_2d.cpp
@@ -35,6 +35,8 @@ void Navigation2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &Navigation2D::get_rid);
ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation2D::get_simple_path, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_closest_point", "to_point"), &Navigation2D::get_closest_point);
+ ClassDB::bind_method(D_METHOD("get_closest_point_owner", "to_point"), &Navigation2D::get_closest_point_owner);
ClassDB::bind_method(D_METHOD("set_cell_size", "cell_size"), &Navigation2D::set_cell_size);
ClassDB::bind_method(D_METHOD("get_cell_size"), &Navigation2D::get_cell_size);
@@ -68,10 +70,18 @@ void Navigation2D::set_edge_connection_margin(float p_edge_connection_margin) {
Navigation2DServer::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin);
}
-Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) {
+Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) const {
return Navigation2DServer::get_singleton()->map_get_path(map, p_start, p_end, p_optimize);
}
+Vector2 Navigation2D::get_closest_point(const Vector2 &p_point) const {
+ return Navigation2DServer::get_singleton()->map_get_closest_point(map, p_point);
+}
+
+RID Navigation2D::get_closest_point_owner(const Vector2 &p_point) const {
+ return Navigation2DServer::get_singleton()->map_get_closest_point_owner(map, p_point);
+}
+
Navigation2D::Navigation2D() {
map = Navigation2DServer::get_singleton()->map_create();
diff --git a/scene/2d/navigation_2d.h b/scene/2d/navigation_2d.h
index 08642a5489..16e20d8f9b 100644
--- a/scene/2d/navigation_2d.h
+++ b/scene/2d/navigation_2d.h
@@ -61,7 +61,9 @@ public:
return edge_connection_margin;
}
- Vector<Vector2> get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize = true);
+ Vector<Vector2> get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize = true) const;
+ Vector2 get_closest_point(const Vector2 &p_point) const;
+ RID get_closest_point_owner(const Vector2 &p_point) const;
Navigation2D();
};
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index 10b12f5c75..f2109a2f33 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -32,11 +32,27 @@
#include "servers/navigation_server.h"
-Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) {
+Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) const {
return NavigationServer::get_singleton()->map_get_path(map, p_start, p_end, p_optimize);
}
+Vector3 Navigation::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision) const {
+ return NavigationServer::get_singleton()->map_get_closest_point_to_segment(map, p_from, p_to, p_use_collision);
+}
+
+Vector3 Navigation::get_closest_point(const Vector3 &p_point) const {
+ return NavigationServer::get_singleton()->map_get_closest_point(map, p_point);
+}
+
+Vector3 Navigation::get_closest_point_normal(const Vector3 &p_point) const {
+ return NavigationServer::get_singleton()->map_get_closest_point_normal(map, p_point);
+}
+
+RID Navigation::get_closest_point_owner(const Vector3 &p_point) const {
+ return NavigationServer::get_singleton()->map_get_closest_point_owner(map, p_point);
+}
+
void Navigation::set_up_vector(const Vector3 &p_up) {
up = p_up;
@@ -63,6 +79,10 @@ void Navigation::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &Navigation::get_rid);
ClassDB::bind_method(D_METHOD("get_simple_path", "start", "end", "optimize"), &Navigation::get_simple_path, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "start", "end", "use_collision"), &Navigation::get_closest_point_to_segment, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_closest_point", "to_point"), &Navigation::get_closest_point);
+ ClassDB::bind_method(D_METHOD("get_closest_point_normal", "to_point"), &Navigation::get_closest_point_normal);
+ ClassDB::bind_method(D_METHOD("get_closest_point_owner", "to_point"), &Navigation::get_closest_point_owner);
ClassDB::bind_method(D_METHOD("set_up_vector", "up"), &Navigation::set_up_vector);
ClassDB::bind_method(D_METHOD("get_up_vector"), &Navigation::get_up_vector);
diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h
index 68e041ad73..85887651ff 100644
--- a/scene/3d/navigation.h
+++ b/scene/3d/navigation.h
@@ -66,7 +66,11 @@ public:
return edge_connection_margin;
}
- Vector<Vector3> get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize = true);
+ Vector<Vector3> get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize = true) const;
+ Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision = false) const;
+ Vector3 get_closest_point(const Vector3 &p_point) const;
+ Vector3 get_closest_point_normal(const Vector3 &p_point) const;
+ RID get_closest_point_owner(const Vector3 &p_point) const;
Navigation();
~Navigation();