-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Improve TextureProgressBar.set_radial_initial_angle()
by removing loops
#98816
Conversation
TextureProgress.set_radial_initial_angle()
by removing loops
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.
See above, does not solve the issue linked (only non-finite inputs)
Thanks for review, looks like I opened it too early.
Issue was Godot freeze, so technically it solves issue. |
It normally does but it'll cause errors, it also doesn't behave correctly with negative input |
Yes, for now it doesn't work well with negative input and I will fix it. |
A check with if (p_angle < -360.0 || p_angle > 360.0) {
p_angle = Math::fmod(p_angle, 360);
}
if (p_angle < 0.0) {
p_angle += 360.0;
} Should be sufficient You could also simply use: if (p_angle < 0.0 || p_angle > 360.0) {
p_angle = Math::fposmod(p_angle, 360);
} And I think some of the checks in that will be optimized out |
a3c3e56
to
7cd187c
Compare
Will test this code when I am able! |
@tool
extends EditorScript
func _run() -> void:
var temp_variable452 = TextureProgressBar.new()
var values : Array[float] = [360*1e4 + 10, - (360*1e4 + 10), INF, -INF]
for val : float in values:
temp_variable452.set_radial_initial_angle(val)
print(val)
print(temp_variable452.radial_initial_angle)
print("---") Output:
This matches with how it worked before (except for infinite numbers). |
7cd187c
to
21fa4d7
Compare
Replaced |
I suppose it's not strictly required but adding a test about this would be nice. |
Sure! I didn't touched Godot unit tests before but it will be definitely interesting to try. |
I suppose, yeah. The PR as is looks like an objective improvement. |
TextureProgress.set_radial_initial_angle()
by removing loopsTextureProgressBar.set_radial_initial_angle()
by removing loops
Sorry for the conflicting directives, but I think that adding the test in this PR would be best, so it can validate the change from this PR being correct. |
Good, I'll do it and close separate PR with test. |
I apologise for my own mistake! |
@Mickeon don't worry, it didn't take much time to merge changes into single branch :) |
21fa4d7
to
11034f4
Compare
Would be good to add test cases for non-finiteness as well |
11034f4
to
efbc643
Compare
Done. |
efbc643
to
58a866d
Compare
58a866d
to
0a4d48b
Compare
Replace two while loops with fposmodp. Document radial_initial_angle wrapping. Add testcases for set_radial_initial_angle()
0a4d48b
to
d692b7b
Compare
I applied suggestions and rebased branch. |
Thanks! |
Replace two while loops with if and
fposmodp
.Document
radial_initial_angle
wrapping.Infinite numbers will cause error and will not change
radial_initial_angle
value.Add testcase for set_radial_initial_angle() argument wrapping and skipping non-finite values.
Should fix #60338.