summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-12-21 17:36:39 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-12-21 17:36:39 -0300
commit7d0cabe9d30238ff2d9a05cecbbc22a45ce71ac1 (patch)
treeaff1db3d5ec6676e031bc29f370be2e340b17f3a /scene/3d
parent1fa9aac3e415f53a095e955c8a37000629d56dde (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.cpp7
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()) {