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_render (#15226)
Addresses https://github.com/bevyengine/bevy/issues/15187 for bevy_render
This commit is contained in:
parent
0c92908baf
commit
274c97d415
11 changed files with 22 additions and 20 deletions
|
@ -226,7 +226,7 @@ pub enum ViewportConversionError {
|
||||||
/// Adding a camera is typically done by adding a bundle, either the `Camera2dBundle` or the
|
/// Adding a camera is typically done by adding a bundle, either the `Camera2dBundle` or the
|
||||||
/// `Camera3dBundle`.
|
/// `Camera3dBundle`.
|
||||||
#[derive(Component, Debug, Reflect, Clone)]
|
#[derive(Component, Debug, Reflect, Clone)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct Camera {
|
pub struct Camera {
|
||||||
/// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`].
|
/// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`].
|
||||||
pub viewport: Option<Viewport>,
|
pub viewport: Option<Viewport>,
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl From<Color> for ClearColorConfig {
|
||||||
/// This color appears as the "background" color for simple apps,
|
/// This color appears as the "background" color for simple apps,
|
||||||
/// when there are portions of the screen with nothing rendered.
|
/// when there are portions of the screen with nothing rendered.
|
||||||
#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)]
|
#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)]
|
||||||
#[reflect(Resource, Default)]
|
#[reflect(Resource, Default, Debug)]
|
||||||
pub struct ClearColor(pub Color);
|
pub struct ClearColor(pub Color);
|
||||||
|
|
||||||
/// Match the dark gray bevy website code block color by default.
|
/// Match the dark gray bevy website code block color by default.
|
||||||
|
|
|
@ -10,7 +10,7 @@ use wgpu::TextureFormat;
|
||||||
|
|
||||||
/// A unique id that corresponds to a specific [`ManualTextureView`] in the [`ManualTextureViews`] collection.
|
/// A unique id that corresponds to a specific [`ManualTextureView`] in the [`ManualTextureViews`] collection.
|
||||||
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Component, Reflect)]
|
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Component, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug, PartialEq, Hash)]
|
||||||
pub struct ManualTextureViewHandle(pub u32);
|
pub struct ManualTextureViewHandle(pub u32);
|
||||||
|
|
||||||
/// A manually managed [`TextureView`] for use as a [`crate::camera::RenderTarget`].
|
/// A manually managed [`TextureView`] for use as a [`crate::camera::RenderTarget`].
|
||||||
|
|
|
@ -98,7 +98,7 @@ pub trait CameraProjection {
|
||||||
|
|
||||||
/// A configurable [`CameraProjection`] that can select its projection type at runtime.
|
/// A configurable [`CameraProjection`] that can select its projection type at runtime.
|
||||||
#[derive(Component, Debug, Clone, Reflect)]
|
#[derive(Component, Debug, Clone, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub enum Projection {
|
pub enum Projection {
|
||||||
Perspective(PerspectiveProjection),
|
Perspective(PerspectiveProjection),
|
||||||
Orthographic(OrthographicProjection),
|
Orthographic(OrthographicProjection),
|
||||||
|
@ -154,7 +154,7 @@ impl Default for Projection {
|
||||||
|
|
||||||
/// A 3D camera projection in which distant objects appear smaller than close objects.
|
/// A 3D camera projection in which distant objects appear smaller than close objects.
|
||||||
#[derive(Component, Debug, Clone, Reflect)]
|
#[derive(Component, Debug, Clone, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct PerspectiveProjection {
|
pub struct PerspectiveProjection {
|
||||||
/// The vertical field of view (FOV) in radians.
|
/// The vertical field of view (FOV) in radians.
|
||||||
///
|
///
|
||||||
|
@ -340,7 +340,7 @@ impl DivAssign<f32> for ScalingMode {
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Component, Debug, Clone, Reflect)]
|
#[derive(Component, Debug, Clone, Reflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, Debug, FromWorld)]
|
||||||
pub struct OrthographicProjection {
|
pub struct OrthographicProjection {
|
||||||
/// The distance of the near clipping plane in world units.
|
/// The distance of the near clipping plane in world units.
|
||||||
///
|
///
|
||||||
|
|
|
@ -10,7 +10,7 @@ use bevy_reflect::prelude::*;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Component, Debug, Default, Clone, Reflect)]
|
#[derive(Component, Debug, Default, Clone, Reflect)]
|
||||||
#[reflect(Component, MapEntities, Default)]
|
#[reflect(Component, MapEntities, Default, Debug)]
|
||||||
pub struct SkinnedMesh {
|
pub struct SkinnedMesh {
|
||||||
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
|
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
|
||||||
pub joints: Vec<Entity>,
|
pub joints: Vec<Entity>,
|
||||||
|
|
|
@ -31,7 +31,7 @@ use bevy_reflect::prelude::*;
|
||||||
/// [`Mesh`]: crate::mesh::Mesh
|
/// [`Mesh`]: crate::mesh::Mesh
|
||||||
/// [`Handle<Mesh>`]: crate::mesh::Mesh
|
/// [`Handle<Mesh>`]: crate::mesh::Mesh
|
||||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect, PartialEq)]
|
#[derive(Component, Clone, Copy, Debug, Default, Reflect, PartialEq)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug, PartialEq)]
|
||||||
pub struct Aabb {
|
pub struct Aabb {
|
||||||
pub center: Vec3A,
|
pub center: Vec3A,
|
||||||
pub half_extents: Vec3A,
|
pub half_extents: Vec3A,
|
||||||
|
@ -212,7 +212,7 @@ impl HalfSpace {
|
||||||
/// [`CameraProjection`]: crate::camera::CameraProjection
|
/// [`CameraProjection`]: crate::camera::CameraProjection
|
||||||
/// [`GlobalTransform`]: bevy_transform::components::GlobalTransform
|
/// [`GlobalTransform`]: bevy_transform::components::GlobalTransform
|
||||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct Frustum {
|
pub struct Frustum {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub half_spaces: [HalfSpace; 6],
|
pub half_spaces: [HalfSpace; 6],
|
||||||
|
@ -303,7 +303,7 @@ impl Frustum {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct CubemapFrusta {
|
pub struct CubemapFrusta {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub frusta: [Frustum; 6],
|
pub frusta: [Frustum; 6],
|
||||||
|
@ -319,7 +319,7 @@ impl CubemapFrusta {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Debug, Default, Reflect, Clone)]
|
#[derive(Component, Debug, Default, Reflect, Clone)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct CascadesFrusta {
|
pub struct CascadesFrusta {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub frusta: EntityHashMap<Vec<Frustum>>,
|
pub frusta: EntityHashMap<Vec<Frustum>>,
|
||||||
|
|
|
@ -166,7 +166,7 @@ impl Plugin for ViewPlugin {
|
||||||
Hash,
|
Hash,
|
||||||
Debug,
|
Debug,
|
||||||
)]
|
)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, PartialEq, Hash, Debug)]
|
||||||
pub enum Msaa {
|
pub enum Msaa {
|
||||||
Off = 1,
|
Off = 1,
|
||||||
Sample2 = 2,
|
Sample2 = 2,
|
||||||
|
@ -210,7 +210,7 @@ impl ExtractedView {
|
||||||
/// `post_saturation` value in [`ColorGradingGlobal`], which is applied after
|
/// `post_saturation` value in [`ColorGradingGlobal`], which is applied after
|
||||||
/// tonemapping.
|
/// tonemapping.
|
||||||
#[derive(Component, Reflect, Debug, Default, Clone)]
|
#[derive(Component, Reflect, Debug, Default, Clone)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct ColorGrading {
|
pub struct ColorGrading {
|
||||||
/// Filmic color grading values applied to the image as a whole (as opposed
|
/// Filmic color grading values applied to the image as a whole (as opposed
|
||||||
/// to individual sections, like shadows and highlights).
|
/// to individual sections, like shadows and highlights).
|
||||||
|
|
|
@ -31,7 +31,7 @@ use super::NoCpuCulling;
|
||||||
/// This is done by the `visibility_propagate_system` which uses the entity hierarchy and
|
/// This is done by the `visibility_propagate_system` which uses the entity hierarchy and
|
||||||
/// `Visibility` to set the values of each entity's [`InheritedVisibility`] component.
|
/// `Visibility` to set the values of each entity's [`InheritedVisibility`] component.
|
||||||
#[derive(Component, Clone, Copy, Reflect, Debug, PartialEq, Eq, Default)]
|
#[derive(Component, Clone, Copy, Reflect, Debug, PartialEq, Eq, Default)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug, PartialEq)]
|
||||||
pub enum Visibility {
|
pub enum Visibility {
|
||||||
/// An entity with `Visibility::Inherited` will inherit the Visibility of its [`Parent`].
|
/// An entity with `Visibility::Inherited` will inherit the Visibility of its [`Parent`].
|
||||||
///
|
///
|
||||||
|
@ -105,7 +105,7 @@ impl PartialEq<&Visibility> for Visibility {
|
||||||
///
|
///
|
||||||
/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
|
/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
|
||||||
#[derive(Component, Deref, Debug, Default, Clone, Copy, Reflect, PartialEq, Eq)]
|
#[derive(Component, Deref, Debug, Default, Clone, Copy, Reflect, PartialEq, Eq)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug, PartialEq)]
|
||||||
pub struct InheritedVisibility(bool);
|
pub struct InheritedVisibility(bool);
|
||||||
|
|
||||||
impl InheritedVisibility {
|
impl InheritedVisibility {
|
||||||
|
@ -133,7 +133,7 @@ impl InheritedVisibility {
|
||||||
/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
|
/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
|
||||||
/// [`CheckVisibility`]: VisibilitySystems::CheckVisibility
|
/// [`CheckVisibility`]: VisibilitySystems::CheckVisibility
|
||||||
#[derive(Component, Deref, Debug, Default, Clone, Copy, Reflect, PartialEq, Eq)]
|
#[derive(Component, Deref, Debug, Default, Clone, Copy, Reflect, PartialEq, Eq)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug, PartialEq)]
|
||||||
pub struct ViewVisibility(bool);
|
pub struct ViewVisibility(bool);
|
||||||
|
|
||||||
impl ViewVisibility {
|
impl ViewVisibility {
|
||||||
|
@ -190,7 +190,7 @@ pub struct VisibilityBundle {
|
||||||
/// - when using some light effects, like wanting a [`Mesh`] out of the [`Frustum`]
|
/// - when using some light effects, like wanting a [`Mesh`] out of the [`Frustum`]
|
||||||
/// to appear in the reflection of a [`Mesh`] within.
|
/// to appear in the reflection of a [`Mesh`] within.
|
||||||
#[derive(Debug, Component, Default, Reflect)]
|
#[derive(Debug, Component, Default, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct NoFrustumCulling;
|
pub struct NoFrustumCulling;
|
||||||
|
|
||||||
/// Collection of entities visible from the current view.
|
/// Collection of entities visible from the current view.
|
||||||
|
@ -203,7 +203,7 @@ pub struct NoFrustumCulling;
|
||||||
/// This component is intended to be attached to the same entity as the [`Camera`] and
|
/// This component is intended to be attached to the same entity as the [`Camera`] and
|
||||||
/// the [`Frustum`] defining the view.
|
/// the [`Frustum`] defining the view.
|
||||||
#[derive(Clone, Component, Default, Debug, Reflect)]
|
#[derive(Clone, Component, Default, Debug, Reflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, Debug)]
|
||||||
pub struct VisibleEntities {
|
pub struct VisibleEntities {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub entities: TypeIdMap<Vec<Entity>>,
|
pub entities: TypeIdMap<Vec<Entity>>,
|
||||||
|
|
|
@ -11,6 +11,7 @@ use bevy_ecs::{
|
||||||
component::Component,
|
component::Component,
|
||||||
entity::{Entity, EntityHashMap},
|
entity::{Entity, EntityHashMap},
|
||||||
query::{Changed, With},
|
query::{Changed, With},
|
||||||
|
reflect::ReflectComponent,
|
||||||
schedule::IntoSystemConfigs as _,
|
schedule::IntoSystemConfigs as _,
|
||||||
system::{Query, Res, ResMut, Resource},
|
system::{Query, Res, ResMut, Resource},
|
||||||
};
|
};
|
||||||
|
@ -109,6 +110,7 @@ impl Plugin for VisibilityRangePlugin {
|
||||||
/// `start_margin` of the next lower LOD; this is important for the crossfade
|
/// `start_margin` of the next lower LOD; this is important for the crossfade
|
||||||
/// effect to function properly.
|
/// effect to function properly.
|
||||||
#[derive(Component, Clone, PartialEq, Reflect)]
|
#[derive(Component, Clone, PartialEq, Reflect)]
|
||||||
|
#[reflect(Component, PartialEq, Hash)]
|
||||||
pub struct VisibilityRange {
|
pub struct VisibilityRange {
|
||||||
/// The range of distances, in world units, between which this entity will
|
/// The range of distances, in world units, between which this entity will
|
||||||
/// smoothly fade into view as the camera zooms out.
|
/// smoothly fade into view as the camera zooms out.
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub type Layer = usize;
|
||||||
///
|
///
|
||||||
/// Entities without this component belong to layer `0`.
|
/// Entities without this component belong to layer `0`.
|
||||||
#[derive(Component, Clone, Reflect, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Component, Clone, Reflect, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
#[reflect(Component, Default, PartialEq)]
|
#[reflect(Component, Default, PartialEq, Debug)]
|
||||||
pub struct RenderLayers(SmallVec<[u64; INLINE_BLOCKS]>);
|
pub struct RenderLayers(SmallVec<[u64; INLINE_BLOCKS]>);
|
||||||
|
|
||||||
/// The number of memory blocks stored inline
|
/// The number of memory blocks stored inline
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl Plugin for CursorPlugin {
|
||||||
|
|
||||||
/// Insert into a window entity to set the cursor for that window.
|
/// Insert into a window entity to set the cursor for that window.
|
||||||
#[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)]
|
#[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)]
|
||||||
#[reflect(Component, Debug, Default)]
|
#[reflect(Component, Debug, Default, PartialEq)]
|
||||||
pub enum CursorIcon {
|
pub enum CursorIcon {
|
||||||
/// Custom cursor image.
|
/// Custom cursor image.
|
||||||
Custom(CustomCursor),
|
Custom(CustomCursor),
|
||||||
|
|
Loading…
Reference in a new issue