From 5a09694dec4057e4c53351ef4de3fccf2252aaf3 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Sun, 12 Jun 2022 19:14:48 +0000 Subject: [PATCH] Overflow::Hidden doesn't work correctly with scale_factor_override (#3854) # Objective Overflow::Hidden doesn't work correctly with scale_factor_override. If you run the Bevy UI example with scale_factor_override 3 you'll see half clipped text around the edges of the scrolling listbox. The problem seems to be that the corners of the node are transformed before the amount of clipping required is calculated. But then that transformed clip is compared to the original untransformed size of the node rect to see if it should be culled or not. With a higher scale factor the relative size of the untransformed node rect is going to be really big, so the overflow isn't culled. # Solution Multiply the size of the node rect by extracted_uinode.transform before the cull test. --- crates/bevy_ui/src/render/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index b4bcb94e0a..598dd10eaa 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -438,9 +438,11 @@ pub fn prepare_uinodes( positions[3] + positions_diff[3].extend(0.), ]; + let transformed_rect_size = extracted_uinode.transform.transform_vector3(rect_size); + // Cull nodes that are completely clipped - if positions_diff[0].x - positions_diff[1].x >= rect_size.x - || positions_diff[1].y - positions_diff[2].y >= rect_size.y + if positions_diff[0].x - positions_diff[1].x >= transformed_rect_size.x + || positions_diff[1].y - positions_diff[2].y >= transformed_rect_size.y { continue; }