Avoid crashes in skeleton

This commit is contained in:
Juan Linietsky 2018-01-03 17:27:13 -03:00
parent 16a49cca04
commit cd63407aa4

View file

@ -160,14 +160,14 @@ void Skeleton::_notification(int p_what) {
//if moved, just update transforms //if moved, just update transforms
VisualServer *vs = VisualServer::get_singleton(); VisualServer *vs = VisualServer::get_singleton();
Bone *bonesptr = &bones[0]; const Bone *bonesptr = bones.ptr();
int len = bones.size(); int len = bones.size();
Transform global_transform = get_global_transform(); Transform global_transform = get_global_transform();
Transform global_transform_inverse = global_transform.affine_inverse(); Transform global_transform_inverse = global_transform.affine_inverse();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Bone &b = bonesptr[i]; const Bone &b = bonesptr[i];
vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse)); vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse));
} }
} break; } break;