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

Added pingpong built-in function #46346

Closed
wants to merge 1 commit into from

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Feb 23, 2021

This math function used in Unity(https://docs.unity3d.com/ScriptReference/Mathf.PingPong.html), Blender, and (perhaps) many other engines. The proposal is to give users the same capability to use it as in them. This implementation is a copy from Blender with just cosmetical changes(should work as a Unity version, except for negative length values(which are not supported in the Unity for this function anyway)). Added to GDScript / C# / VisualScript.

@Chaosus Chaosus requested review from a team as code owners February 23, 2021 13:24
@Chaosus Chaosus added this to the 4.0 milestone Feb 23, 2021
@Chaosus Chaosus changed the title Added PingPong function Added PingPong math function Feb 23, 2021
@Chaosus Chaosus changed the title Added PingPong math function Added PingPong built-in function Feb 23, 2021
@Chaosus Chaosus changed the title Added PingPong built-in function Added pingpong built-in function Feb 23, 2021
@Calinou
Copy link
Member

Calinou commented Feb 23, 2021

What are some practical use cases for this function? It's usually better to use sin() or cos() for smoothly pulsing lights or emissive materials. (Linear pulsing lights or emissive materials often look bad in action.)

While I'm not against this change, I would advise using methods that result in smooth animations whenever possible.

@Chaosus
Copy link
Member Author

Chaosus commented Feb 23, 2021

@Calinou I have no idea by myself since I'm not using it, maybe some former Unity users may say why they like it and whether they want it in the Godot.

@aaronfranke
Copy link
Member

aaronfranke commented Feb 23, 2021

@Chaosus We don't just add features in case maybe someone will use it one day. This needs a proposal. If you aren't using it and don't know how it will be used, that is hardly a substantive use case. So I'm closing this as per the Godot proposal policy (since there is no use case here, one needs to be presented in a proposal before this can be considered).

  1. All proposals must be linked to a substantive use-case. In justifying your proposal, it is not enough to say it would be "nice" or "helpful". Use the template to show how Godot is not currently meeting your needs and then explain how your proposal will meet a particular need.

@Chaosus Chaosus deleted the ping_pong_func branch February 23, 2021 14:54
@Chaosus
Copy link
Member Author

Chaosus commented Feb 23, 2021

Ok, I forgot about it a bit...

@TokageItLab
Copy link
Member

TokageItLab commented Apr 30, 2021

Please restore this PR, so I need this for #48332!

That PR is to implement a ping-pong loop in the animation function, and without this function, it will have to write the same mathematical expression again and again.

In short, instead of normal loop using fposmod(), the ping-pong loop needs pingpong().

@fire
Copy link
Member

fire commented Apr 30, 2021

@Chaosus is currently unavailable, but we we discussed that if we are able to find a use, we can use it.

So we can put pingpong into your pr.

@TokageItLab
Copy link
Member

Yes, it has been merged into my PR, so there is no need to necessarily restore this one unless a step-by-step merge is required.

@Chaosus Chaosus deleted the ping_pong_func branch May 20, 2021 04:55
@aaronfranke
Copy link
Member

For the record, this has been implemented in #53819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants