Fix Skeleton3D
deprecated format missing pose
This commit is contained in:
parent
d3352813ea
commit
3fbbc3bbd6
1 changed files with 23 additions and 8 deletions
|
@ -95,10 +95,11 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
|
|||
} else if (what == "scale") {
|
||||
set_bone_pose_scale(which, p_value);
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
} else if (what == "pose") {
|
||||
} else if (what == "pose" || what == "bound_children") {
|
||||
// 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()));
|
||||
if (what == "pose") {
|
||||
// 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);
|
||||
|
@ -106,6 +107,20 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &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());
|
||||
} else { // bound_children
|
||||
// This handles the case where the pose was set to the rest position; the pose property would == Transform() and would not be saved to the scene by default.
|
||||
// However, the bound_children property was always saved regardless of value, and it was always saved after both pose and rest.
|
||||
// We don't do anything else with bound_children, as it's not present on Skeleton3D.
|
||||
Vector3 pos = get_bone_pose_position(which);
|
||||
Quaternion rot = get_bone_pose_rotation(which);
|
||||
Vector3 scale = get_bone_pose_scale(which);
|
||||
Transform3D rest = get_bone_rest(which);
|
||||
if (rest != Transform3D() && pos == Vector3() && rot == Quaternion() && scale == Vector3(1, 1, 1)) {
|
||||
set_bone_pose_position(which, rest.origin);
|
||||
set_bone_pose_rotation(which, rest.basis.get_rotation_quaternion());
|
||||
set_bone_pose_scale(which, rest.basis.get_scale());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue