Ver Fonte

Merge pull request #58641 from rburing/joints_fix_signals

Rémi Verschelde há 3 anos atrás
pai
commit
97e5367fe8
2 ficheiros alterados com 17 adições e 5 exclusões
  1. 8 3
      scene/2d/joint_2d.cpp
  2. 9 2
      scene/3d/joint_3d.cpp

+ 8 - 3
scene/2d/joint_2d.cpp

@@ -159,15 +159,18 @@ NodePath Joint2D::get_node_b() const {
 
 void Joint2D::_notification(int p_what) {
 	switch (p_what) {
-		case NOTIFICATION_READY: {
+		case NOTIFICATION_POST_ENTER_TREE: {
+			if (is_configured()) {
+				_disconnect_signals();
+			}
 			_update_joint();
 		} break;
 
 		case NOTIFICATION_EXIT_TREE: {
 			if (is_configured()) {
 				_disconnect_signals();
-				_update_joint(true);
 			}
+			_update_joint(true);
 		} break;
 	}
 }
@@ -187,7 +190,9 @@ void Joint2D::set_exclude_nodes_from_collision(bool p_enable) {
 	if (exclude_from_collision == p_enable) {
 		return;
 	}
-
+	if (is_configured()) {
+		_disconnect_signals();
+	}
 	_update_joint(true);
 	exclude_from_collision = p_enable;
 	_update_joint();

+ 9 - 2
scene/3d/joint_3d.cpp

@@ -166,15 +166,18 @@ int Joint3D::get_solver_priority() const {
 
 void Joint3D::_notification(int p_what) {
 	switch (p_what) {
-		case NOTIFICATION_READY: {
+		case NOTIFICATION_POST_ENTER_TREE: {
+			if (is_configured()) {
+				_disconnect_signals();
+			}
 			_update_joint();
 		} break;
 
 		case NOTIFICATION_EXIT_TREE: {
 			if (is_configured()) {
 				_disconnect_signals();
-				_update_joint(true);
 			}
+			_update_joint(true);
 		} break;
 	}
 }
@@ -183,6 +186,10 @@ void Joint3D::set_exclude_nodes_from_collision(bool p_enable) {
 	if (exclude_from_collision == p_enable) {
 		return;
 	}
+	if (is_configured()) {
+		_disconnect_signals();
+	}
+	_update_joint(true);
 	exclude_from_collision = p_enable;
 	_update_joint();
 }