diff --git a/doc/classes/NavigationMeshInstance.xml b/doc/classes/NavigationMeshInstance.xml index 6866f0e2a..74259b76f 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 345eac36f..3e28fdb42 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 470acf1fb..e9ec1a3e7 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -382,6 +382,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 { @@ -533,6 +537,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 e67ab3b42..ba631673a 100644 --- a/scene/2d/navigation_polygon.h +++ b/scene/2d/navigation_polygon.h @@ -117,6 +117,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 7b4e85dc1..45a45e075 100644 --- a/scene/3d/navigation_mesh_instance.cpp +++ b/scene/3d/navigation_mesh_instance.cpp @@ -70,6 +70,10 @@ bool NavigationMeshInstance::is_enabled() const { return enabled; } +RID NavigationMeshInstance::get_region_rid() const { + return region; +} + ///////////////////////////// void NavigationMeshInstance::_notification(int p_what) { @@ -211,6 +215,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 c8cbba93c..3a015b49f 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;