Skip to content

Commit

Permalink
Skeleton3D: Convert 3.x skeletons
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitalita committed Jan 20, 2024
1 parent 3524346 commit bcad569
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scene/3d/skeleton_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit bcad569

Please sign in to comment.