Extract borders without border radius (#15020)

# 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.
This commit is contained in:
ickshonpe 2024-09-02 23:47:43 +01:00 committed by GitHub
parent 61f9f8c5f6
commit 96942058f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -508,7 +508,7 @@ pub fn extract_uinode_borders(
Option<&Parent>, Option<&Parent>,
&Style, &Style,
&BorderColor, &BorderColor,
&BorderRadius, Option<&BorderRadius>,
), ),
Without<ContentSize>, Without<ContentSize>,
>, >,
@ -526,7 +526,7 @@ pub fn extract_uinode_borders(
parent, parent,
style, style,
border_color, border_color,
border_radius, maybe_border_radius,
) in &uinode_query ) in &uinode_query
{ {
let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_ui_camera.get()) let Some(camera_entity) = camera.map(TargetCamera::entity).or(default_ui_camera.get())
@ -574,14 +574,17 @@ pub fn extract_uinode_borders(
continue; continue;
} }
let border_radius = resolve_border_radius( let border_radius = if let Some(border_radius) = maybe_border_radius {
border_radius, let resolved_radius = resolve_border_radius(
node.size(), border_radius,
ui_logical_viewport_size, node.size(),
ui_scale.0, ui_logical_viewport_size,
); ui_scale.0,
);
let border_radius = clamp_radius(border_radius, node.size(), border.into()); clamp_radius(resolved_radius, node.size(), border.into())
} else {
[0.; 4]
};
let transform = global_transform.compute_matrix(); let transform = global_transform.compute_matrix();
extracted_uinodes.uinodes.insert( extracted_uinodes.uinodes.insert(