Skip to content

SoftBody3D behaves incorrectly if transform is adjusted after it has been added to a scene #108090

@simpkins

Description

@simpkins

Tested versions

  • Reproducible in 4.4.1 and master

System information

Windows 11

Issue description

Changing the transform on a SoftBody3D object behaves incorrectly once it has been added to a scene.

If you change the transform of a SoftBody3D that is currently part of a scene, it then renders at the wrong location.
The transform appears like it might be getting applied twice somehow, and the physics simulation is now being done incorrect relative to the rendered location. For instance, setting body.global_transform to a value of (0, 1, 0) causes the mesh to instead be rendered at a height of 2, and when it falls via gravity it stops at y=1 rather than y=0. If you apply a transform that has a rotation, the mesh now appears to fall at an angle instead of falling downwards.

It appears like it is somewhat possible to adjust the transform by:

  1. remove the SoftBody3D from the scene tree
  2. change the SoftBody3D transform
  3. change the SoftBody3d mesh (this does reset the body vertices to their original mesh positions, so you cannot preserve the current mesh state)
  4. re-add the SoftBody3D back to the scene tree

However, even with this procedure there is still a graphical glitch where the mesh is rendered at the wrong location for 1 frame when it is first re-added to the scene. The SoftBody3D code has a simulation_started boolean flag intended to prevent this behavior, but it only works the very first time that the mesh is added to the scene, and is not reset when the mesh is removed from the scene.

Note that these transform bugs appear to occur with both Jolt and Godot physics engines.

Steps to reproduce

Load the attached MRP, and use the "Restore Transform", "Reset Mesh & Transform Out-of-scene", and "Raise Body" buttons to play around with changing the transform on the body.

Minimal reproduction project (MRP)

soft-body-updates.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    For team assessment

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions