godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Improve/add new collision import options around indirect CollisionShape children (depends on godotengine/godot#77937) #11170

Open funkysandwich opened 6 days ago

funkysandwich commented 6 days ago

Describe the project you are working on

A game which would use modular assets to build levels and props.

Describe the problem or limitation you are having in your project

Currently, within the scene importer, you can enable physics generation on an imported MeshInstance node, and select a physics type. Rigidbody, StaticBody, or Area.

This will generate a separate physics object for each mesh you enable this option for. This means there is no way to generate collision for several meshes under a single body. image

This is also limited to generating CollisionShapes, meaning you can't import custom CollisionShapes that were created prior within a 3D modeling application as children of the visual MeshInstance. image

If you want to generate only collisionshapes for a mesh, currently you would have to:

Since this scene is separate from the imported one, if I make any changes to the mesh externally and reimport, the collision would no longer match the mesh, and I would have to open the scene with the collision shapes, and regenerate and replace them manually.

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

Important: This feature would require https://github.com/godotengine/godot/pull/77937 be merged in order to work.

This way collision shapes will update on reimport and you can avoid having to generate them separately. Another small improvement would be for imported collision shapes to be named after the mesh that they are for, instead of leaving all shapes named CollisionShape3D

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

Locally, I have the PR for indirect collisionshape children working, and I also tried making some changes to the importer: Screenshot 2024-11-15 131014

Also, instead of changing the imported scene root type to a physics type, you could just add the imported scene underneath the physics type you want. So you could reuse the same imported scene for rigidbodies, staticbodies, and areas. Screenshot 2024-11-15 131410 Screenshot 2024-11-15 130924

You could also add several imported models as indirect children of a physics node instead of them needing to be separate bodies. Here's how you could create a StaticBody for a room and it's props using this: Screenshot 2024-11-15 132719

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

I'm not sure.

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

Importing scenes is core functionality in the editor. This would improve the modularity of imported assets when using them as part of larger physics objects.