How to adapt a CollisionShape3D on blend_shape (shape key) changed?

Godot Version

4.2.2 on ArchLinux


I have a blend file imported in Godot, using the -col suffix to automatically create StaticBody3D/CollisionShape3D children which works just fine. Some of my meshes have blend_shapes (shape keys in Blender). They also work fine.
What I cannot achieve is creating/changing an appropriate CollisionShape3D on changing the blend_shapes.

I tried using Mesh.create_trimesh_collision(), but it just generates the same shape as before, independent of the state of the blend_shape(s). How can I create a CollisionShape3D to match the “blend shaped mesh”?

Are you wanting to do this during runtime, when you change the shape of the mesh?

Yes. Imagine a cupboard door. If the door is open, I need another CollisionShape to interact with objects in the way or just two doors touching each other.

I could split these objects, and have a seperate mesh for every moving piece and just rotate it with its shape in place, but this would be a lot of work to respect a simple blend shape.

Using blend shapes for this is a overkill and not recommended for something so simple and static, especially if you require matching collision for the states.

There is so much more flexibility in what you can do with things if you just set this up as a cabinet scene with the doors as separate nodes that can have their own collision and then be setup to do simple tweens for the different states, and the collision will just follow along with the respective mesh instances.

Okay. Bad example. I’ve build a coffee machine which can be filled with water/coffee (the blend shape there moves mainly the z value of the water mesh), a button to switch on and of, a lid on top where you can put in the coffee, and so on.

The other example is to hard for me to explain, but those two blend shapes can be changed together. I would have to create a lot of meshes and a lot of collision shapes if I wanted to do this separately. (imagine one pulling x and z, the other y and z)

However. The point is doing most work in Blender as it is much easier to use than Godot. I also thought about using bones for the machine and creating animations and use them.

But for now, I just want to know how to match the CollisionShape to the blended mesh.

For all those searching a solution: There is a workaround in progress: Add option to bake a mesh from blend shape mix by smix8 · Pull Request #76725 · godotengine/godot · GitHub