Răsfoiți Sursa

Fix 2D bones ignored by onion skinning

Fixes #27819.
Pedro J. Estébanez 6 ani în urmă
părinte
comite
88153fbb61

+ 1 - 1
editor/plugins/animation_player_editor_plugin.cpp

@@ -1484,7 +1484,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
 		if (valid) {
 		if (valid) {
 			player->seek(pos, true);
 			player->seek(pos, true);
 			get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials
 			get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials
-			values_backup.update_skeletons(); // Needed for Skeletons
+			values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D)
 
 
 			VS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
 			VS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
 			VS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]);
 			VS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]);

+ 6 - 0
scene/2d/skeleton_2d.h

@@ -39,6 +39,9 @@ class Bone2D : public Node2D {
 	GDCLASS(Bone2D, Node2D)
 	GDCLASS(Bone2D, Node2D)
 
 
 	friend class Skeleton2D;
 	friend class Skeleton2D;
+#ifdef TOOLS_ENABLED
+	friend class AnimatedValuesBackup;
+#endif
 
 
 	Bone2D *parent_bone;
 	Bone2D *parent_bone;
 	Skeleton2D *skeleton;
 	Skeleton2D *skeleton;
@@ -71,6 +74,9 @@ class Skeleton2D : public Node2D {
 	GDCLASS(Skeleton2D, Node2D);
 	GDCLASS(Skeleton2D, Node2D);
 
 
 	friend class Bone2D;
 	friend class Bone2D;
+#ifdef TOOLS_ENABLED
+	friend class AnimatedValuesBackup;
+#endif
 
 
 	struct Bone {
 	struct Bone {
 		bool operator<(const Bone &p_bone) const {
 		bool operator<(const Bone &p_bone) const {

+ 8 - 0
scene/animation/animation_player.cpp

@@ -37,12 +37,20 @@
 
 
 #ifdef TOOLS_ENABLED
 #ifdef TOOLS_ENABLED
 #include "editor/editor_settings.h"
 #include "editor/editor_settings.h"
+#include "scene/2d/skeleton_2d.h"
 
 
 void AnimatedValuesBackup::update_skeletons() {
 void AnimatedValuesBackup::update_skeletons() {
 
 
 	for (int i = 0; i < entries.size(); i++) {
 	for (int i = 0; i < entries.size(); i++) {
 		if (entries[i].bone_idx != -1) {
 		if (entries[i].bone_idx != -1) {
+			// 3D bone
 			Object::cast_to<Skeleton>(entries[i].object)->notification(Skeleton::NOTIFICATION_UPDATE_SKELETON);
 			Object::cast_to<Skeleton>(entries[i].object)->notification(Skeleton::NOTIFICATION_UPDATE_SKELETON);
+		} else {
+			Bone2D *bone = Object::cast_to<Bone2D>(entries[i].object);
+			if (bone && bone->skeleton) {
+				// 2D bone
+				bone->skeleton->_update_transform();
+			}
 		}
 		}
 	}
 	}
 }
 }