summaryrefslogtreecommitdiffstats
path: root/scene/3d/physics
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-05-15 12:09:50 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-05-15 12:09:50 +0200
commit77470740de5f0a915ec901e350abe0d2ce4c31d1 (patch)
tree4f29afdbe56aab7832e1f22975ec1c343998fd77 /scene/3d/physics
parentb802c7274fffb0fbce293ccb40063628d8aac6e4 (diff)
parent51bc55598c5cea7eaae1190a7ecea321c4e1785e (diff)
downloadredot-engine-77470740de5f0a915ec901e350abe0d2ce4c31d1.tar.gz
Merge pull request #91936 from jsjtxietian/body-connect
Avoid duplicate connect in Joint2D and Joint3D `_update_joint`
Diffstat (limited to 'scene/3d/physics')
-rw-r--r--scene/3d/physics/joints/joint_3d.cpp8
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 8feec9e0e7..47c89f37e2 100644
--- a/scene/3d/physics/joints/joint_3d.cpp
+++ b/scene/3d/physics/joints/joint_3d.cpp
@@ -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);