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 NavigationLink property updates in constructor #83802

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/classes/NavigationLink2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the [RID] of this link on the [NavigationServer2D].
</description>
</method>
<method name="set_global_end_position">
<return type="void" />
<param index="0" name="position" type="Vector2" />
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/NavigationLink3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the [RID] of this link on the [NavigationServer3D].
</description>
</method>
<method name="set_global_end_position">
<return type="void" />
<param index="0" name="position" type="Vector3" />
Expand Down
12 changes: 12 additions & 0 deletions scene/2d/navigation_link_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "servers/navigation_server_3d.h"

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

ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationLink2D::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationLink2D::is_enabled);

Expand Down Expand Up @@ -175,6 +177,10 @@ bool NavigationLink2D::_edit_is_selected_on_click(const Point2 &p_point, double
}
#endif // TOOLS_ENABLED

RID NavigationLink2D::get_rid() const {
return link;
}

void NavigationLink2D::set_enabled(bool p_enabled) {
if (enabled == p_enabled) {
return;
Expand Down Expand Up @@ -343,7 +349,13 @@ PackedStringArray NavigationLink2D::get_configuration_warnings() const {

NavigationLink2D::NavigationLink2D() {
link = NavigationServer2D::get_singleton()->link_create();

NavigationServer2D::get_singleton()->link_set_owner_id(link, get_instance_id());
NavigationServer2D::get_singleton()->link_set_enter_cost(link, enter_cost);
NavigationServer2D::get_singleton()->link_set_travel_cost(link, travel_cost);
NavigationServer2D::get_singleton()->link_set_navigation_layers(link, navigation_layers);
NavigationServer2D::get_singleton()->link_set_bidirectional(link, bidirectional);
NavigationServer2D::get_singleton()->link_set_enabled(link, enabled);

set_notify_transform(true);
set_hide_clip_children(true);
Expand Down
1 change: 1 addition & 0 deletions scene/2d/navigation_link_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class NavigationLink2D : 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 { return enabled; }
Expand Down
12 changes: 12 additions & 0 deletions scene/3d/navigation_link_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void NavigationLink3D::_update_debug_mesh() {
#endif // DEBUG_ENABLED

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

ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationLink3D::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationLink3D::is_enabled);

Expand Down Expand Up @@ -263,7 +265,13 @@ void NavigationLink3D::_notification(int p_what) {

NavigationLink3D::NavigationLink3D() {
link = NavigationServer3D::get_singleton()->link_create();

NavigationServer3D::get_singleton()->link_set_owner_id(link, get_instance_id());
NavigationServer3D::get_singleton()->link_set_enter_cost(link, enter_cost);
NavigationServer3D::get_singleton()->link_set_travel_cost(link, travel_cost);
NavigationServer3D::get_singleton()->link_set_navigation_layers(link, navigation_layers);
NavigationServer3D::get_singleton()->link_set_bidirectional(link, bidirectional);
NavigationServer3D::get_singleton()->link_set_enabled(link, enabled);

set_notify_transform(true);
}
Expand All @@ -284,6 +292,10 @@ NavigationLink3D::~NavigationLink3D() {
#endif // DEBUG_ENABLED
}

RID NavigationLink3D::get_rid() const {
return link;
}

void NavigationLink3D::set_enabled(bool p_enabled) {
if (enabled == p_enabled) {
return;
Expand Down
2 changes: 2 additions & 0 deletions scene/3d/navigation_link_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class NavigationLink3D : public Node3D {
NavigationLink3D();
~NavigationLink3D();

RID get_rid() const;

void set_enabled(bool p_enabled);
bool is_enabled() const { return enabled; }

Expand Down
Loading