MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / execute_modifications

Method execute_modifications

scene/2d/skeleton_2d.cpp:777–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775}
776
777void 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
825void Skeleton2D::_bind_methods() {
826 ClassDB::bind_method(D_METHOD("get_bone_count"), &Skeleton2D::get_bone_count);

Callers

nothing calls this directly

Calls 10

propagate_callMethod · 0.80
sizeMethod · 0.65
executeMethod · 0.65
is_nullMethod · 0.45
set_skeletonMethod · 0.45
set_metaMethod · 0.45
interpolate_withMethod · 0.45
set_transformMethod · 0.45
remove_metaMethod · 0.45

Tested by

no test coverage detected