diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/skeleton.cpp | 18 | ||||
-rw-r--r-- | scene/3d/skeleton.h | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 25e76efeb4..95478f0b02 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -154,7 +154,19 @@ void Skeleton::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - _make_dirty(); + + //if moved, just update transforms + VisualServer *vs = VisualServer::get_singleton(); + Bone *bonesptr = &bones[0]; + int len = bones.size(); + 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]; + vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse)); + } } break; case NOTIFICATION_UPDATE_SKELETON: { @@ -245,8 +257,8 @@ void Skeleton::_notification(int p_what) { } } - Transform transform = b.pose_global * b.rest_global_inverse; - vs->skeleton_bone_set_transform(skeleton, i, global_transform * (transform * global_transform_inverse)); + b.transform_final = b.pose_global * b.rest_global_inverse; + vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse)); for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) { diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index fdc1100472..11ff728474 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -57,6 +57,8 @@ class Skeleton : public Spatial { bool custom_pose_enable; Transform custom_pose; + Transform transform_final; + List<uint32_t> nodes_bound; Bone() { |