-
-
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
Add docs note about remap returning undefined when istart == istop #91615
Conversation
doc/classes/@GlobalScope.xml
Outdated
@@ -1092,7 +1092,7 @@ | |||
<param index="3" name="ostart" type="float" /> | |||
<param index="4" name="ostop" type="float" /> | |||
<description> | |||
Maps a [param value] from range [code][istart, istop][/code] to [code][ostart, ostop][/code]. See also [method lerp] and [method inverse_lerp]. If [param value] is outside [code][istart, istop][/code], then the resulting value will also be outside [code][ostart, ostop][/code]. If this is not desired, use [method clamp] on the result of this function. | |||
Maps a [param value] from range [code][istart, istop][/code] to [code][ostart, ostop][/code]. See also [method lerp] and [method inverse_lerp]. If [param value] is outside [code][istart, istop][/code], then the resulting value will also be outside [code][ostart, ostop][/code]. If this is not desired, use [method clamp] on the result of this function. If [param istart] and [param istop] are the same, the function will return NaN, use [method is_nan] to guard against this. |
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.
Actually for istart == istop
case it can also return INF
or -INF
(these and NaN
can be checked against with is_finite
method).
Basically1:
value < istart == istop
then result islerp(ostart, ostop, -INF)
,value == istart == istop
then result islerp(ostart, ostop, NaN)
,value > istart == istop
then result islerp(ostart, ostop, INF)
.
Footnotes
@Frozenfire92 I'm not aware of that, but just wanted to point out that in theory it could happen. I think the simplest would be to state something like: I mean I don't see a point in getting into details about specifics of when exactly which value is returned, it seems very unlikely that user would want this specific behavior anyway. And saying it's undefined kinda already tells "handle it yourself (according to your needs)". 🙂 Thus in a similar manner I don't think tests are needed for the |
63fa379
to
d2d1203
Compare
d2d1203
to
2e55f60
Compare
@kleonc thanks for the suggestion, I've updated the PR to match |
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.
Overall LGTM!
(just small comment style nitpick)
ca5f951
to
6d2b7eb
Compare
Co-Authored-By: Rémi Verschelde <rverschelde@gmail.com> Co-Authored-By: kleonc <9283098+kleonc@users.noreply.github.com>
ab25f4e
to
26feefa
Compare
Thanks! |
Closes godotengine/godot-proposals#9680
It does not implement my initial proposal, and instead updates the documentation as suggested in the comments godotengine/godot-proposals#9680 (comment)
I haven't tested any other cases that could lead to NaN, might be worth just mentioning it can return NaN and to use is_nan, open to feedback hereIt was updated to be a bit more generic based on findings in the comments of this PR