@@ -633,8 +633,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
633
633
track_xform->bone_idx = bone_idx;
634
634
Transform3D rest = sk->get_bone_rest (bone_idx);
635
635
track_xform->init_loc = rest.origin ;
636
- track_xform->ref_rot = rest.basis .get_rotation_quaternion ();
637
- track_xform->init_rot = track_xform->ref_rot .log ();
636
+ track_xform->init_rot = rest.basis .get_rotation_quaternion ();
638
637
track_xform->init_scale = rest.basis .get_scale ();
639
638
}
640
639
}
@@ -667,8 +666,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
667
666
track_xform->init_loc = reset_anim->track_get_key_value (rt, 0 );
668
667
} break ;
669
668
case Animation::TYPE_ROTATION_3D: {
670
- track_xform->ref_rot = reset_anim->track_get_key_value (rt, 0 );
671
- track_xform->init_rot = track_xform->ref_rot .log ();
669
+ track_xform->init_rot = reset_anim->track_get_key_value (rt, 0 );
672
670
} break ;
673
671
case Animation::TYPE_SCALE_3D: {
674
672
track_xform->init_scale = reset_anim->track_get_key_value (rt, 0 );
@@ -1144,7 +1142,7 @@ void AnimationTree::_process_graph(double p_delta) {
1144
1142
continue ;
1145
1143
}
1146
1144
a->rotation_track_interpolate (i, (double )a->get_length (), &rot[1 ]);
1147
- t->rot + = (rot[ 1 ]. log () - rot[0 ].log ()) * blend;
1145
+ t->rot = (t-> rot * Quaternion (). slerp ( rot[0 ].inverse () * rot[ 1 ], blend)). normalized () ;
1148
1146
prev_time = 0 ;
1149
1147
}
1150
1148
} else {
@@ -1154,7 +1152,7 @@ void AnimationTree::_process_graph(double p_delta) {
1154
1152
continue ;
1155
1153
}
1156
1154
a->rotation_track_interpolate (i, 0 , &rot[1 ]);
1157
- t->rot + = (rot[ 1 ]. log () - rot[0 ].log ()) * blend;
1155
+ t->rot = (t-> rot * Quaternion (). slerp ( rot[0 ].inverse () * rot[ 1 ], blend)). normalized () ;
1158
1156
prev_time = 0 ;
1159
1157
}
1160
1158
}
@@ -1165,7 +1163,7 @@ void AnimationTree::_process_graph(double p_delta) {
1165
1163
}
1166
1164
1167
1165
a->rotation_track_interpolate (i, time, &rot[1 ]);
1168
- t->rot + = (rot[ 1 ]. log () - rot[0 ].log ()) * blend;
1166
+ t->rot = (t-> rot * Quaternion (). slerp ( rot[0 ].inverse () * rot[ 1 ], blend)). normalized () ;
1169
1167
prev_time = !backward ? 0 : (double )a->get_length ();
1170
1168
1171
1169
} else {
@@ -1182,10 +1180,7 @@ void AnimationTree::_process_graph(double p_delta) {
1182
1180
continue ;
1183
1181
}
1184
1182
1185
- if (signbit (rot.dot (t->ref_rot ))) {
1186
- rot = -rot;
1187
- }
1188
- t->rot += (rot.log () - t->init_rot ) * blend;
1183
+ t->rot = (t->rot * Quaternion ().slerp (t->init_rot .inverse () * rot, blend)).normalized ();
1189
1184
}
1190
1185
#endif // _3D_DISABLED
1191
1186
} break ;
@@ -1585,7 +1580,6 @@ void AnimationTree::_process_graph(double p_delta) {
1585
1580
case Animation::TYPE_POSITION_3D: {
1586
1581
#ifndef _3D_DISABLED
1587
1582
TrackCacheTransform *t = static_cast <TrackCacheTransform *>(track);
1588
- t->rot = t->rot .exp ();
1589
1583
1590
1584
if (t->root_motion ) {
1591
1585
Transform3D xform;
0 commit comments