Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix animation jumping back one frame when cross ConditionState using MAINTAIN_FRAME_ACROSS_STATES #770

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/game/client/draw/w3dmodeldraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,13 @@ float W3DModelDraw::Get_Current_Anim_Fraction() const
return 0.0f;
}

// #BUGFIX Fix animation jumping back one frame when crossing ConditionState using MAINTAIN_FRAME_ACROSS_STATES.
// Loop frame to beginning of animation if supported.
frame += 2.0f;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would have expected to add just one frame to advance the animation after we copy it from the previous animation state. But adding just one will duplicate the animation frame when crossing the ConditionState. It is unclear why it goes back one frame. Could be another bug somewhere else. However, if we are unable to observe other issues, then this fix is sufficient, otherwise just add one here if we find another place to avoid the deduction. Perhaps it is supposed to work like this and +2 frames is the correct approach.

As of right now this fix works for the observed issue. It would be good to test more scenarios to gain more confidence.

if (Test_Animation_Flag(m_curState->m_flags, RESTART_ANIM_WHEN_COMPLETE) && frame > frames) {
frame -= frames;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done to gracefully support edge case where it should get to begin of animation if it crossed the end of it.

}

if (frames > frame) {
return frame / (frames - 1.0f);
}
Expand Down