bevy/crates/bevy_pbr/src
Torstein Grindvik 67aa2953d0 Extract component derive (#7399)
# Objective

In simple cases we might want to derive the `ExtractComponent` trait.
This adds symmetry to the existing `ExtractResource` derive.

## Solution

Add an implementation of `#[derive(ExtractComponent)]`.
The implementation is adapted from the existing `ExtractResource` derive macro.

Additionally, there is an attribute called `extract_component_filter`. This allows specifying a query filter type used when extracting.
If not specified, no filter (equal to `()`) is used.

So:

```rust
#[derive(Component, Clone, ExtractComponent)]
#[extract_component_filter(With<Fuel>)]
pub struct Car {
    pub wheels: usize,
}
```

would expand to (a bit cleaned up here):

```rust
impl ExtractComponent for Car
{
    type Query = &'static Self;
    type Filter = With<Fuel>;
    type Out = Self;
    fn extract_component(item: QueryItem<'_, Self::Query>) -> Option<Self::Out> {
        Some(item.clone())
    }
}
```

---

## Changelog

- Added the ability to `#[derive(ExtractComponent)]` with an optional filter.
2023-01-30 18:12:16 +00:00
..
prepass Wgpu 0.15 (#7356) 2023-01-29 20:27:30 +00:00
render Wgpu 0.15 (#7356) 2023-01-29 20:27:30 +00:00
alpha.rs Standard Material Blend Modes (#6644) 2023-01-21 21:46:53 +00:00
bundle.rs Cascaded shadow maps. (#7064) 2023-01-25 12:35:39 +00:00
fog.rs Add Distance and Atmospheric Fog support (#6412) 2023-01-29 15:28:56 +00:00
lib.rs Add Distance and Atmospheric Fog support (#6412) 2023-01-29 15:28:56 +00:00
light.rs Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
material.rs Standard Material Blend Modes (#6644) 2023-01-21 21:46:53 +00:00
pbr_material.rs Add Distance and Atmospheric Fog support (#6412) 2023-01-29 15:28:56 +00:00
wireframe.rs Extract component derive (#7399) 2023-01-30 18:12:16 +00:00