godotengine / godot-proposals

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

Add MeshInstance option to get mesh from MeshLibrary #8036

Open aes opened 1 year ago

aes commented 1 year ago

Describe the project you are working on

tl;dr: Doesn't matter, this is basic MeshInstance use.

3D, first-person space ship game, where the ship and controls are embodied and diegetic, similar to Carrier Command 2. (Plan is to make the usual classic Elite vision, but with full focus on the peaceful trader play)

Describe the problem or limitation you are having in your project

I would like to be able to specify a mesh from a MeshLibrary instance in my scene as the actual mesh in my MeshInstance. This can be done right now, but weirdly, only using code:

func _ready():
    $MeshInstance3D.mesh = $GridMap.mesh_library.get_item_mesh(0)

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

Add this option to the menu in the MeshInstance UI, and ofc implement loading the resource and picking out the mesh.

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

Make it an option in the UI. (Or, at least, hint that more can be done with code)

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

It works now with a little code, it's just a very weird feature omission and if I didn't know to try harder, I would just see the absence and believe Godot can't do that.

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

It works now with a little code, it's just a very weird feature omission and if I didn't know to try harder, I would just see the absence and believe Godot can't do that.

Calinou commented 1 year ago

it's just a very weird feature omission

I think it's because it's an unusual workflow. I've never seen anyone do that in their project from a script, or even ask about doing something like that. This doesn't mean it's a bad idea, but we need to know clear use cases.

Out of curiosity, why do you need to load a mesh from a specific GridMap tile?

aes commented 1 year ago

I don't (necessarily) want to load a GridMap, I just want a mesh from a MeshLibrary. The GridMap in the example is just a way to load a MeshLibrary resource. (I just happened to have one when I noticed this omission).

An example of when I would want one of each, though, is 'destructible terrain'. A part of the spaceship comes loose and flies spiraling away, disconnected from the Gridmap. It should be easy to pick any GridMap tile, set it to nothing and create a MeshInstance in its place.

ImmaB commented 1 day ago

While the workaround works, it writes all the vertex data to the scene file instead of just a reference to the library and item. Changes to the source file will not automatically be applied. Can this even be solved by a workaround?