Fix mesh instance materials not initialized correctly #42846
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.
This fixes a regression from PR #40313 (support for software skinning in
MeshInstance
).Before, the base mesh was always updated on load even if not skinning was used, which caused mesh instance materials to be reset on the rendering side.
Now the base mesh is set only when it has been modified (to avoid unnecessary updates on the render side), or when switching software skinning on or off. In this case the mesh instance materials are always updated properly afterwards.
Fixes #42675
CC @lawnjelly
Thanks for tracking the issue down! In the end I've chosen not to disable the whole call to initialize skinning as you suggested in #40313 (comment) because I want to make sure skinning is properly reset if needed when the skeleton path is changed.
Since the cause is calling
set_base
without updating materials afterwards it should be fine now.