-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Rect2().encloses(Rect2()) with same rect is false #26615
Comments
I suppose the question then would be "what is the desired functionality"? Should a rectangle enclose itself? What are the game programming use cases for true vs false? See also: #25829 Might want to look over all this code at once. |
if A is a Rect2 representing the game map area |
@xakz What's your use case for |
@akien-mga Probably none but: For world coordinates, it's not really a problem, but for map coordinates (TileMap) it's not what one expect. We expect a 1x1 tile fit in each corner of a 2x2 tile. Just some precisons in the doc could be enought. |
Rect2.encloses method is inconsistent now. |
Some geometry methods follow non-strict inequalities already: godot/doc/classes/Geometry.xml Lines 219 to 242 in 0827258
I've also had to define some constant to emulate strictness (copied directly from my custom camera class to be enclosed within world limits): const LIMIT_MARGIN = 1.0 # if 0.0 - strictly enclosed |
Result is false, expected true
Rect2(0,0,1,1).encloses( Rect2(0,0,1,1) )
Rect2(0,0,0,0).encloses( Rect2(0,0,0,0) )
godot/core/math/rect2.h
Line 99 in b16c309
Compared with java
I suggest simply do <= instead of <
https://github.com/godotengine/godot/blob/b16c309f82c77d606472c3c721a1857e323a09e7/core/math/rect2.h#L102-#L103
It will return true in this case which differs from Java but that should be fine.
Rect2(0,0,0,0).encloses( Rect2(0,0,0,0) )
The text was updated successfully, but these errors were encountered: