Merge pull request #91936 from jsjtxietian/body-connect
Avoid duplicate connect in Joint2D and Joint3D `_update_joint`
This commit is contained in:
commit
77470740de
|
@ -116,8 +116,12 @@ void Joint2D::_update_joint(bool p_only_free) {
|
|||
ba = body_a->get_rid();
|
||||
bb = body_b->get_rid();
|
||||
|
||||
body_a->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint2D::_body_exit_tree));
|
||||
body_b->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint2D::_body_exit_tree));
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -106,12 +106,16 @@ void Joint3D::_update_joint(bool p_only_free) {
|
|||
|
||||
if (body_a) {
|
||||
ba = body_a->get_rid();
|
||||
body_a->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint3D::_body_exit_tree));
|
||||
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();
|
||||
body_b->connect(SceneStringName(tree_exiting), callable_mp(this, &Joint3D::_body_exit_tree));
|
||||
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