-
-
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
Snap half-px sprite offset the opposite way as canvas items #94305
Snap half-px sprite offset the opposite way as canvas items #94305
Conversation
For the sprite offset of `Sprite2D` and `AnimatedSprite2D`, rounding towards positive direction changes the snapping direction of odd-sized sprites with `centered=true` compared to 4.2 or earlier. This is likely an undesirable change, so it should be changed to round halfway values the opposite direction using `ceil(x - 0.5)`.
It makes sense to also change it in rich_text_label and renderer_canvas_cull (for compatibility)? |
We should hold off a bit on this one until we can discuss it more. I left some comments in the original ticket, as this seems to be expected behavior. This change would make rounding behavior inconsistent with the rest of Godot as well. |
I will leave this open for now, but feel free to close if the consensus is to close #94298 as not a bug. |
I think I'll just replace this with #94626. |
Why was this one closed? I'd think this would be a far more consistent and less corner-case-y way to address the current issue.
The previous behavior would round in a different direction based on whether the coordinate was positive or negative. The recent change to Right now I'm a pretty firm believer that this is the fix we need. While it needs testing, it's more consistent, less corner-case-y, and addresses the specific issue in a general way by making the math more consistent, not less. Could we please reopen this? |
...Not to mention, Godot 4.3 just now hit Release Candidate. I really don't think we have room to introduce any changes that have more potential for breakage than this one. |
@KeyboardDanni It breaks your PixelPerfectTest, one of the blocks show red. |
@adamscott Seems fine to me. Did you make any modifications to the test, or are you using any additional patches? |
I tried it with KeyboardDanni's project and not getting any red. From all my tests it doesn't help or hurt anything. If the majority of users prefer that half values round up for positions but offsets work in reverse and round down for half values then this seems to do the trick, but I believe if we reopen it the PR should include some documentation of this behavior somewhere for when questions arise... or like in all other cases two weeks go by and I forget. 😅 |
This PR makes things inconsistent between the sprite offset and node2d translation. Both offset and translation visually move the sprite, the two are not doing opposite things, so it does not really make sense for them to be rounded differently.
I am more inclined to consider #94298 to be not a bug, but not too strongly. Regardless, I don't think this is the correct "fix". |
For the sprite offset of
Sprite2D
andAnimatedSprite2D
, rounding towards positive direction changes the snapping direction of odd-sized sprites withcentered=true
compared to 4.2 or earlier. This is likely an undesirable change, so it should be changed to round halfway values the opposite direction usingceil(x - 0.5)
.