-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Print warnings when using a Rect2 or AABB with a negative size #37626
Conversation
80884ca
to
d4ba379
Compare
I don't think this is a good idea. If I am not mistaking, the negative scale for Rect2 is purposefully used in sprite regions to allow for textures flips, which does make sense. Generally, adding warning is not a good thing. They add noise for use cases where people might do something on purpose. Either the API is not good, and then we forbid negative scale (which I don't think is a good idea), either we throw an error. There should not be an "in-between" behavior where you do things almost right. Also, if a behavior is "undefined", we should define it in the documentation. We don't fix things by just throwing a warning. |
I don't get what you mean by defining it in the documentation. For some methods, like "has_point", it fails with negative size. How is documenting "It doesn't work" better than having a warning?
Well, this is a common approach in many pieces of software. Giving up and throwing errors was one of the unique things that Unix did to stay lean and performant. Maybe the warnings need to only show up for some methods, to allow some uses without yelling at the user? I'll add "needs testing" then. |
If it does not work consistently with negative scales, then it is a bug, which should be fixed. And if it has an undefined behavior, then we should instead document the behavior in the documentation. Adding a warning stating "this behavior is undefined" instead of fixing the problem itself, when the problem is easy to solve, is probably the worst solution to the problem.
When the program crashes, it's not a problem to throw logs to explain why. When it does not crashes, like Godot does, we should avoid warning as much as possible, especially when there is a valid use case to the feature.
No, as I said it is definitely better to implement a correct version of all functions there, and document the behavior in such case. If it needs to automatically transform the rect to a positive scale, then it should be stated in the documentation. |
6a5cb91
to
ea6da2b
Compare
91d1aaa
to
9d62dda
Compare
9d62dda
to
99e2a5a
Compare
df1bf2f
to
4a2e532
Compare
4a2e532
to
320397a
Compare
320397a
to
1f2158c
Compare
1f2158c
to
7c7efc4
Compare
7c7efc4
to
830375b
Compare
830375b
to
c2fc835
Compare
c2fc835
to
6c4b972
Compare
6c4b972
to
6aa3885
Compare
6f8eda7
to
d4dd794
Compare
d4dd794
to
3f015e6
Compare
3f015e6
to
9978aa1
Compare
9978aa1
to
31377ca
Compare
31377ca
to
1ead0db
Compare
1ead0db
to
e948152
Compare
e948152
to
6a36cb9
Compare
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.
PR meeting:
- This is good and we want to merge.
- This should be an error, not a warning
- It needs an
unlikely
added to the if checks - We need to make sure docs state negative sizes aren't supported
- It should say unsupported, not undefined
Thank you for contributing!
6a36cb9
to
9687f6f
Compare
|
Merged as discussed in the PR meeting. |
Edit: Reverted due to regressions / false positive warnings. |
There are various issues caused by this change (linked above) which warrant more discussion on whether this was a good idea. For now I'm reverting it in |
Fixes #23711, fixes #25829, fixes #37617 (or at the very least, mitigates them by showing a warning).
One idea mentioned in #37617 is to make the code in Rect2 automatically correct this, but that would be bad for a number of reasons, including performance and the fact that
abs()
might not actually be the desired solution. I think the best idea is to print a warning, letting the user know something's up.Note 1: I didn't actually test if the warnings show up specifically for each of the above bugs, but I would be surprised if they didn't (and if so, they can just be re-opened).
Note 2: I noticed that there were a few typos of
Point2
being used in place ofPoint2i
, I fixed them.Part of this is mutually exclusive with #38310, so if this is merged then #38310 should be closed.