Fix missing material override after two glb reimports #96446
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem was because both objects in the scene inherited from the same resource. When the first inherited scene was loaded, the
MeshInstance3D
connected itself to the mesh'schanged
signal. Then, when the second inherited scene was loaded, theEditorNode
calledResourceLoader::load
withResourceFormatLoader::CACHE_MODE_REPLACE_DEEP
, forcing the mesh to reload a second time. However, since the firstMeshInstance3D
was already connected, when the loader updated the name of the mesh, it emitted thechanged
signal, triggeringMeshInstance3D::_mesh_changed
. The issue was thatset_name
was called before the mesh surfaces were loaded, causing thesurface_override_materials
to be resized to zero on the firstMeshInstance3D
.I replaced
ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP
withResourceFormatLoader::CACHE_MODE_REPLACE
. This should not cause any problems becauseEditorNode::reload_instances_with_path_in_edited_scenes
already reloads every scene in the inherited chain. In fact, this should improve scene reloading since, with the deep parameter, the mesh was being reloaded for each inherited level!I also retested this MRP that I used to test scene reimportation:
test-godot-blender-reimport-missing-node-v6.zip