diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-12-21 17:36:39 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-12-21 17:36:39 -0300 |
commit | 7d0cabe9d30238ff2d9a05cecbbc22a45ce71ac1 (patch) | |
tree | aff1db3d5ec6676e031bc29f370be2e340b17f3a /scene/3d | |
parent | 1fa9aac3e415f53a095e955c8a37000629d56dde (diff) |
Change skeleton processing to work on global coordinates, should help fix many import problems from Blender, GLTF2, etc.
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/skeleton.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index d0e0937eca..3d40bb299a 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -180,6 +180,9 @@ void Skeleton::_notification(int p_what) { rest_global_inverse_dirty = false; } + Transform global_transform = get_global_transform(); + Transform global_transform_inverse = global_transform.affine_inverse(); + for (int i = 0; i < len; i++) { Bone &b = bonesptr[i]; @@ -239,7 +242,9 @@ void Skeleton::_notification(int p_what) { } } - vs->skeleton_bone_set_transform(skeleton, i, b.pose_global * b.rest_global_inverse); + Transform transform = b.pose_global * b.rest_global_inverse; + + vs->skeleton_bone_set_transform(skeleton, i, global_transform * (transform * global_transform_inverse)); for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) { |