| 775 | } |
| 776 | |
| 777 | void Skeleton2D::execute_modifications(real_t p_delta, int p_execution_mode) { |
| 778 | if (modification_stack.is_null()) { |
| 779 | return; |
| 780 | } |
| 781 | |
| 782 | // Do not cache the transform changes caused by the modifications! |
| 783 | for (uint32_t i = 0; i < bones.size(); i++) { |
| 784 | bones[i].bone->copy_transform_to_cache = false; |
| 785 | } |
| 786 | |
| 787 | if (modification_stack->skeleton != this) { |
| 788 | modification_stack->set_skeleton(this); |
| 789 | } |
| 790 | |
| 791 | modification_stack->execute(p_delta, p_execution_mode); |
| 792 | |
| 793 | // Only apply the local pose override on _process. Otherwise, just calculate the local_pose_override and reset the transform. |
| 794 | if (p_execution_mode == SkeletonModificationStack2D::EXECUTION_MODE::execution_mode_process) { |
| 795 | for (uint32_t i = 0; i < bones.size(); i++) { |
| 796 | if (bones[i].local_pose_override_amount > 0) { |
| 797 | bones[i].bone->set_meta("_local_pose_override_enabled_", true); |
| 798 | |
| 799 | Transform2D final_trans = bones[i].bone->cache_transform; |
| 800 | final_trans = final_trans.interpolate_with(bones[i].local_pose_override, bones[i].local_pose_override_amount); |
| 801 | bones[i].bone->set_transform(final_trans); |
| 802 | bones[i].bone->propagate_call("force_update_transform"); |
| 803 | |
| 804 | if (bones[i].local_pose_override_persistent) { |
| 805 | bones[i].local_pose_override_amount = 0.0; |
| 806 | } |
| 807 | } else { |
| 808 | /// @todo See if there is a way to undo the override without having to resort to setting every bone's transform. |
| 809 | bones[i].bone->remove_meta("_local_pose_override_enabled_"); |
| 810 | bones[i].bone->set_transform(bones[i].bone->cache_transform); |
| 811 | } |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | // Cache any future transform changes |
| 816 | for (uint32_t i = 0; i < bones.size(); i++) { |
| 817 | bones[i].bone->copy_transform_to_cache = true; |
| 818 | } |
| 819 | |
| 820 | #ifdef TOOLS_ENABLED |
| 821 | modification_stack->set_editor_gizmos_dirty(true); |
| 822 | #endif // TOOLS_ENABLED |
| 823 | } |
| 824 | |
| 825 | void Skeleton2D::_bind_methods() { |
| 826 | ClassDB::bind_method(D_METHOD("get_bone_count"), &Skeleton2D::get_bone_count); |
nothing calls this directly
no test coverage detected