Merge pull request #58642 from rburing/joints_fix_signals_3.x

This commit is contained in:
Rémi Verschelde 2022-03-01 11:01:35 +01:00 committed by GitHub
commit 29d78f20de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View file

@ -168,14 +168,17 @@ NodePath Joint2D::get_node_b() const {
void Joint2D::_notification(int p_what) { void Joint2D::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_READY: { case NOTIFICATION_POST_ENTER_TREE: {
if (joint.is_valid()) {
_disconnect_signals();
}
_update_joint(); _update_joint();
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
if (joint.is_valid()) { if (joint.is_valid()) {
_disconnect_signals(); _disconnect_signals();
_update_joint(true);
} }
_update_joint(true);
} break; } break;
} }
} }
@ -195,7 +198,9 @@ void Joint2D::set_exclude_nodes_from_collision(bool p_enable) {
if (exclude_from_collision == p_enable) { if (exclude_from_collision == p_enable) {
return; return;
} }
if (joint.is_valid()) {
_disconnect_signals();
}
_update_joint(true); _update_joint(true);
exclude_from_collision = p_enable; exclude_from_collision = p_enable;
_update_joint(); _update_joint();

View file

@ -178,14 +178,17 @@ int Joint::get_solver_priority() const {
void Joint::_notification(int p_what) { void Joint::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_READY: { case NOTIFICATION_POST_ENTER_TREE: {
if (joint.is_valid()) {
_disconnect_signals();
}
_update_joint(); _update_joint();
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
if (joint.is_valid()) { if (joint.is_valid()) {
_disconnect_signals(); _disconnect_signals();
_update_joint(true);
} }
_update_joint(true);
} break; } break;
} }
} }
@ -194,6 +197,10 @@ void Joint::set_exclude_nodes_from_collision(bool p_enable) {
if (exclude_from_collision == p_enable) { if (exclude_from_collision == p_enable) {
return; return;
} }
if (joint.is_valid()) {
_disconnect_signals();
}
_update_joint(true);
exclude_from_collision = p_enable; exclude_from_collision = p_enable;
_update_joint(); _update_joint();
} }