mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Reflect derived traits on all components and resources: bevy_pbr (#15224)
Solves https://github.com/bevyengine/bevy/issues/15187 for bevy_pbr
This commit is contained in:
parent
d878e2f8bd
commit
b6b28a621f
15 changed files with 37 additions and 27 deletions
|
@ -6,6 +6,7 @@ use bevy_asset::Handle;
|
|||
use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::entity::{Entity, EntityHashMap};
|
||||
use bevy_ecs::{bundle::Bundle, component::Component, reflect::ReflectComponent};
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::{
|
||||
mesh::Mesh,
|
||||
|
@ -50,14 +51,14 @@ impl<M: Material> Default for MaterialMeshBundle<M> {
|
|||
/// This component contains all mesh entities visible from the current light view.
|
||||
/// The collection is updated automatically by [`crate::SimulationLightSystems`].
|
||||
#[derive(Component, Clone, Debug, Default, Reflect, Deref, DerefMut)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Debug, Default)]
|
||||
pub struct VisibleMeshEntities {
|
||||
#[reflect(ignore)]
|
||||
pub entities: Vec<Entity>,
|
||||
}
|
||||
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Debug, Default)]
|
||||
pub struct CubemapVisibleEntities {
|
||||
#[reflect(ignore)]
|
||||
data: [VisibleMeshEntities; 6],
|
||||
|
|
|
@ -80,7 +80,7 @@ pub struct ClusterZConfig {
|
|||
|
||||
/// Configuration of the clustering strategy for clustered forward rendering
|
||||
#[derive(Debug, Copy, Clone, Component, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Debug, Default)]
|
||||
pub enum ClusterConfig {
|
||||
/// Disable cluster calculations for this view
|
||||
None,
|
||||
|
|
|
@ -50,7 +50,7 @@ use bevy_render::{extract_component::ExtractComponent, prelude::Camera};
|
|||
/// [`StandardMaterial`](crate::StandardMaterial) instances via the `fog_enabled` flag.
|
||||
#[derive(Debug, Clone, Component, Reflect, ExtractComponent)]
|
||||
#[extract_component_filter(With<Camera>)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct DistanceFog {
|
||||
/// The color of the fog effect.
|
||||
///
|
||||
|
|
|
@ -16,7 +16,7 @@ use super::*;
|
|||
/// }
|
||||
/// ```
|
||||
#[derive(Resource, Clone, Debug, ExtractResource, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
#[reflect(Resource, Debug, Default)]
|
||||
pub struct AmbientLight {
|
||||
pub color: Color,
|
||||
/// A direct scale factor multiplied with `color` before being passed to the shader.
|
||||
|
|
|
@ -48,7 +48,7 @@ use super::*;
|
|||
/// .insert_resource(DirectionalLightShadowMap { size: 2048 });
|
||||
/// ```
|
||||
#[derive(Component, Debug, Clone, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct DirectionalLight {
|
||||
pub color: Color,
|
||||
/// Illuminance in lux (lumens per square meter), representing the amount of
|
||||
|
|
|
@ -88,7 +88,7 @@ pub mod light_consts {
|
|||
}
|
||||
|
||||
#[derive(Resource, Clone, Debug, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
#[reflect(Resource, Debug, Default)]
|
||||
pub struct PointLightShadowMap {
|
||||
pub size: usize,
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ pub type WithLight = Or<(With<PointLight>, With<SpotLight>, With<DirectionalLigh
|
|||
|
||||
/// Controls the resolution of [`DirectionalLight`] shadow maps.
|
||||
#[derive(Resource, Clone, Debug, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
#[reflect(Resource, Debug, Default)]
|
||||
pub struct DirectionalLightShadowMap {
|
||||
pub size: usize,
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ impl Default for DirectionalLightShadowMap {
|
|||
/// }.into();
|
||||
/// ```
|
||||
#[derive(Component, Clone, Debug, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct CascadeShadowConfig {
|
||||
/// The (positive) distance to the far boundary of each cascade.
|
||||
pub bounds: Vec<f32>,
|
||||
|
@ -271,7 +271,7 @@ impl From<CascadeShadowConfigBuilder> for CascadeShadowConfig {
|
|||
}
|
||||
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Debug, Default)]
|
||||
pub struct Cascades {
|
||||
/// Map from a view to the configuration of each of its [`Cascade`]s.
|
||||
pub(crate) cascades: EntityHashMap<Vec<Cascade>>,
|
||||
|
@ -439,7 +439,7 @@ fn calculate_cascade(
|
|||
}
|
||||
/// Add this component to make a [`Mesh`] not cast shadows.
|
||||
#[derive(Debug, Component, Reflect, Default)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct NotShadowCaster;
|
||||
/// Add this component to make a [`Mesh`] not receive shadows.
|
||||
///
|
||||
|
@ -447,7 +447,7 @@ pub struct NotShadowCaster;
|
|||
/// cause both “regular” shadows as well as diffusely transmitted shadows to be disabled,
|
||||
/// even when [`TransmittedShadowReceiver`] is being used.
|
||||
#[derive(Debug, Component, Reflect, Default)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct NotShadowReceiver;
|
||||
/// Add this component to make a [`Mesh`] using a PBR material with [`diffuse_transmission`](crate::pbr_material::StandardMaterial::diffuse_transmission)`> 0.0`
|
||||
/// receive shadows on its diffuse transmission lobe. (i.e. its “backside”)
|
||||
|
@ -457,7 +457,7 @@ pub struct NotShadowReceiver;
|
|||
///
|
||||
/// **Note:** Using [`NotShadowReceiver`] overrides this component.
|
||||
#[derive(Debug, Component, Reflect, Default)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct TransmittedShadowReceiver;
|
||||
|
||||
/// Add this component to a [`Camera3d`](bevy_core_pipeline::core_3d::Camera3d)
|
||||
|
@ -466,7 +466,7 @@ pub struct TransmittedShadowReceiver;
|
|||
/// The different modes use different approaches to
|
||||
/// [Percentage Closer Filtering](https://developer.nvidia.com/gpugems/gpugems/part-ii-lighting-and-shadows/chapter-11-shadow-map-antialiasing).
|
||||
#[derive(Debug, Component, ExtractComponent, Reflect, Clone, Copy, PartialEq, Eq, Default)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug, PartialEq)]
|
||||
pub enum ShadowFilteringMethod {
|
||||
/// Hardware 2x2.
|
||||
///
|
||||
|
|
|
@ -18,7 +18,7 @@ use super::*;
|
|||
///
|
||||
/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
|
||||
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct PointLight {
|
||||
/// The color of this light source.
|
||||
pub color: Color,
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::*;
|
|||
/// shines light only in a given direction. The direction is taken from
|
||||
/// the transform, and can be specified with [`Transform::looking_at`](Transform::looking_at).
|
||||
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct SpotLight {
|
||||
pub color: Color,
|
||||
/// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
|
||||
|
|
|
@ -48,9 +48,11 @@
|
|||
|
||||
use bevy_asset::{AssetId, Handle};
|
||||
use bevy_ecs::{
|
||||
bundle::Bundle, component::Component, query::QueryItem, system::lifetimeless::Read,
|
||||
bundle::Bundle, component::Component, query::QueryItem, reflect::ReflectComponent,
|
||||
system::lifetimeless::Read,
|
||||
};
|
||||
use bevy_math::Quat;
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::{
|
||||
extract_instances::ExtractInstance,
|
||||
|
@ -84,6 +86,7 @@ pub const ENVIRONMENT_MAP_SHADER_HANDLE: Handle<Shader> =
|
|||
///
|
||||
/// See [`crate::environment_map`] for detailed information.
|
||||
#[derive(Clone, Component, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct EnvironmentMapLight {
|
||||
/// The blurry image that represents diffuse radiance surrounding a region.
|
||||
pub diffuse_map: Handle<Image>,
|
||||
|
|
|
@ -132,7 +132,7 @@
|
|||
//!
|
||||
//! [Why ambient cubes?]: #why-ambient-cubes
|
||||
|
||||
use bevy_ecs::component::Component;
|
||||
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
||||
use bevy_render::{
|
||||
render_asset::RenderAssets,
|
||||
render_resource::{
|
||||
|
@ -145,6 +145,7 @@ use bevy_render::{
|
|||
use std::{num::NonZero, ops::Deref};
|
||||
|
||||
use bevy_asset::{AssetId, Handle};
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
use bevy_reflect::Reflect;
|
||||
|
||||
use crate::{
|
||||
|
@ -166,6 +167,7 @@ pub(crate) const IRRADIANCE_VOLUMES_ARE_USABLE: bool = cfg!(not(target_arch = "w
|
|||
///
|
||||
/// See [`crate::irradiance_volume`] for detailed information.
|
||||
#[derive(Clone, Default, Reflect, Component, Debug)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct IrradianceVolume {
|
||||
/// The 3D texture that represents the ambient cubes, encoded in the format
|
||||
/// described in [`crate::irradiance_volume`].
|
||||
|
|
|
@ -103,7 +103,7 @@ pub struct LightProbePlugin;
|
|||
/// specific technique but rather to a class of techniques. Developers familiar
|
||||
/// with other engines should be aware of this terminology difference.
|
||||
#[derive(Component, Debug, Clone, Copy, Default, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct LightProbe;
|
||||
|
||||
/// A GPU type that stores information about a light probe.
|
||||
|
|
|
@ -20,6 +20,7 @@ use bevy_ecs::{
|
|||
prelude::*,
|
||||
system::{lifetimeless::SRes, SystemParamItem},
|
||||
};
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::{
|
||||
camera::TemporalJitter,
|
||||
|
@ -825,6 +826,7 @@ pub fn queue_material_meshes<M: Material>(
|
|||
|
||||
/// Default render method used for opaque materials.
|
||||
#[derive(Default, Resource, Clone, Debug, ExtractResource, Reflect)]
|
||||
#[reflect(Resource, Default, Debug)]
|
||||
pub struct DefaultOpaqueRendererMethod(OpaqueRendererMethod);
|
||||
|
||||
impl DefaultOpaqueRendererMethod {
|
||||
|
|
|
@ -14,6 +14,7 @@ use bevy_ecs::{
|
|||
system::{Commands, Query, Res, ResMut, Resource},
|
||||
world::{FromWorld, World},
|
||||
};
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::{
|
||||
camera::{ExtractedCamera, TemporalJitter},
|
||||
|
@ -154,7 +155,7 @@ pub struct ScreenSpaceAmbientOcclusionBundle {
|
|||
///
|
||||
/// SSAO is not supported on `WebGL2`, and is not currently supported on `WebGPU` or `DirectX12`.
|
||||
#[derive(Component, ExtractComponent, Reflect, PartialEq, Eq, Hash, Clone, Default, Debug)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Debug, Default, Hash, PartialEq)]
|
||||
#[doc(alias = "Ssao")]
|
||||
pub struct ScreenSpaceAmbientOcclusion {
|
||||
pub quality_level: ScreenSpaceAmbientOcclusionQualityLevel,
|
||||
|
|
|
@ -44,6 +44,7 @@ use bevy_math::{
|
|||
primitives::{Cuboid, Plane3d},
|
||||
Vec2, Vec3,
|
||||
};
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::{
|
||||
mesh::{Mesh, Meshable},
|
||||
|
@ -71,14 +72,14 @@ pub struct VolumetricFogPlugin;
|
|||
///
|
||||
/// This allows the light to generate light shafts/god rays.
|
||||
#[derive(Clone, Copy, Component, Default, Debug, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct VolumetricLight;
|
||||
|
||||
/// When placed on a [`bevy_core_pipeline::core_3d::Camera3d`], enables
|
||||
/// volumetric fog and volumetric lighting, also known as light shafts or god
|
||||
/// rays.
|
||||
#[derive(Clone, Copy, Component, Debug, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct VolumetricFog {
|
||||
/// Color of the ambient light.
|
||||
///
|
||||
|
@ -138,7 +139,7 @@ pub struct FogVolumeBundle {
|
|||
}
|
||||
|
||||
#[derive(Clone, Component, Debug, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct FogVolume {
|
||||
/// The color of the fog.
|
||||
///
|
||||
|
|
|
@ -56,7 +56,7 @@ impl Plugin for WireframePlugin {
|
|||
///
|
||||
/// This requires the [`WireframePlugin`] to be enabled.
|
||||
#[derive(Component, Debug, Clone, Default, Reflect, Eq, PartialEq)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug, PartialEq)]
|
||||
pub struct Wireframe;
|
||||
|
||||
/// Sets the color of the [`Wireframe`] of the entity it is attached to.
|
||||
|
@ -69,7 +69,7 @@ pub struct Wireframe;
|
|||
// This could blow up in size if people use random colored wireframes for each mesh.
|
||||
// It will also be important to remove unused materials from the cache.
|
||||
#[derive(Component, Debug, Clone, Default, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct WireframeColor {
|
||||
pub color: Color,
|
||||
}
|
||||
|
@ -79,11 +79,11 @@ pub struct WireframeColor {
|
|||
///
|
||||
/// This requires the [`WireframePlugin`] to be enabled.
|
||||
#[derive(Component, Debug, Clone, Default, Reflect, Eq, PartialEq)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug, PartialEq)]
|
||||
pub struct NoWireframe;
|
||||
|
||||
#[derive(Resource, Debug, Clone, Default, ExtractResource, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
#[reflect(Resource, Debug, Default)]
|
||||
pub struct WireframeConfig {
|
||||
/// Whether to show wireframes for all meshes.
|
||||
/// Can be overridden for individual meshes by adding a [`Wireframe`] or [`NoWireframe`] component.
|
||||
|
|
Loading…
Reference in a new issue