Skip to content

Commit f7ca732

Browse files
authored
Merge pull request godotengine#60308 from TokageItLab/remove-exp-map-in-blending
Discontinue exp map in blending
2 parents 50bb184 + 3ce843c commit f7ca732

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

scene/animation/animation_tree.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
633633
track_xform->bone_idx = bone_idx;
634634
Transform3D rest = sk->get_bone_rest(bone_idx);
635635
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();
638637
track_xform->init_scale = rest.basis.get_scale();
639638
}
640639
}
@@ -667,8 +666,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
667666
track_xform->init_loc = reset_anim->track_get_key_value(rt, 0);
668667
} break;
669668
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);
672670
} break;
673671
case Animation::TYPE_SCALE_3D: {
674672
track_xform->init_scale = reset_anim->track_get_key_value(rt, 0);
@@ -1144,7 +1142,7 @@ void AnimationTree::_process_graph(double p_delta) {
11441142
continue;
11451143
}
11461144
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();
11481146
prev_time = 0;
11491147
}
11501148
} else {
@@ -1154,7 +1152,7 @@ void AnimationTree::_process_graph(double p_delta) {
11541152
continue;
11551153
}
11561154
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();
11581156
prev_time = 0;
11591157
}
11601158
}
@@ -1165,7 +1163,7 @@ void AnimationTree::_process_graph(double p_delta) {
11651163
}
11661164

11671165
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();
11691167
prev_time = !backward ? 0 : (double)a->get_length();
11701168

11711169
} else {
@@ -1182,10 +1180,7 @@ void AnimationTree::_process_graph(double p_delta) {
11821180
continue;
11831181
}
11841182

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();
11891184
}
11901185
#endif // _3D_DISABLED
11911186
} break;
@@ -1585,7 +1580,6 @@ void AnimationTree::_process_graph(double p_delta) {
15851580
case Animation::TYPE_POSITION_3D: {
15861581
#ifndef _3D_DISABLED
15871582
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
1588-
t->rot = t->rot.exp();
15891583

15901584
if (t->root_motion) {
15911585
Transform3D xform;

scene/animation/animation_tree.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ class AnimationTree : public Node {
198198
bool rot_used = false;
199199
bool scale_used = false;
200200
Vector3 init_loc = Vector3(0, 0, 0);
201-
Quaternion ref_rot = Quaternion(0, 0, 0, 1);
202-
Quaternion init_rot = Quaternion(0, 0, 0, 0);
201+
Quaternion init_rot = Quaternion(0, 0, 0, 1);
203202
Vector3 init_scale = Vector3(1, 1, 1);
204203
Vector3 loc;
205204
Quaternion rot;

0 commit comments

Comments
 (0)