Improve performance when apply bone transform in get_bone_global_pose() #42681
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.
Improve performance when apply bone transform in
get_bone_global_pose()
by implementing bone_children and associating them with dirty flag and option: bypass updating skins.The current implementation of Skeleton is that if you call
get_bone_global_pose()
after transforming a bone, recalculate transformation all the bones in the skeleton and access the visual (rendering) server for updating the skin. However, the current implementation causes a lot of waste waste when computing the bones in the same thread.For example, a skeleton has 100 bones. If the transformation is applied to the bone at the base of the skeleton's right index finger, then the necessary recalculation would normally only require 3 times recalculation, so including the child. However, in the current implementation, it would be recalculated 100 times.
Also, under normal circumstances, applying the skin only needs to be done once at the end of the thread. If you want to transform a bone multiple times with
get_bone_global_pose()
in the same thread, slows down performance because accessing the visual server multiple times.These issues have resulted in very poor performance when using
get_bone_global_pose()
in add-ons that simulate bone transformation, such as IK and DynamicBone. In order to lay the groundwork for future add-on development, I make two main changes in this PRget_bone_global_pose()
I actually saw a large performance improvement in the DynamicBone I created for 3D model's hair.