godotengine / godotengine/godot
`PhysicsServer3D.joint_disable_collisions_between_bodies` permanently affects bodies even after joint deletion
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in 4.5.1.stable
### System information
Godot v4.5.1.stable - Windows 11 (build 26100) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1660 SUPER (NVIDIA; 32.0.15.9159) - Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz (16 threads) - 15.92 GiB memory
### Issue description
If `PhysicsServer3D.joint_disable_collisions_between_bodies` is used to disable collisions on a joint, this collision exception will permanently remain even after using `PhysicsServer3D.joint_clear` and/or `PhysicsServer3D.free_rid`. This is inconsistent to the behaviour when using an equivalent `Joint3D` node, which properly removes the collision exception when it is deleted.
The only way to remove the effect is to explicitly call `PhysicsServer3D.joint_disable_collisions_between_bodies` again before clearing the joint. This should not be necessary, because the collision exception should be within the scope of the joint. Otherwise, users should just use `PhysicsServer3D.body_add_collision_exception`.
https://github.com/user-attachments/assets/01712291-b199-401c-b250-1c38c5e93998
### Steps to reproduce
- Open attached project and play the main scene.
- Observe the two identical joints, one being created using a node, and the other using `PhysicsServer3D` directly.
- Press the `Delete Joints` button.
- Observe that one pair of capsules properly collide with each other again, while the other do not.
### Minimal reproduction project (MRP)
[bug-report-2.zip](https://github.com/user-attachments/files/24657702/bug-report-2.zip)
Contributor guide
Research direction
Start with the attached minimal reproduction project and trace the PhysicsServer3D calls to joint_disable_collisions_between_bodies, joint_clear, and free_rid. Compare the direct PhysicsServer3D behavior with the equivalent Joint3D node deletion. Done means deleting the direct joint restores collisions between the two bodies without an extra disable call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100