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

Don't animate if there is nothing to animate #1494

Merged
merged 2 commits into from
May 3, 2022

Conversation

OrenAudeles
Copy link
Collaborator

Summary

SUMMARY: Performance "Do not go into animation loop if there is nothing to animate"

Purpose of change

When using animations the game will check for user input more quickly so that any active animations can progress. With terminal builds animations are fairly rare. This burns CPU time to do little of importance. A user reported high CPU usage with animations enabled on curses build that disappeared when disabled, even when there was no weather, SCT, nor after-life to animate.

Describe the solution

Check early to see if there is anything in need of animation. If there is something that requires we go into the faster animate loop do so. Otherwise treat it like animation is turned off to save some CPU time since new animations won't begin until at least after user input has been obtained.

In the case of TILES builds we will go ahead and enter animation loop anyway because there may be minimap or terrain animations to do and according to the comment these are not cached.

Describe alternatives you've considered

Leave it alone. For any recent CPUs the load from getting input isn't going to break anything. It's a minor problem.

Testing

Started character with animations off, stood still, observed CPU load for baseline.
Turned animations on with nothing around to animate, observed CPU load was similar.
Changed weather to rain, observed CPU load increase now that it has something to animate
Changed weather to clear, then got into a fight to see SCT animations, observed above baseline CPU load in small spikes
Died and watched the world move on.

Previous functionality remained.

Sent patch to reporting user to see if it helped them, it did.

@Coolthulhu Coolthulhu self-assigned this Apr 30, 2022
@Coolthulhu Coolthulhu merged commit 429a524 into cataclysmbnteam:upload May 3, 2022
@OrenAudeles OrenAudeles deleted the cursed_anim_cpu branch May 3, 2022 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants