Skip to content

Check material array size

This prevents one of the crashes mentioned in #24635 (closed) though it fights a symptom, not the cause.

For some reason there is a delay of a few frames between calling ArrayMesh::add_surface_from_arrays, it causing MeshInstance::_mesh_changed to be executed (which resizes our materials array to match the number of surfaces) and our visual server becoming aware of the resized materials array. That still needs further investigation.

The fix in this PR simply checks if the materials array has the right size and ensures the render pipeline doesn't crash but instead simply uses the default material. This is the same outcome as when the materials array would have been resized as it still would not hold any overridden materials.

Bugsquad edit: Fixes #23790 (closed).

Merge request reports