Skip to content

Fix MeshInstance3D::get_active_material() error on empty mesh or empty surfaces #107691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

smix8
Copy link
Contributor

@smix8 smix8 commented Jun 19, 2025

Fixes #105580

A MeshInstance3D without a Mesh resource (or empty surfaces) has also empty surface material arrays.

The get_active_material() function tried to access those empty internal material arrays and did run into index errors.

The correct order for checking what material is active is:

  • Check if there is a general geometry material override on the inherited GeometryInstance3D.
  • Check if a Mesh even exists and if it has surfaces.
  • Check the surface material override slot on the rendering instance.
  • Check the surface material slot on the mesh resource.

…y surfaces

FixesMeshInstance3D::get_active_material() error on empty mesh or empty surfaces.
@smix8 smix8 requested a review from a team as a code owner June 19, 2025 01:08
@AThousandShips AThousandShips added this to the 4.5 milestone Jun 19, 2025
@AThousandShips AThousandShips added the cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release label Jun 20, 2025
@Repiteo Repiteo merged commit 3c9f6aa into godotengine:master Jun 24, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 24, 2025

Thanks!

@smix8 smix8 deleted the mi_active_mat branch June 25, 2025 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release topic:editor topic:3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_active_material() throws an error on MeshInstance3D that has not yet had a mesh set on it yet when running from a @tool script
4 participants