-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[Mono] Rename Fposmod to PosMod, fix output #19231
Conversation
There is nothing in the name |
Does it help to have inline documentation? Editors such as MonoDevelop can read this. We could add this for other methods later, if we want. Also, I've realized it would be useful to have an integer version of this method, so I've added one. |
464f2ee
to
e9627b1
Compare
By the way, test code:
Output:
Output should be increasing, but looping around range ( With old
|
The example from the docs indicates that it should return within the range http://docs.godotengine.org/en/3.0/classes/[email protected]#class-gdscript-fposmod |
@KellyThomas This is inconsistent with the positive values, and thus with the wording "wraps equally in positive and negative". I've submitted another PR to fix the C++ code: #19279 |
e9627b1
to
600410d
Compare
[Mono] Rename Fposmod to PosMod
600410d
to
5b2b23c
Compare
@neikeq I've changed the function name to Since you've already concluded that the fix is correct, we should merge so that we have a consistent C# API before Godot 3.1 Alpha on July 1st. Unlike in the C++ code, nothing depends on this function (yet). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. However, if this code is a mirror of the new implementation being introduced in #19279, then I would prefer both PRs to be merged at the same time to avoid problems.
Cherry picked into 3.0.6 |
#18364 (comment)
None of the other float-returning methods start with the letter F
It's not PascalCase if you count
pos
andmod
as wordsTheIn the interest of clarity and somewhat keeping consistency with the C++ math, I've kept the wordpos
distinction is not necessary because for "non-positive modulus" also known as "remainder" there's already an operator in C# called %. People using the Mathf function would only ever be looking for something that wasn't in the C# language.Pos
.PosMod()
looks a lot cleaner thanFposmod()
.Also, I've changed the code inside the method. In my tests, this version works much better. The previous version of the code produces incorrect output for some values.
As someone who uses this function a lot in my code, I would definitely appreciate this change.