mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
chore: use ExtractComponent derive macro for EnvironmentMapLight and FogSettings (#10191)
I've done tiny cleanup when playing with code. ## Solution [derive macro](https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/macros/src/extract_component.rs) with `extract_component_filter` attribute generate the same code I removed. ## Migration Guide No migration needed
This commit is contained in:
parent
15c54b5542
commit
dcc35120f9
2 changed files with 5 additions and 23 deletions
|
@ -46,7 +46,8 @@ impl Plugin for EnvironmentMapPlugin {
|
|||
/// The diffuse map uses the Lambertian distribution, and the specular map uses the GGX distribution.
|
||||
///
|
||||
/// `KhronosGroup` also has several prefiltered environment maps that can be found [here](https://github.com/KhronosGroup/glTF-Sample-Environments).
|
||||
#[derive(Component, Reflect, Clone)]
|
||||
#[derive(Component, Reflect, Clone, ExtractComponent)]
|
||||
#[extract_component_filter(With<Camera3d>)]
|
||||
pub struct EnvironmentMapLight {
|
||||
pub diffuse_map: Handle<Image>,
|
||||
pub specular_map: Handle<Image>,
|
||||
|
@ -60,16 +61,6 @@ impl EnvironmentMapLight {
|
|||
}
|
||||
}
|
||||
|
||||
impl ExtractComponent for EnvironmentMapLight {
|
||||
type Query = &'static Self;
|
||||
type Filter = With<Camera3d>;
|
||||
type Out = Self;
|
||||
|
||||
fn extract_component(item: bevy_ecs::query::QueryItem<'_, Self::Query>) -> Option<Self::Out> {
|
||||
Some(item.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_bindings<'a>(
|
||||
environment_map_light: Option<&EnvironmentMapLight>,
|
||||
images: &'a RenderAssets<Image>,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::ReflectComponent;
|
||||
use bevy_ecs::{prelude::*, query::QueryItem};
|
||||
use bevy_ecs::prelude::*;
|
||||
use bevy_math::Vec3;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Camera};
|
||||
|
@ -47,7 +47,8 @@ use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Ca
|
|||
///
|
||||
/// Once enabled for a specific camera, the fog effect can also be disabled for individual
|
||||
/// [`StandardMaterial`](crate::StandardMaterial) instances via the `fog_enabled` flag.
|
||||
#[derive(Debug, Clone, Component, Reflect)]
|
||||
#[derive(Debug, Clone, Component, Reflect, ExtractComponent)]
|
||||
#[extract_component_filter(With<Camera>)]
|
||||
#[reflect(Component)]
|
||||
pub struct FogSettings {
|
||||
/// The color of the fog effect.
|
||||
|
@ -474,13 +475,3 @@ impl Default for FogSettings {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtractComponent for FogSettings {
|
||||
type Query = &'static Self;
|
||||
type Filter = With<Camera>;
|
||||
type Out = Self;
|
||||
|
||||
fn extract_component(item: QueryItem<Self::Query>) -> Option<Self::Out> {
|
||||
Some(item.clone())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue