Description
Tested versions
- Reproducible in 4.5-beta1 and 4.4
System information
Windows 11
Issue description
When pinning SoftBody3D points in the editor, it's possible to get index out of bounds errors.
Jolt Physics logs errors like "Index 461 of pinned vertex in soft body 'SoftBody3D:<SoftBody3D#2319114652763>' is out of bounds. There are only 24 vertices in the current mesh."
Godot Physics logs errors like "Condition "p_index >= (int)map_visual_to_physics.size()" is true."
This might be the same underlying bug as #56168, but I'm not positive. That report doesn't have quite the same reproduction steps, and a lot of things have changed since that issue was filed.
The issue is that SoftBody3D does not always keep the physics server mesh in sync with the mesh used by the MeshInstance3D. When the mesh is changed in the editor it often does not update the physics server, resulting in the physics server having old out-of-date mesh information.
When not in the editor, SoftBody3D calls set_physics_process_internal(true)
and each time it receives
NOTIFICATION_INTERNAL_PHYSICS_PROCESS it checks to see if the mesh has been changed. When running in the editor it does not register for this notification, and never tells the physics server about changes to the mesh.
I think the best fix here would be to change SoftBody3D
to process the mesh update directly in set_mesh()
instead of checking after the fact in several other places to try and detect if the mesh has been changed since it last checked.
Steps to reproduce
- Open the attached MRP, which contains a SoftBody3D using a BoxMesh.
- Replace the mesh with a SphereMesh
- Try pinning some points by clicking on some of the vertex handles (with the default sphere settings of 64 segments and 32 rings you'll very likely get a vertex index higher than the box mesh vertex).
When the editor first opens the scene and adds the SoftBody3D to the world it tells the physics server about the BoxMesh, but when you change the mesh to a SphereMesh it never tells the physics server about the change.
Minimal reproduction project (MRP)
Metadata
Metadata
Assignees
Type
Projects
Status