godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add a Cloth Node #9058

Closed Jesusemora closed 7 months ago

Jesusemora commented 7 months ago

Describe the project you are working on

3D game

Describe the problem or limitation you are having in your project

Softbody is very useful for creating balls, baskets, nets, trampolines, curtains, flags and hanging pieces of fabric, but it is not suitable for making cloth for a character outside of a cape. The reason for this is that softbody is a physics object, so it moves on its own and reacts to all other physics nodes on the scene. The act of creating pins is also tedious and is not enough for all occasions. My proposal is to make a new node called cloth, which will be totally different from softbody.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The cloth node will be inherited from meshInstance3D, but have nothing in common with softbody. It will move with a skeleton just like a meshInstance3D, and we would set either a vertex group or paint weights onto it. The weights/vertex_group will determine what parts of the mesh will be affected by local physics. Finally, we can set a list of spheres, capsules or cubes as colliders.

There will be some advantages over softbody: 1 - position will remain local, tied to a skeleton, so it should have better performance. 2 - seamless transition with skinned meshes. 3 - setting a list of colliders should improve performance, and we can keep cloth away from the rest of the physics. 4 - if we use vertex groups, we skip the process of pinning used in softbody.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The mesh will be moved by the skeletal animation and then there will be physics calculations for the loose parts, given by the weights. I'm not an expert in physics, so I don't feel confident coming up with some pseudo-code of how it should work. But the parts with weights should not be affected by physics, or be partially affected.

If this enhancement will not be used often, can it be worked around with a few lines of script?

no

Is there a reason why this should be core and not an add-on in the asset library?

this is a core feature in other engines like unity, and currently missing from Godot. Cloth is not the same as softbody and there are no workarounds, softbody moves in space, but cloth should not move, it needs to be implemented separately. Softbody is still good for other uses, so it should stay as well.

Calinou commented 7 months ago

Thanks for the proposal! Consolidating in https://github.com/godotengine/godot-proposals/issues/2513.