Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Joint2D and Joint: update joint on NOTIFICATION_POST_ENTER_TREE #58642

Merged
merged 2 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions scene/2d/joints_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -195,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();
Expand Down
11 changes: 9 additions & 2 deletions scene/3d/physics_joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -194,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();
}
Expand Down