1
0
Fork 0

Discontinue exp map in blending

This commit is contained in:
Silc 'Tokage' Renew 2022-04-17 04:34:28 +09:00
parent 3639c27cf1
commit 3ce843c128
2 changed files with 7 additions and 14 deletions

View File

@ -633,8 +633,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_xform->bone_idx = bone_idx; track_xform->bone_idx = bone_idx;
Transform3D rest = sk->get_bone_rest(bone_idx); Transform3D rest = sk->get_bone_rest(bone_idx);
track_xform->init_loc = rest.origin; track_xform->init_loc = rest.origin;
track_xform->ref_rot = rest.basis.get_rotation_quaternion(); track_xform->init_rot = rest.basis.get_rotation_quaternion();
track_xform->init_rot = track_xform->ref_rot.log();
track_xform->init_scale = rest.basis.get_scale(); track_xform->init_scale = rest.basis.get_scale();
} }
} }
@ -667,8 +666,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_xform->init_loc = reset_anim->track_get_key_value(rt, 0); track_xform->init_loc = reset_anim->track_get_key_value(rt, 0);
} break; } break;
case Animation::TYPE_ROTATION_3D: { case Animation::TYPE_ROTATION_3D: {
track_xform->ref_rot = reset_anim->track_get_key_value(rt, 0); track_xform->init_rot = reset_anim->track_get_key_value(rt, 0);
track_xform->init_rot = track_xform->ref_rot.log();
} break; } break;
case Animation::TYPE_SCALE_3D: { case Animation::TYPE_SCALE_3D: {
track_xform->init_scale = reset_anim->track_get_key_value(rt, 0); track_xform->init_scale = reset_anim->track_get_key_value(rt, 0);
@ -1144,7 +1142,7 @@ void AnimationTree::_process_graph(double p_delta) {
continue; continue;
} }
a->rotation_track_interpolate(i, (double)a->get_length(), &rot[1]); a->rotation_track_interpolate(i, (double)a->get_length(), &rot[1]);
t->rot += (rot[1].log() - rot[0].log()) * blend; t->rot = (t->rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized();
prev_time = 0; prev_time = 0;
} }
} else { } else {
@ -1154,7 +1152,7 @@ void AnimationTree::_process_graph(double p_delta) {
continue; continue;
} }
a->rotation_track_interpolate(i, 0, &rot[1]); a->rotation_track_interpolate(i, 0, &rot[1]);
t->rot += (rot[1].log() - rot[0].log()) * blend; t->rot = (t->rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized();
prev_time = 0; prev_time = 0;
} }
} }
@ -1165,7 +1163,7 @@ void AnimationTree::_process_graph(double p_delta) {
} }
a->rotation_track_interpolate(i, time, &rot[1]); a->rotation_track_interpolate(i, time, &rot[1]);
t->rot += (rot[1].log() - rot[0].log()) * blend; t->rot = (t->rot * Quaternion().slerp(rot[0].inverse() * rot[1], blend)).normalized();
prev_time = !backward ? 0 : (double)a->get_length(); prev_time = !backward ? 0 : (double)a->get_length();
} else { } else {
@ -1182,10 +1180,7 @@ void AnimationTree::_process_graph(double p_delta) {
continue; continue;
} }
if (signbit(rot.dot(t->ref_rot))) { t->rot = (t->rot * Quaternion().slerp(t->init_rot.inverse() * rot, blend)).normalized();
rot = -rot;
}
t->rot += (rot.log() - t->init_rot) * blend;
} }
#endif // _3D_DISABLED #endif // _3D_DISABLED
} break; } break;
@ -1585,7 +1580,6 @@ void AnimationTree::_process_graph(double p_delta) {
case Animation::TYPE_POSITION_3D: { case Animation::TYPE_POSITION_3D: {
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track); TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
t->rot = t->rot.exp();
if (t->root_motion) { if (t->root_motion) {
Transform3D xform; Transform3D xform;

View File

@ -198,8 +198,7 @@ private:
bool rot_used = false; bool rot_used = false;
bool scale_used = false; bool scale_used = false;
Vector3 init_loc = Vector3(0, 0, 0); Vector3 init_loc = Vector3(0, 0, 0);
Quaternion ref_rot = Quaternion(0, 0, 0, 1); Quaternion init_rot = Quaternion(0, 0, 0, 1);
Quaternion init_rot = Quaternion(0, 0, 0, 0);
Vector3 init_scale = Vector3(1, 1, 1); Vector3 init_scale = Vector3(1, 1, 1);
Vector3 loc; Vector3 loc;
Quaternion rot; Quaternion rot;