From ebcbbec56397a486205d75d40b71d54bed763d78 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Sat, 30 Apr 2022 15:54:12 +0200 Subject: [PATCH] Add get_region_rid() to NavigationPolygonInstance and NavigationMeshInstance Add get_region_rid() to NavigationPolygonInstance and NavigationMeshInstance --- doc/classes/NavigationMeshInstance.xml | 6 ++++++ doc/classes/NavigationPolygonInstance.xml | 6 ++++++ scene/2d/navigation_polygon.cpp | 6 ++++++ scene/2d/navigation_polygon.h | 2 ++ scene/3d/navigation_mesh_instance.cpp | 6 ++++++ scene/3d/navigation_mesh_instance.h | 2 ++ 6 files changed, 28 insertions(+) diff --git a/doc/classes/NavigationMeshInstance.xml b/doc/classes/NavigationMeshInstance.xml index 3bf2affc2f3..cfb072d126b 100644 --- a/doc/classes/NavigationMeshInstance.xml +++ b/doc/classes/NavigationMeshInstance.xml @@ -15,6 +15,12 @@ Bakes the [NavigationMesh]. The baking is done in a separate thread because navigation baking is not a cheap operation. This can be done at runtime. When it is completed, it automatically sets the new [NavigationMesh]. + + + + Returns the [RID] of this region on the [NavigationServer]. Combined with [method NavigationServer.map_get_closest_point_owner] can be used to identify the [NavigationMeshInstance] closest to a point on the merged navigation map. + + diff --git a/doc/classes/NavigationPolygonInstance.xml b/doc/classes/NavigationPolygonInstance.xml index 3ebc9e1dde8..667074c2950 100644 --- a/doc/classes/NavigationPolygonInstance.xml +++ b/doc/classes/NavigationPolygonInstance.xml @@ -7,6 +7,12 @@ + + + + Returns the [RID] of this region on the [Navigation2DServer]. Combined with [method Navigation2DServer.map_get_closest_point_owner] can be used to identify the [NavigationPolygonInstance] closest to a point on the merged navigation map. + + diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 2d45dae198b..4afd527e8c4 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -381,6 +381,10 @@ bool NavigationPolygonInstance::is_enabled() const { return enabled; } +RID NavigationPolygonInstance::get_region_rid() const { + return region; +} + ///////////////////////////// #ifdef TOOLS_ENABLED Rect2 NavigationPolygonInstance::_edit_get_rect() const { @@ -532,6 +536,8 @@ void NavigationPolygonInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationPolygonInstance::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationPolygonInstance::is_enabled); + ClassDB::bind_method(D_METHOD("get_region_rid"), &NavigationPolygonInstance::get_region_rid); + ClassDB::bind_method(D_METHOD("_navpoly_changed"), &NavigationPolygonInstance::_navpoly_changed); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navpoly", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"), "set_navigation_polygon", "get_navigation_polygon"); diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h index ed857f99089..1194c143883 100644 --- a/scene/2d/navigation_polygon.h +++ b/scene/2d/navigation_polygon.h @@ -116,6 +116,8 @@ public: void set_enabled(bool p_enabled); bool is_enabled() const; + RID get_region_rid() const; + void set_navigation_polygon(const Ref &p_navpoly); Ref get_navigation_polygon() const; diff --git a/scene/3d/navigation_mesh_instance.cpp b/scene/3d/navigation_mesh_instance.cpp index 83d43e47d1b..968e44e5f66 100644 --- a/scene/3d/navigation_mesh_instance.cpp +++ b/scene/3d/navigation_mesh_instance.cpp @@ -69,6 +69,10 @@ bool NavigationMeshInstance::is_enabled() const { return enabled; } +RID NavigationMeshInstance::get_region_rid() const { + return region; +} + ///////////////////////////// void NavigationMeshInstance::_notification(int p_what) { @@ -210,6 +214,8 @@ void NavigationMeshInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationMeshInstance::set_enabled); ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationMeshInstance::is_enabled); + ClassDB::bind_method(D_METHOD("get_region_rid"), &NavigationMeshInstance::get_region_rid); + ClassDB::bind_method(D_METHOD("bake_navigation_mesh"), &NavigationMeshInstance::bake_navigation_mesh); ClassDB::bind_method(D_METHOD("_bake_finished", "nav_mesh"), &NavigationMeshInstance::_bake_finished); diff --git a/scene/3d/navigation_mesh_instance.h b/scene/3d/navigation_mesh_instance.h index c20472b63c2..ec49375aef9 100644 --- a/scene/3d/navigation_mesh_instance.h +++ b/scene/3d/navigation_mesh_instance.h @@ -57,6 +57,8 @@ public: void set_enabled(bool p_enabled); bool is_enabled() const; + RID get_region_rid() const; + void set_navigation_mesh(const Ref &p_navmesh); Ref get_navigation_mesh() const;