Fix SoftBody3D's position influences its physics in Jolt#112483
Fix SoftBody3D's position influences its physics in Jolt#112483Repiteo merged 1 commit intogodotengine:masterfrom
SoftBody3D's position influences its physics in Jolt#112483Conversation
|
@mihe, can you please look at this carefully. It solves the MRP that was provided, but I might have broken other things. |
SoftBody3D's position influences its physics in Jolt
@jrouwe It does indeed seem to break the re-adding of a It also seems to trigger a Jolt assertion when the body is added back again: EDIT: It looks like the Jolt assertion happens even without this PR, so I guess that's something to address separately. Apart from that, I'm not seeing any issues in the few projects I've tested with. Functionality that involve the vertex positions, like moving pinned vertices, seems to work fine. |
The position of a soft body was always kept at identity. This introduced computational errors when moving the soft body away from the origin. Translation is now stored in the soft body's position rather than in its vertices. Fixes godotengine#112348
|
I have not triggered any assert on my side. The way the transforms are handled with soft bodies is 'interesting'. The problem is that in godot/modules/jolt_physics/objects/jolt_soft_body_3d.cpp Lines 602 to 604 in 6fd949a I'm not sure if that means that
|
Are you using
Yeah,
Well, I'm not sure how I missed this in my initial implementation, but it turns out this whole sharing of godot/scene/3d/physics/soft_body_3d.cpp Lines 471 to 476 in 6fd949a godot/scene/3d/physics/soft_body_3d.cpp Lines 498 to 506 in 6fd949a It's only in the editor (for some reason) that the meshes are left as-is and thus shared, which I guess I must have extrapolated to think that it applied to runtime as well, without actually double-checking to see if that was the case. I guess there's reasonable justification for just removing all that stuff then, which would not only simplify the code a bit, but also mean that |
You're more than welcome to. |
Since the soft body meshes are always copied before simulation, the shared map never actually shared data with anything. This also makes it possible to create the mesh in local space the 2nd time it gets added to a space. Fixes an assert in inertia calculation and a 1 frame inaccuracy in the pressure calculation. See godotengine#112483 (comment)
Since the soft body meshes are always copied before simulation, the shared map never actually shared data with anything. This also makes it possible to create the mesh in local space the 2nd time it gets added to a space. Fixes an assert in inertia calculation and a 1 frame inaccuracy in the pressure calculation. See godotengine#112483 (comment)
|
Thanks! |
|
Cherry-picked for 4.5.2. |

The position of a soft body was always kept at identity. This introduced computational errors when moving the soft body away from the origin. Translation is now stored in the soft body's position rather than in its vertices.
Fixes #112348