Avoid duplicate connect in `Joint2D::_update_joint` and Joint3D
This commit is contained in:
parent
557f63d037
commit
51bc55598c
|
@ -117,8 +117,12 @@ void Joint2D::_update_joint(bool p_only_free) {
|
|||
ba = body_a->get_rid();
|
||||
bb = body_b->get_rid();
|
||||
|
||||
if (!body_a->is_connected(SceneStringName(tree_exiting), callable_mp(this, &Joint2D::_body_exit_tree))) {
|
||||
body_a->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint2D::_body_exit_tree));
|
||||
}
|
||||
if (!body_b->is_connected(SceneStringName(tree_exiting), callable_mp(this, &Joint2D::_body_exit_tree))) {
|
||||
body_b->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint2D::_body_exit_tree));
|
||||
}
|
||||
|
||||
PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
|
||||
}
|
||||
|
|
|
@ -108,13 +108,17 @@ void Joint3D::_update_joint(bool p_only_free) {
|
|||
|
||||
if (body_a) {
|
||||
ba = body_a->get_rid();
|
||||
if (!body_a->is_connected(SceneStringName(tree_exiting), callable_mp(this, &Joint3D::_body_exit_tree))) {
|
||||
body_a->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint3D::_body_exit_tree));
|
||||
}
|
||||
}
|
||||
|
||||
if (body_b) {
|
||||
bb = body_b->get_rid();
|
||||
if (!body_b->is_connected(SceneStringName(tree_exiting), callable_mp(this, &Joint3D::_body_exit_tree))) {
|
||||
body_b->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint3D::_body_exit_tree));
|
||||
}
|
||||
}
|
||||
|
||||
PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue