Use a different approach to update skeletons when transform changes
This commit is contained in:
parent
a54e3f72ce
commit
448b58ba4c
@ -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()) {
|
||||
|
||||
|
@ -57,6 +57,8 @@ class Skeleton : public Spatial {
|
||||
bool custom_pose_enable;
|
||||
Transform custom_pose;
|
||||
|
||||
Transform transform_final;
|
||||
|
||||
List<uint32_t> nodes_bound;
|
||||
|
||||
Bone() {
|
||||
|
Loading…
Reference in New Issue
Block a user