fix: more predictable spring behaviour #7011
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for bug described here: #7010
The proposed solution is that 'tick' should be added to the spring options. If the elapsed frame time is greater than this, then multiple tick calculations are carried out instead of the usual 1.
To prevent the number of rounds of calculations in a frame from increasing high enough to cause high cpu load (principally from when the user switches tab during a spring animation), it is proposed that there should be a configurable 'limit', which sets a limit on the number of ticks calculated per frame.
As this issue effects all springs, and is unlikely to cause issues with any existing usage, I think it may be appropriate for this to be the standard behaviour with sensible defaults.
I don't know if the proposed variable names are appropriate (it is hard to reduce a complex idea to a simple memorable term without losing some nuance.)
I haven't indented the existing code that should be indented to be in a loop, in order to make the changes clear. I've also not attempted to write any tests until I know that it would be worthwhile. This is my first attempt at submitting a pull request, so please let me know if I'm going about this at all wrong.