From bcad569ed9c2d547dbf48b40ef7db25c41015732 Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Wed, 10 Jan 2024 08:56:04 -0800 Subject: [PATCH] Skeleton3D: Convert 3.x skeletons --- scene/3d/skeleton_3d.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index 445c1003b5dd..11a79d636dde 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -95,6 +95,19 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { set_bone_pose_rotation(which, p_value); } else if (what == "scale") { set_bone_pose_scale(which, p_value); +#ifndef DISABLE_DEPRECATED + } else if (what == "pose") { + // Kept for compatibility from 3.x to 4.x. + WARN_DEPRECATED_MSG("Skeleton uses old pose format, which is deprecated (and loads slower). Consider re-importing or re-saving the scene." + + (is_inside_tree() ? vformat(" Path: \"%s\"", get_path()) : String())); + // Old Skeleton poses were relative to rest, new ones are absolute, so we need to recompute the pose. + // Skeleton3D nodes were always written with rest before pose, so this *SHOULD* work... + Transform3D rest = get_bone_rest(which); + Transform3D pose = rest * (Transform3D)p_value; + set_bone_pose_position(which, pose.origin); + set_bone_pose_rotation(which, pose.basis.get_rotation_quaternion()); + set_bone_pose_scale(which, pose.basis.get_scale()); +#endif } else { return false; }