Add get_region_rid() to NavigationPolygonInstance and NavigationMeshInstance

Add get_region_rid() to NavigationPolygonInstance and NavigationMeshInstance
This commit is contained in:
smix8 2022-04-30 15:54:12 +02:00 committed by Relintai
parent a9df89703c
commit 1317f7000a
6 changed files with 28 additions and 0 deletions

View File

@ -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].
</description>
</method>
<method name="get_region_rid" qualifiers="const">
<return type="RID" />
<description>
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.
</description>
</method>
</methods>
<members>
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">

View File

@ -7,6 +7,12 @@
<tutorials>
</tutorials>
<methods>
<method name="get_region_rid" qualifiers="const">
<return type="RID" />
<description>
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.
</description>
</method>
</methods>
<members>
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">

View File

@ -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");

View File

@ -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<NavigationPolygon> &p_navpoly);
Ref<NavigationPolygon> get_navigation_polygon() const;

View File

@ -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);

View File

@ -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<NavigationMesh> &p_navmesh);
Ref<NavigationMesh> get_navigation_mesh() const;