Skip to content

Commit

Permalink
Fixed incorrect blending in Pos/Rot/Scl Track
Browse files Browse the repository at this point in the history
  • Loading branch information
TokageItLab committed Nov 10, 2021
1 parent e317e34 commit 78f5ce0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
66 changes: 34 additions & 32 deletions scene/animation/animation_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,15 +934,12 @@ void AnimationTree::_process_graph(real_t p_delta) {
#ifndef _3D_DISABLED
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);

if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = Vector3();
t->rot = Quaternion();
t->rot_blend_accum = 0;
t->scale = Vector3(1, 1, 1);
}

if (track->root_motion) {
if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = Vector3();
}

double prev_time = time - delta;
if (!backward) {
if (prev_time < 0) {
Expand Down Expand Up @@ -1015,6 +1012,12 @@ void AnimationTree::_process_graph(real_t p_delta) {
Vector3 loc;

Error err = a->position_track_interpolate(i, time, &loc);

if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = loc;
}

if (err != OK) {
continue;
}
Expand All @@ -1027,15 +1030,12 @@ void AnimationTree::_process_graph(real_t p_delta) {
#ifndef _3D_DISABLED
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);

if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = Vector3();
t->rot = Quaternion();
t->rot_blend_accum = 0;
t->scale = Vector3(1, 1, 1);
}

if (track->root_motion) {
if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->rot = Quaternion();
}

double prev_time = time - delta;
if (!backward) {
if (prev_time < 0) {
Expand Down Expand Up @@ -1111,34 +1111,30 @@ void AnimationTree::_process_graph(real_t p_delta) {
Quaternion rot;

Error err = a->rotation_track_interpolate(i, time, &rot);

if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->rot = rot;
}

if (err != OK) {
continue;
}

if (t->rot_blend_accum == 0) {
t->rot = rot;
t->rot_blend_accum = blend;
} else {
real_t rot_total = t->rot_blend_accum + blend;
t->rot = rot.slerp(t->rot, t->rot_blend_accum / rot_total).normalized();
t->rot_blend_accum = rot_total;
}
t->rot = t->rot.slerp(rot, blend).normalized();
}
#endif // _3D_DISABLED
} break;
case Animation::TYPE_SCALE_3D: {
#ifndef _3D_DISABLED
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);

if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->loc = Vector3();
t->rot = Quaternion();
t->rot_blend_accum = 0;
t->scale = Vector3(1, 1, 1);
}

if (track->root_motion) {
if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->scale = Vector3(1, 1, 1);
}

double prev_time = time - delta;
if (!backward) {
if (prev_time < 0) {
Expand Down Expand Up @@ -1211,6 +1207,12 @@ void AnimationTree::_process_graph(real_t p_delta) {
Vector3 scale;

Error err = a->scale_track_interpolate(i, time, &scale);

if (t->process_pass != process_pass) {
t->process_pass = process_pass;
t->scale = scale;
}

if (err != OK) {
continue;
}
Expand Down
1 change: 0 additions & 1 deletion scene/animation/animation_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class AnimationTree : public Node {
bool scale_used = false;
Vector3 loc;
Quaternion rot;
real_t rot_blend_accum = 0.0;
Vector3 scale;

TrackCacheTransform() {
Expand Down

0 comments on commit 78f5ce0

Please sign in to comment.