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

Check if the current value of a spring is already set to what you're trying to update it to #38

Open
ewd3v opened this issue Sep 11, 2024 · 3 comments

Comments

@ewd3v
Copy link
Contributor

ewd3v commented Sep 11, 2024

So basically checking if output.cache is equal to "v" when trying to set the current position of a spring (similar to source.luau).

I doubt this would ever happen normally unless you're trying to set the spring to its current value, or if you are setting it to its target position (after it's reached it).
I don't really believe it would have any performance benefits as graph.update_descendants is only called the next time the spring is stepped, but it wouldn't hurt adding.

@centau
Copy link
Owner

centau commented Sep 12, 2024

This isn't necessary because what spring() does is create an effect internally to the input source. But the input source will not run effects if it is set to the same value. So this not-equals check you are proposing is already being done, just not by the spring.

@ewd3v
Copy link
Contributor Author

ewd3v commented Sep 14, 2024

Not sure if it was clear but I meant to add this check for the feature added in this pull request #36

The reason I proposed this was because to me it looks like the spring would still schedule itself to be updated even if the position you set it to was the position it was already at.

@centau
Copy link
Owner

centau commented Nov 6, 2024

Sorry for the late reply,

I see what you mean now. Since the purpose of that pull request was to allow the instant setting of a spring's current output, as well as the resetting of its velocity, there may be the rare case that output.cache is equal to the new value but the velocity is non-zero and you intend to reset the velocity which this change would prevent you from doing.

In any other case it isn't a performance concern anyways because the spring will unschedule itself in the next step.

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

No branches or pull requests

2 participants