Skip to content
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

round_ties_up fix #9548

Merged
merged 2 commits into from
Aug 23, 2023
Merged

Conversation

ickshonpe
Copy link
Contributor

Objective

round_ties_up checks the predicate:

0. <= value || value.fract() != 0.5

which is meant to determine if the value is negative with a fractional part of 0.5.

However given a negative value, fract returns a negative fraction so the predicate is true for all numeric values and ceil is never called.

Solution

Changed the predicate to value.fract() != -0.5 and added a test.
Also improved the comments a bit.

 `0. <= value || value.fract() != 0.5`
 which is meant to determine if the value is negative with a fractional part of `0.5`.

 However given a negative value, `fract` returns a negative fraction so the predicate is true for all numeric values and `ceil` is never called.

Solution:
Changed the predicate to `value.fract() != -0.5` and added a test.

Also improved the comments for `round_layout_coords`.
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets labels Aug 23, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Aug 23, 2023
Copy link
Contributor

@rparrett rparrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems clearly broken before / fixed after.

@mockersf mockersf added this pull request to the merge queue Aug 23, 2023
Merged via the queue into bevyengine:main with commit 8edcd82 Aug 23, 2023
24 checks passed
@mockersf
Copy link
Member

Just to confirm, this PR made a small visual change in example overflow_debug:

text-switch.mp4

It feels OK for me

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Aug 24, 2023

Just to confirm, this PR made a small visual change in example overflow_debug:

Yep this is as expected, overflow_debug and z_index are the only UI examples which use negative coordinates atm. z_index can also show changes but only with certain scale factors (1.5 should work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants