diff options
author | jsjtxietian <jsjtxietian@outlook.com> | 2024-05-14 16:41:43 +0800 |
---|---|---|
committer | jsjtxietian <jsjtxietian@outlook.com> | 2024-05-15 11:57:51 +0800 |
commit | 51bc55598c5cea7eaae1190a7ecea321c4e1785e (patch) | |
tree | 36ff70ed16f0c448634af6ff3c7137970f1d4032 /scene/3d/physics | |
parent | 557f63d03796db78255f055b6d06cb5f9195ff7e (diff) | |
download | redot-engine-51bc55598c5cea7eaae1190a7ecea321c4e1785e.tar.gz |
Avoid duplicate connect in `Joint2D::_update_joint` and Joint3D
Diffstat (limited to 'scene/3d/physics')
-rw-r--r-- | scene/3d/physics/joints/joint_3d.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scene/3d/physics/joints/joint_3d.cpp b/scene/3d/physics/joints/joint_3d.cpp index dac52a4dd8..88ae49beaa 100644 --- a/scene/3d/physics/joints/joint_3d.cpp +++ b/scene/3d/physics/joints/joint_3d.cpp @@ -108,12 +108,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); |