From f197e5eebb7532ad1586fd2a17742f0cf1937291 Mon Sep 17 00:00:00 2001 From: Ricardo Buring Date: Mon, 28 Feb 2022 22:48:48 +0100 Subject: [PATCH 1/2] Joint2D and Joint: update joint on NOTIFICATION_POST_ENTER_TREE This allows reparenting, etc. --- scene/2d/joints_2d.cpp | 7 +++++-- scene/3d/physics_joint.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index cc66d42fbe8..8ca7196a384 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -168,14 +168,17 @@ NodePath Joint2D::get_node_b() const { void Joint2D::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { + case NOTIFICATION_POST_ENTER_TREE: { + if (joint.is_valid()) { + _disconnect_signals(); + } _update_joint(); } break; case NOTIFICATION_EXIT_TREE: { if (joint.is_valid()) { _disconnect_signals(); - _update_joint(true); } + _update_joint(true); } break; } } diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index bc38368b8d9..381fc684585 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -178,14 +178,17 @@ int Joint::get_solver_priority() const { void Joint::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { + case NOTIFICATION_POST_ENTER_TREE: { + if (joint.is_valid()) { + _disconnect_signals(); + } _update_joint(); } break; case NOTIFICATION_EXIT_TREE: { if (joint.is_valid()) { _disconnect_signals(); - _update_joint(true); } + _update_joint(true); } break; } } From 322e3a9567aa459fd74f2d9ccb7d8761b59f7edd Mon Sep 17 00:00:00 2001 From: Ricardo Buring Date: Mon, 28 Feb 2022 22:51:40 +0100 Subject: [PATCH 2/2] Joint2D and Joint: make set_exclude_nodes_from_collision respect signals --- scene/2d/joints_2d.cpp | 4 +++- scene/3d/physics_joint.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 8ca7196a384..c3939278d7b 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -198,7 +198,9 @@ void Joint2D::set_exclude_nodes_from_collision(bool p_enable) { if (exclude_from_collision == p_enable) { return; } - + if (joint.is_valid()) { + _disconnect_signals(); + } _update_joint(true); exclude_from_collision = p_enable; _update_joint(); diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index 381fc684585..c05d645a4ab 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -197,6 +197,10 @@ void Joint::set_exclude_nodes_from_collision(bool p_enable) { if (exclude_from_collision == p_enable) { return; } + if (joint.is_valid()) { + _disconnect_signals(); + } + _update_joint(true); exclude_from_collision = p_enable; _update_joint(); }