vide icon indicating copy to clipboard operation
vide copied to clipboard

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

Open ewd3v opened this issue 1 year ago • 2 comments

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.

ewd3v avatar Sep 11 '24 21:09 ewd3v

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.

centau avatar Sep 12 '24 10:09 centau

Not sure if it was clear but I meant to add this check for the feature added in this pull request https://github.com/centau/vide/pull/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.

ewd3v avatar Sep 14 '24 11:09 ewd3v

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.

centau avatar Nov 06 '24 20:11 centau