diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-14 08:26:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-14 08:26:03 +0100 |
commit | 156d700f004d04e4a03ced23695c627fa3ff3fb3 (patch) | |
tree | 85973fec652f4af57cc401f123f7024c2b9a124c /scene/3d | |
parent | 8d4698db3656457eccfc54ea84716af146fb49a9 (diff) | |
parent | 95020d3e381cc44d70ddfd6c272392d19d877853 (diff) |
Merge pull request #45167 from madmiraal/fix-44703
Fix not clearing a Joint3D with only a B node when removing the B node
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/physics_joint_3d.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp index 0a2af6b0cd..326b91b6ed 100644 --- a/scene/3d/physics_joint_3d.cpp +++ b/scene/3d/physics_joint_3d.cpp @@ -114,21 +114,23 @@ void Joint3D::_update_joint(bool p_only_free) { return; } - if (!body_a) { - SWAP(body_a, body_b); - } - warning = String(); update_configuration_warning(); - joint = _configure_joint(body_a, body_b); + if (body_a) { + joint = _configure_joint(body_a, body_b); + } else if (body_b) { + joint = _configure_joint(body_b, nullptr); + } ERR_FAIL_COND_MSG(!joint.is_valid(), "Failed to configure the joint."); PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority); - ba = body_a->get_rid(); - body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree), make_binds(body_a->get_instance_id())); + if (body_a) { + ba = body_a->get_rid(); + body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree), make_binds(body_a->get_instance_id())); + } if (body_b) { bb = body_b->get_rid(); |