Skip to content

Commit

Permalink
Fix missing NavigationLink property updates in constructor
Browse files Browse the repository at this point in the history
Fixes missing NavigationLink property updates in constructor.
  • Loading branch information
smix8 committed Oct 22, 2023
1 parent 8c25a98 commit 2f16688
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
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

0 comments on commit 2f16688

Please sign in to comment.