-
Notifications
You must be signed in to change notification settings - Fork 120
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
Rounding errors can accumulate and cause nodes to expand each time a layout is recomputed #501
Comments
The problem seems to be how rust rounds ties away from zero. So here the node ranges horizontally from -148.5 to 151.5 and then after rounding away from zero the range becomes -149 to 152, increasing the width by 1. Replacing the fn round_half_up(
value: f32,
) -> f32 {
if 0. < value || value.trunc() - value != 0.5 {
value.round()
} else {
value.ceil()
}
} seems to work, but I'm not sure about it. |
Huh. This is bizarre. Relayouts should not in any way depend on rounded values from previous layout runs. I'm thinking this is really a caching issue (using stale rounded values) rather than a rounding issue. I think we might need to:
But that's just a guess at this point. I will need to investigate properly. |
Ah, so layout doesn't take rounded values as an input. But the rounding process itself does. I think the fix for this will indeed be to store unrounded values in addition to rounded values. We could also look at changing the rounding algorithm to |
* WIP * When rounding is enabled, also store unrounded layout values. Fixes #501 * Remove get_raw method from Cache struct * Update rounding relayout test to actually assert * cargo fmt * Fix doc links * Rename abs_x/abs_y to cumulative_x/cumulative_y * Document when final_layout is rounded vs unrounded
taffy
version0.3.10 and main 868b85d
What you did
What went wrong
The width of the inner node expands by a pixel each time the layout is recomputed.
Additional information
This only happens when rounding is enabled.
The text was updated successfully, but these errors were encountered: