Skip to content

Commit

Permalink
Extract borders without border radius (#15020)
Browse files Browse the repository at this point in the history
# Objective

The `BorderRadius` component shouldn't be required to draw borders for
nodes with sharp corners.

## Solution

Make `BorderRadius` optional in `extract_uinode_borders`'s UI node
query.
  • Loading branch information
ickshonpe authored Sep 2, 2024
1 parent 61f9f8c commit 9694205
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ pub fn extract_uinode_borders(
Option<&Parent>,
&Style,
&BorderColor,
&BorderRadius,
Option<&BorderRadius>,
),
Without<ContentSize>,
>,
Expand All @@ -526,7 +526,7 @@ pub fn extract_uinode_borders(
parent,
style,
border_color,
border_radius,
maybe_border_radius,
) in &uinode_query
{
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_ui_camera.get())
Expand Down Expand Up @@ -574,14 +574,17 @@ pub fn extract_uinode_borders(
continue;
}

let border_radius = resolve_border_radius(
border_radius,
node.size(),
ui_logical_viewport_size,
ui_scale.0,
);

let border_radius = clamp_radius(border_radius, node.size(), border.into());
let border_radius = if let Some(border_radius) = maybe_border_radius {
let resolved_radius = resolve_border_radius(
border_radius,
node.size(),
ui_logical_viewport_size,
ui_scale.0,
);
clamp_radius(resolved_radius, node.size(), border.into())
} else {
[0.; 4]
};
let transform = global_transform.compute_matrix();

extracted_uinodes.uinodes.insert(
Expand Down

0 comments on commit 9694205

Please sign in to comment.