Browse Source

Merge pull request #88164 from smix8/fix_region_signals

Fix NavigationRegion errors from signal changes
Rémi Verschelde 1 year ago
parent
commit
effb35dfa7

+ 10 - 2
scene/2d/navigation_region_2d.cpp

@@ -275,6 +275,14 @@ void NavigationRegion2D::_navigation_map_changed(RID p_map) {
 }
 #endif // DEBUG_ENABLED
 
+#ifdef DEBUG_ENABLED
+void NavigationRegion2D::_navigation_debug_changed() {
+	if (is_inside_tree()) {
+		queue_redraw();
+	}
+}
+#endif // DEBUG_ENABLED
+
 Array NavigationRegion2D::get_configuration_warnings() const {
 	Array warnings = Node2D::get_configuration_warnings();
 
@@ -374,7 +382,7 @@ NavigationRegion2D::NavigationRegion2D() {
 
 #ifdef DEBUG_ENABLED
 	NavigationServer2D::get_singleton()->connect(SNAME("map_changed"), callable_mp(this, &NavigationRegion2D::_navigation_map_changed));
-	NavigationServer2D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion2D::_navigation_map_changed));
+	NavigationServer2D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion2D::_navigation_debug_changed));
 #endif // DEBUG_ENABLED
 }
 
@@ -391,7 +399,7 @@ NavigationRegion2D::~NavigationRegion2D() {
 
 #ifdef DEBUG_ENABLED
 	NavigationServer2D::get_singleton()->disconnect(SNAME("map_changed"), callable_mp(this, &NavigationRegion2D::_navigation_map_changed));
-	NavigationServer2D::get_singleton()->disconnect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion2D::_navigation_map_changed));
+	NavigationServer2D::get_singleton()->disconnect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion2D::_navigation_debug_changed));
 #endif // DEBUG_ENABLED
 }
 

+ 1 - 0
scene/2d/navigation_region_2d.h

@@ -59,6 +59,7 @@ private:
 	void _update_debug_mesh();
 	void _update_debug_edge_connections_mesh();
 	void _navigation_map_changed(RID p_map);
+	void _navigation_debug_changed();
 #endif // DEBUG_ENABLED
 
 protected:

+ 11 - 4
scene/3d/navigation_region_3d.cpp

@@ -361,6 +361,15 @@ void NavigationRegion3D::_navigation_map_changed(RID p_map) {
 }
 #endif // DEBUG_ENABLED
 
+#ifdef DEBUG_ENABLED
+void NavigationRegion3D::_navigation_debug_changed() {
+	if (is_inside_tree()) {
+		_update_debug_mesh();
+		_update_debug_edge_connections_mesh();
+	}
+}
+#endif // DEBUG_ENABLED
+
 void NavigationRegion3D::_region_enter_navigation_map() {
 	if (!is_inside_tree()) {
 		return;
@@ -426,8 +435,7 @@ NavigationRegion3D::NavigationRegion3D() {
 
 #ifdef DEBUG_ENABLED
 	NavigationServer3D::get_singleton()->connect(SNAME("map_changed"), callable_mp(this, &NavigationRegion3D::_navigation_map_changed));
-	NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion3D::_update_debug_mesh));
-	NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion3D::_update_debug_edge_connections_mesh));
+	NavigationServer3D::get_singleton()->connect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion3D::_navigation_debug_changed));
 #endif // DEBUG_ENABLED
 }
 
@@ -440,8 +448,7 @@ NavigationRegion3D::~NavigationRegion3D() {
 
 #ifdef DEBUG_ENABLED
 	NavigationServer3D::get_singleton()->disconnect(SNAME("map_changed"), callable_mp(this, &NavigationRegion3D::_navigation_map_changed));
-	NavigationServer3D::get_singleton()->disconnect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion3D::_update_debug_mesh));
-	NavigationServer3D::get_singleton()->disconnect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion3D::_update_debug_edge_connections_mesh));
+	NavigationServer3D::get_singleton()->disconnect(SNAME("navigation_debug_changed"), callable_mp(this, &NavigationRegion3D::_navigation_debug_changed));
 
 	ERR_FAIL_NULL(RenderingServer::get_singleton());
 	if (debug_instance.is_valid()) {

+ 1 - 0
scene/3d/navigation_region_3d.h

@@ -61,6 +61,7 @@ private:
 	void _update_debug_mesh();
 	void _update_debug_edge_connections_mesh();
 	void _navigation_map_changed(RID p_map);
+	void _navigation_debug_changed();
 #endif // DEBUG_ENABLED
 
 protected: