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

Optimize animation blend tree process #68593

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

TokageItLab
Copy link
Member

@TokageItLab TokageItLab commented Nov 13, 2022

Optimize animation blend tree process.

Fixes #65199 (Partially)

In #57675 and #62623, for blending result consistency, it was necessary to blend animations even if the blend amount is 0 or don't have sync option.

The fundamental reason of this is that the blend values are initialized only on the track that will be blended in the only one frame that is just played.

Consistent blending by correct initialization:

1.mp4

Inconsistent blending due to lack of initialization on certain tracks:

2.mp4

This PR separates the initialization process and iterates through the TrackCache instead of the track that will be blended at that frame. This greatly reduces calculation cost while keeping the blending consistency. Well, this is just a re-implementation of the optimization that #57675 removed.

I confirmed that this would increase the FPS of the #65199 (comment) project at running by about 1.5 times.

Before:
image

After:
image

Also, these are the projects to check whether this PR will not change the behavior:
animation_blend_test.zip
character_controller_3d_sample.zip

As far as I have checked, this PR should not change the behavior of the blending, but I welcome anyone who is interested to test it. This is mention to people I remember talking about optimization before: @JoanPotatoes2021 @and-rad

This process optimization was the biggest issue, so I think we can now close #65199 for now. If this does not solve the problem of frame rate dropping with panning viewport, then perhaps it is a problem other than blending.

@akien-mga akien-mga merged commit dff8a51 into godotengine:master Nov 22, 2022
@akien-mga
Copy link
Member

Thanks!

@zacryol
Copy link
Contributor

zacryol commented Nov 23, 2022

This (or something related) may have caused the regression described in #69066
It's the only Animation-related PR listed on the release notes in between beta5 and beta6.

@TokageItLab
Copy link
Member Author

TokageItLab commented Nov 23, 2022

I think that issue has already been fixed in the follow-up PR, see #68993.

@atirut-w
Copy link
Contributor

Off topic, but something about those Suzanne-headed humanoids feels very uncomfortable.

Where can I get them?

@TokageItLab
Copy link
Member Author

There it is in the project for benchmarking uploaded by @JoanPotatoes2021 in #65199 (comment), but I don't know if you can use it as you want, just ask @JoanPotatoes2021. Yeah, Humanoid Suzanne is not cute, but I think it's nice as the enemy model.

@TokageItLab TokageItLab deleted the optimize-blend-animation branch February 14, 2024 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AnimationBlendTree performance issue
5 participants