Fix skinning initialization in MeshInstance when loaded from thread #48217
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 #48152 based on suggestion by @lawnjelly in #48152 (comment)
This is a fix for a regression from software skinning support (PR #40313):
instance_attach_skeleton
wasn't called inset_mesh
before, and it's causing issues when the mesh instance is loaded from a thread.instance_attach_skeleton
withRID()
in the visual server.instance_attach_skeleton
immediately with a valid skeletoninstance_attach_skeleton
resets the attached skeletonThis change prevents that to happen by making sure
instance_attach_skeleton
is not called onset_mesh
, the same way it was done before #40313.This fix seems to be fine for the specific case in #48152. I've tested with different projects from #40313 and things seem to still work correctly.
But:
There might be a more general problem to solve in how server commands are executed when resources are loaded from a different thread.
At the moment, they can be executed in the wrong order if the first ones are queued and the next ones are executed immediately. This could have other unpredictable side effects.
Maybe queued commands should be flushed when an immediate command is executed? I'm not sure if that would be ok for performance but it would make things much safer.