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

Easings float operator #487

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from
Draft

Conversation

newemka
Copy link
Contributor

@newemka newemka commented Nov 4, 2024

An operator similar to [Spring] and [Damp]
We can select the easing function and set the duration.

This operator creates transitions between changing input values, perfect for animating any step change.
Note: The input value should evolve in steps (e.g., sudden changes) to fully utilize the easing effect.

Easing functions source: https://easings.net/

An operator similar to [Spring] and [Damp], we can select the easing function and set the duration.
Easing functions source: https://easings.net/
@domportera
Copy link
Collaborator

love this and long overdue 🙏 - i'd definitely want the type selection to be Enum-based though
If you can, pls define the enum in a separate .cs file to avoid issues when duplicating operators

It might also make things simpler on the user end to remove the Strength slot if we can live without it? since it only affects a couple of them, it would confuse me

@newemka
Copy link
Contributor Author

newemka commented Nov 5, 2024

Thanks a lot for your feedback.
I will start working on the separate .cs file now.
It's true that the Strength is not necessary since for more granular controls we have the Spring operators and they allow to reach the same kind of animation.

@domportera
Copy link
Collaborator

oh, i didnt mean separate the easing functions into a separate file! But I would happily take that change bc these functions could be useful for the editor >:) or the core math library! hell, the whole functiion float East(float val, EasingType type) could be a really nice to have as an editor/core math function. But we can pull that out when these ops get merged into main

what I meant was to make an enum instead of a switch statement on an integer (which you've done!) and have that in a separate file, so the input Ease would be
InputSlot<EasingType> Ease = new();

Seems like you're already in the process of doing so, just wanted to clarify bc i feel bad if I encouraged you to do more work than you needed to 😅

I also say this not knowing how well the editor supports just adding an enum slot like that though... 🤷‍♂️

@newemka
Copy link
Contributor Author

newemka commented Nov 6, 2024

I think the way I did it is okay. I have the enum and functions in [EasingFunctions.cs] So I can use them in any operator like Easings or EasingsVec3. Creating EasingsVec2 will be straight forward.

About InputSlot<EasingType> Ease = new(); , I have no idea how I could do that, I'm just following how it's done in the other operators, with an interger.

[Input(Guid = "9ef45ff9-9d59-44b7-b03d-37a1be40a776", MappedType = typeof(EasingFunctions.EasingType))]
        public readonly InputSlot<int> Ease = new();

Right now the only way to see the dropdown menu with the enums in the parameters window of an operator is to add , MappedType = typeof(EasingFunctions.EasingType) and the enums to the cs file of an operator.

Thus, duplicating such operator within the editor will give a int and won't show a dropdown menu.

Instead of having a dropdown list with 30 easing functions.
(pretty hard to read).
I've added a enum to select between In, Out and InOut.
Then it reduces the list to 10. Its way more readable.
@newemka
Copy link
Contributor Author

newemka commented Nov 10, 2024

This how the parameter window looks like
image

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