Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing NavigationRegion property updates in constructor #83812

Merged
merged 1 commit into from Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/classes/NavigationRegion2D.xml
Expand Up @@ -43,7 +43,14 @@
Returns the current navigation map [RID] used by this region.
</description>
</method>
<method name="get_region_rid" qualifiers="const">
<method name="get_region_rid" qualifiers="const" is_deprecated="true">
<return type="RID" />
<description>
Returns the [RID] of this region on the [NavigationServer2D].
[i]Deprecated.[/i] Use [method get_rid] instead.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the [RID] of this region on the [NavigationServer2D]. Combined with [method NavigationServer2D.map_get_closest_point_owner] can be used to identify the [NavigationRegion2D] closest to a point on the merged navigation map.
Expand Down
9 changes: 8 additions & 1 deletion doc/classes/NavigationRegion3D.xml
Expand Up @@ -36,7 +36,14 @@
Returns the current navigation map [RID] used by this region.
</description>
</method>
<method name="get_region_rid" qualifiers="const">
<method name="get_region_rid" qualifiers="const" is_deprecated="true">
<return type="RID" />
<description>
Returns the [RID] of this region on the [NavigationServer3D].
[i]Deprecated.[/i] Use [method get_rid] instead.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the [RID] of this region on the [NavigationServer3D]. Combined with [method NavigationServer3D.map_get_closest_point_owner] can be used to identify the [NavigationRegion3D] closest to a point on the merged navigation map.
Expand Down
11 changes: 10 additions & 1 deletion scene/2d/navigation_region_2d.cpp
Expand Up @@ -35,6 +35,10 @@
#include "scene/resources/world_2d.h"
#include "servers/navigation_server_2d.h"

RID NavigationRegion2D::get_rid() const {
return region;
}

void NavigationRegion2D::set_enabled(bool p_enabled) {
if (enabled == p_enabled) {
return;
Expand Down Expand Up @@ -136,7 +140,7 @@ real_t NavigationRegion2D::get_travel_cost() const {
}

RID NavigationRegion2D::get_region_rid() const {
return region;
return get_rid();
}

#ifdef TOOLS_ENABLED
Expand Down Expand Up @@ -279,6 +283,8 @@ PackedStringArray NavigationRegion2D::get_configuration_warnings() const {
}

void NavigationRegion2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &NavigationRegion2D::get_rid);

ClassDB::bind_method(D_METHOD("set_navigation_polygon", "navigation_polygon"), &NavigationRegion2D::set_navigation_polygon);
ClassDB::bind_method(D_METHOD("get_navigation_polygon"), &NavigationRegion2D::get_navigation_polygon);

Expand Down Expand Up @@ -356,6 +362,9 @@ NavigationRegion2D::NavigationRegion2D() {
NavigationServer2D::get_singleton()->region_set_owner_id(region, get_instance_id());
NavigationServer2D::get_singleton()->region_set_enter_cost(region, get_enter_cost());
NavigationServer2D::get_singleton()->region_set_travel_cost(region, get_travel_cost());
NavigationServer2D::get_singleton()->region_set_navigation_layers(region, navigation_layers);
NavigationServer2D::get_singleton()->region_set_use_edge_connections(region, use_edge_connections);
NavigationServer2D::get_singleton()->region_set_enabled(region, enabled);

#ifdef DEBUG_ENABLED
NavigationServer2D::get_singleton()->connect(SNAME("map_changed"), callable_mp(this, &NavigationRegion2D::_navigation_map_changed));
Expand Down
1 change: 1 addition & 0 deletions scene/2d/navigation_region_2d.h
Expand Up @@ -76,6 +76,7 @@ class NavigationRegion2D : public Node2D {
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
RID get_rid() const;

void set_enabled(bool p_enabled);
bool is_enabled() const;
Expand Down
11 changes: 10 additions & 1 deletion scene/3d/navigation_region_3d.cpp
Expand Up @@ -33,6 +33,10 @@
#include "scene/resources/navigation_mesh_source_geometry_data_3d.h"
#include "servers/navigation_server_3d.h"

RID NavigationRegion3D::get_rid() const {
return region;
}

void NavigationRegion3D::set_enabled(bool p_enabled) {
if (enabled == p_enabled) {
return;
Expand Down Expand Up @@ -154,7 +158,7 @@ real_t NavigationRegion3D::get_travel_cost() const {
}

RID NavigationRegion3D::get_region_rid() const {
return region;
return get_rid();
}

void NavigationRegion3D::_notification(int p_what) {
Expand Down Expand Up @@ -275,6 +279,8 @@ PackedStringArray NavigationRegion3D::get_configuration_warnings() const {
}

void NavigationRegion3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &NavigationRegion3D::get_rid);

ClassDB::bind_method(D_METHOD("set_navigation_mesh", "navigation_mesh"), &NavigationRegion3D::set_navigation_mesh);
ClassDB::bind_method(D_METHOD("get_navigation_mesh"), &NavigationRegion3D::get_navigation_mesh);

Expand Down Expand Up @@ -410,6 +416,9 @@ NavigationRegion3D::NavigationRegion3D() {
NavigationServer3D::get_singleton()->region_set_owner_id(region, get_instance_id());
NavigationServer3D::get_singleton()->region_set_enter_cost(region, get_enter_cost());
NavigationServer3D::get_singleton()->region_set_travel_cost(region, get_travel_cost());
NavigationServer3D::get_singleton()->region_set_navigation_layers(region, navigation_layers);
NavigationServer3D::get_singleton()->region_set_use_edge_connections(region, use_edge_connections);
NavigationServer3D::get_singleton()->region_set_enabled(region, enabled);

#ifdef DEBUG_ENABLED
NavigationServer3D::get_singleton()->connect(SNAME("map_changed"), callable_mp(this, &NavigationRegion3D::_navigation_map_changed));
Expand Down
2 changes: 2 additions & 0 deletions scene/3d/navigation_region_3d.h
Expand Up @@ -73,6 +73,8 @@ class NavigationRegion3D : public Node3D {
#endif // DISABLE_DEPRECATED

public:
RID get_rid() const;

void set_enabled(bool p_enabled);
bool is_enabled() const;

Expand Down