Backported from Godot 4: Fixed value track blend animation without RESET - TokageItLab

0fe723a1ac
This commit is contained in:
Relintai 2022-08-12 17:28:51 +02:00
parent ec9eb18aaf
commit 65f8c774a8

View File

@ -626,11 +626,13 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_xform->skeleton = nullptr; track_xform->skeleton = nullptr;
track_xform->bone_idx = -1; track_xform->bone_idx = -1;
bool has_rest = false;
if (path.get_subname_count() == 1 && Object::cast_to<Skeleton>(spatial)) { if (path.get_subname_count() == 1 && Object::cast_to<Skeleton>(spatial)) {
Skeleton *sk = Object::cast_to<Skeleton>(spatial); Skeleton *sk = Object::cast_to<Skeleton>(spatial);
track_xform->skeleton = sk; track_xform->skeleton = sk;
int bone_idx = sk->find_bone(path.get_subname(0)); int bone_idx = sk->find_bone(path.get_subname(0));
if (bone_idx != -1) { if (bone_idx != -1) {
has_rest = true;
track_xform->bone_idx = bone_idx; track_xform->bone_idx = bone_idx;
Transform rest = sk->get_bone_rest(bone_idx); Transform rest = sk->get_bone_rest(bone_idx);
track_xform->init_loc = rest.origin; track_xform->init_loc = rest.origin;
@ -659,7 +661,8 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} }
} }
if (has_reset_anim) { // For non Skeleton3D bone animation.
if (has_reset_anim && !has_rest) {
int rt = reset_anim->find_track(path, track_type); int rt = reset_anim->find_track(path, track_type);
if (rt >= 0 && reset_anim->track_get_key_count(rt) > 0) { if (rt >= 0 && reset_anim->track_get_key_count(rt) > 0) {
switch (track_type) { switch (track_type) {
@ -1160,9 +1163,9 @@ void AnimationTree::_process_graph(float p_delta) {
if (!t->init_value) { if (!t->init_value) {
t->init_value = value; t->init_value = value;
t->init_value.zero(); t->init_value.zero();
} else {
t->value = t->init_value;
} }
t->value = t->init_value;
} }
Variant::sub(value, t->init_value, value); Variant::sub(value, t->init_value, value);