Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use ExtractComponent derive macro for EnvironmentMapLight and FogSettings #10191

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions crates/bevy_pbr/src/environment_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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>,
Expand Down
15 changes: 3 additions & 12 deletions crates/bevy_pbr/src/fog.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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())
}
}