From 9e100c3e7a38fa0a8338809729e4677e5c8e8edb Mon Sep 17 00:00:00 2001 From: Ricardo Buring Date: Mon, 28 Feb 2022 22:21:32 +0100 Subject: Joint2D and Joint3D: update joint on NOTIFICATION_POST_ENTER_TREE This allows reparenting, etc. --- scene/2d/joint_2d.cpp | 8 +++++--- scene/3d/joint_3d.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/scene/2d/joint_2d.cpp b/scene/2d/joint_2d.cpp index 521efe6567..623e643333 100644 --- a/scene/2d/joint_2d.cpp +++ b/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,6 @@ void Joint2D::set_exclude_nodes_from_collision(bool p_enable) { if (exclude_from_collision == p_enable) { return; } - _update_joint(true); exclude_from_collision = p_enable; _update_joint(); diff --git a/scene/3d/joint_3d.cpp b/scene/3d/joint_3d.cpp index f957b6c732..9a4cf79a8d 100644 --- a/scene/3d/joint_3d.cpp +++ b/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; } } -- cgit v1.2.3 From cb5bc58e81ad42def9ae9ab5075d6b754f3d9e96 Mon Sep 17 00:00:00 2001 From: Ricardo Buring Date: Mon, 28 Feb 2022 22:25:45 +0100 Subject: Joint2D and Joint3D: make set_exclude_nodes_from_collision respect signals --- scene/2d/joint_2d.cpp | 3 +++ scene/3d/joint_3d.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/scene/2d/joint_2d.cpp b/scene/2d/joint_2d.cpp index 623e643333..c2773191ea 100644 --- a/scene/2d/joint_2d.cpp +++ b/scene/2d/joint_2d.cpp @@ -190,6 +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(); diff --git a/scene/3d/joint_3d.cpp b/scene/3d/joint_3d.cpp index 9a4cf79a8d..ce7c0d8292 100644 --- a/scene/3d/joint_3d.cpp +++ b/scene/3d/joint_3d.cpp @@ -186,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(); } -- cgit v1.2.3