[3.x] Fix Blendshapes exploding on skinned Mesh replacement #47992
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.
Fixes #37854
Previously when a MeshInstance Mesh with Blendshapes was loaded or replaced on an animated Skeleton at runtime it could cause an unrepairable Mesh explosion on the next frame up to an entire (VisualServer) crash under bad circumstances.
Now when a Mesh is set or replaced any available Blendshape on the new Mesh is reset to default blendvalues AFTER updating Skin and Material Surfaces.
Issue was that only Skeleton Skins and Material Surfaces were updated on Mesh changes. Existing old blendvalues for the MeshInstance on the VisualServer could set the new Mesh off to a corrupted blending state.
In my tests all Blendshape related runtime loading and replacement crashes in Godot 3.x are 100% gone with this change (... and they hunted all my projects for months if not years now).
Godot 4.x had similar issues a few months back when blendshapes were first added back in. I have no blendshape test setup rightnow that runs on Godot 4.x and will keep it in mind for later.