godotengine / godot-proposals

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

Make `MeshInstance3D.get_active_material(int p_surface)` use `0` as a default value #10597

Open shahriarlabib000 opened 3 weeks ago

shahriarlabib000 commented 3 weeks ago

Describe the project you are working on

I was trying to access a MeshInstance3D's material. It only had one material.

Describe the problem or limitation you are having in your project

Not really a limitation just for convenience. Same for These https://github.com/godotengine/godot/blob/fd7239cfab228c50777cd54a8bf6eb279a02ef81/scene/3d/mesh_instance_3d.h#L86-#L88

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

Convenient when you only want to access a single/first material

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

Something like this maybe Ref<Material> get_active_material(int p_surface=0) const;

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

Yes,infact you don't even need any extra line just mesh.get_active_material(0)

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

I don't know

shahriarlabib000 commented 3 weeks ago

So I updated the code.But couldn't test it since I'm using Android.But yeah if this gets approved maybe I'll attempt a pull request. Here is the updated branch