bevy/crates
ickshonpe 54733e82ae box-shadow clipping fix (#16790)
Instead of clipping the non-visable sections of box-shadows, the shadow
is scaled to fit into the remaining area after clipping because the
normalized coordinates that are meant to border the unclipped subsection
of the shadow are always set to `[Vec2::ZERO, Vec2::X, Vec2::ONE,
Vec2::Y]`,

Calculate the coordinates for the corners of the visible area.

Test app:

```rust
use bevy::color::palettes::css::RED;
use bevy::color::palettes::css::WHITE;
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);
    commands
        .spawn(Node {
            ..Default::default()
        })
        .with_children(|commands| {
            commands
                .spawn((
                    Node {
                        width: Val::Px(100.),
                        height: Val::Px(100.),
                        margin: UiRect {
                            left: Val::Px(100.),
                            top: Val::Px(300.),
                            ..Default::default()
                        },
                        overflow: Overflow::clip(),
                        ..Default::default()
                    },
                    BackgroundColor(WHITE.into()),
                ))
                .with_children(|commands| {
                    commands.spawn((
                        Node {
                            position_type: PositionType::Absolute,
                            left: Val::Px(50.),
                            top: Val::Px(50.),
                            width: Val::Px(100.),
                            height: Val::Px(100.),
                            ..Default::default()
                        },
                        BackgroundColor(RED.into()),
                        BoxShadow::from(ShadowStyle {
                            x_offset: Val::ZERO,
                            y_offset: Val::ZERO,
                            spread_radius: Val::Px(50.),
                            blur_radius: Val::Px(6.),
                            ..Default::default()
                        }),
                    ));
                });
        });
}
```

Main:
<img width="103" alt="bad_shadow"
src="https://github.com/user-attachments/assets/6f7ade0e-959f-4d18-92e8-903630eb8cd3"
/>

This PR:
<img width="98" alt="clipped_shadow"
src="https://github.com/user-attachments/assets/7f576c94-908c-4fe6-abaa-f18fefe05207"
/>
2025-01-03 19:26:37 +01:00
..
bevy_a11y Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_animation Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_app Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_asset Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_audio Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_color Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_core Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_core_pipeline Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_derive Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_dev_tools Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_diagnostic Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_dylib Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_ecs Expose SystemMeta's access field as part of public API (#16625) 2025-01-03 19:15:53 +01:00
bevy_encase_derive Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_gilrs Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_gizmos Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_gltf Make bevy_gltf compile without bevy_animation feature (#16551) 2025-01-03 19:15:53 +01:00
bevy_hierarchy Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_image Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_input Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_internal Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_log Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_macro_utils Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_math Fix atan2 docs (#16673) 2025-01-03 19:15:53 +01:00
bevy_mesh Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_mikktspace Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_pbr Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_picking picking: disable raycast backface culling for Mesh2d (#16657) 2025-01-03 19:15:53 +01:00
bevy_ptr Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_reflect Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_remote BrpQueryRow has field deserialization fix (#16613) 2025-01-03 19:15:53 +01:00
bevy_render Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_scene Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_sprite Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_state Make StateTransitionSteps public (#16612) 2025-01-03 19:15:53 +01:00
bevy_tasks Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_text Add missing registration for TextEntity (#16649) 2025-01-03 19:15:53 +01:00
bevy_time Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_transform Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_ui box-shadow clipping fix (#16790) 2025-01-03 19:26:37 +01:00
bevy_utils Release 0.15.0 2024-11-29 01:50:42 +01:00
bevy_window add missing type registration for Monitor (#16685) 2025-01-03 19:15:53 +01:00
bevy_winit Release 0.15.0 2024-11-29 01:50:42 +01:00