From 2f1668804cf1196920902540a3787cb8f7c33f71 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Mon, 23 Oct 2023 01:43:55 +0200 Subject: [PATCH] Fix missing NavigationLink property updates in constructor Fixes missing NavigationLink property updates in constructor. --- doc/classes/NavigationLink2D.xml | 6 ++++++ doc/classes/NavigationLink3D.xml | 6 ++++++ scene/2d/navigation_link_2d.cpp | 12 ++++++++++++ scene/2d/navigation_link_2d.h | 1 + scene/3d/navigation_link_3d.cpp | 12 ++++++++++++ scene/3d/navigation_link_3d.h | 2 ++ 6 files changed, 39 insertions(+) diff --git a/doc/classes/NavigationLink2D.xml b/doc/classes/NavigationLink2D.xml index b12051b4f43c..75b691aaf475 100644 --- a/doc/classes/NavigationLink2D.xml +++ b/doc/classes/NavigationLink2D.xml @@ -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. + + + + Returns the [RID] of this link on the [NavigationServer2D]. + + diff --git a/doc/classes/NavigationLink3D.xml b/doc/classes/NavigationLink3D.xml index 90eaaaee6d26..711c637dc5be 100644 --- a/doc/classes/NavigationLink3D.xml +++ b/doc/classes/NavigationLink3D.xml @@ -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. + + + + Returns the [RID] of this link on the [NavigationServer3D]. + + diff --git a/scene/2d/navigation_link_2d.cpp b/scene/2d/navigation_link_2d.cpp index 95798b685645..04ba550888ad 100644 --- a/scene/2d/navigation_link_2d.cpp +++ b/scene/2d/navigation_link_2d.cpp @@ -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); @@ -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; @@ -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); diff --git a/scene/2d/navigation_link_2d.h b/scene/2d/navigation_link_2d.h index 4259740c900c..2929691c045c 100644 --- a/scene/2d/navigation_link_2d.h +++ b/scene/2d/navigation_link_2d.h @@ -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; } diff --git a/scene/3d/navigation_link_3d.cpp b/scene/3d/navigation_link_3d.cpp index 70416ca93b69..dc776ebea255 100644 --- a/scene/3d/navigation_link_3d.cpp +++ b/scene/3d/navigation_link_3d.cpp @@ -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); @@ -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); } @@ -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; diff --git a/scene/3d/navigation_link_3d.h b/scene/3d/navigation_link_3d.h index ec92fb9dd939..1867082811ff 100644 --- a/scene/3d/navigation_link_3d.h +++ b/scene/3d/navigation_link_3d.h @@ -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; }