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:
Blazepaws 2024-09-15 19:05:11 +02:00 committed by GitHub
parent 0c92908baf
commit 274c97d415
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 22 additions and 20 deletions

View file

@ -226,7 +226,7 @@ pub enum ViewportConversionError {
/// Adding a camera is typically done by adding a bundle, either the `Camera2dBundle` or the
/// `Camera3dBundle`.
#[derive(Component, Debug, Reflect, Clone)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct Camera {
/// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`].
pub viewport: Option<Viewport>,

View file

@ -31,7 +31,7 @@ impl From<Color> for ClearColorConfig {
/// This color appears as the "background" color for simple apps,
/// when there are portions of the screen with nothing rendered.
#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)]
#[reflect(Resource, Default)]
#[reflect(Resource, Default, Debug)]
pub struct ClearColor(pub Color);
/// Match the dark gray bevy website code block color by default.

View file

@ -10,7 +10,7 @@ use wgpu::TextureFormat;
/// 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)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug, PartialEq, Hash)]
pub struct ManualTextureViewHandle(pub u32);
/// A manually managed [`TextureView`] for use as a [`crate::camera::RenderTarget`].

View file

@ -98,7 +98,7 @@ pub trait CameraProjection {
/// A configurable [`CameraProjection`] that can select its projection type at runtime.
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub enum Projection {
Perspective(PerspectiveProjection),
Orthographic(OrthographicProjection),
@ -154,7 +154,7 @@ impl Default for Projection {
/// A 3D camera projection in which distant objects appear smaller than close objects.
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct PerspectiveProjection {
/// The vertical field of view (FOV) in radians.
///
@ -340,7 +340,7 @@ impl DivAssign<f32> for ScalingMode {
/// });
/// ```
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component)]
#[reflect(Component, Debug, FromWorld)]
pub struct OrthographicProjection {
/// The distance of the near clipping plane in world units.
///

View file

@ -10,7 +10,7 @@ use bevy_reflect::prelude::*;
use std::ops::Deref;
#[derive(Component, Debug, Default, Clone, Reflect)]
#[reflect(Component, MapEntities, Default)]
#[reflect(Component, MapEntities, Default, Debug)]
pub struct SkinnedMesh {
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
pub joints: Vec<Entity>,

View file

@ -31,7 +31,7 @@ use bevy_reflect::prelude::*;
/// [`Mesh`]: crate::mesh::Mesh
/// [`Handle<Mesh>`]: crate::mesh::Mesh
#[derive(Component, Clone, Copy, Debug, Default, Reflect, PartialEq)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug, PartialEq)]
pub struct Aabb {
pub center: Vec3A,
pub half_extents: Vec3A,
@ -212,7 +212,7 @@ impl HalfSpace {
/// [`CameraProjection`]: crate::camera::CameraProjection
/// [`GlobalTransform`]: bevy_transform::components::GlobalTransform
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct Frustum {
#[reflect(ignore)]
pub half_spaces: [HalfSpace; 6],
@ -303,7 +303,7 @@ impl Frustum {
}
#[derive(Component, Clone, Debug, Default, Reflect)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct CubemapFrusta {
#[reflect(ignore)]
pub frusta: [Frustum; 6],
@ -319,7 +319,7 @@ impl CubemapFrusta {
}
#[derive(Component, Debug, Default, Reflect, Clone)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct CascadesFrusta {
#[reflect(ignore)]
pub frusta: EntityHashMap<Vec<Frustum>>,

View file

@ -166,7 +166,7 @@ impl Plugin for ViewPlugin {
Hash,
Debug,
)]
#[reflect(Component, Default)]
#[reflect(Component, Default, PartialEq, Hash, Debug)]
pub enum Msaa {
Off = 1,
Sample2 = 2,
@ -210,7 +210,7 @@ impl ExtractedView {
/// `post_saturation` value in [`ColorGradingGlobal`], which is applied after
/// tonemapping.
#[derive(Component, Reflect, Debug, Default, Clone)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct ColorGrading {
/// Filmic color grading values applied to the image as a whole (as opposed
/// to individual sections, like shadows and highlights).

View file

@ -31,7 +31,7 @@ use super::NoCpuCulling;
/// 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.
#[derive(Component, Clone, Copy, Reflect, Debug, PartialEq, Eq, Default)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug, PartialEq)]
pub enum Visibility {
/// An entity with `Visibility::Inherited` will inherit the Visibility of its [`Parent`].
///
@ -105,7 +105,7 @@ impl PartialEq<&Visibility> for Visibility {
///
/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
#[derive(Component, Deref, Debug, Default, Clone, Copy, Reflect, PartialEq, Eq)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug, PartialEq)]
pub struct InheritedVisibility(bool);
impl InheritedVisibility {
@ -133,7 +133,7 @@ impl InheritedVisibility {
/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
/// [`CheckVisibility`]: VisibilitySystems::CheckVisibility
#[derive(Component, Deref, Debug, Default, Clone, Copy, Reflect, PartialEq, Eq)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug, PartialEq)]
pub struct ViewVisibility(bool);
impl ViewVisibility {
@ -190,7 +190,7 @@ pub struct VisibilityBundle {
/// - when using some light effects, like wanting a [`Mesh`] out of the [`Frustum`]
/// to appear in the reflection of a [`Mesh`] within.
#[derive(Debug, Component, Default, Reflect)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct NoFrustumCulling;
/// 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
/// the [`Frustum`] defining the view.
#[derive(Clone, Component, Default, Debug, Reflect)]
#[reflect(Component, Default)]
#[reflect(Component, Default, Debug)]
pub struct VisibleEntities {
#[reflect(ignore)]
pub entities: TypeIdMap<Vec<Entity>>,

View file

@ -11,6 +11,7 @@ use bevy_ecs::{
component::Component,
entity::{Entity, EntityHashMap},
query::{Changed, With},
reflect::ReflectComponent,
schedule::IntoSystemConfigs as _,
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
/// effect to function properly.
#[derive(Component, Clone, PartialEq, Reflect)]
#[reflect(Component, PartialEq, Hash)]
pub struct VisibilityRange {
/// The range of distances, in world units, between which this entity will
/// smoothly fade into view as the camera zooms out.

View file

@ -21,7 +21,7 @@ pub type Layer = usize;
///
/// Entities without this component belong to layer `0`.
#[derive(Component, Clone, Reflect, PartialEq, Eq, PartialOrd, Ord)]
#[reflect(Component, Default, PartialEq)]
#[reflect(Component, Default, PartialEq, Debug)]
pub struct RenderLayers(SmallVec<[u64; INLINE_BLOCKS]>);
/// The number of memory blocks stored inline

View file

@ -35,7 +35,7 @@ impl Plugin for CursorPlugin {
/// Insert into a window entity to set the cursor for that window.
#[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)]
#[reflect(Component, Debug, Default)]
#[reflect(Component, Debug, Default, PartialEq)]
pub enum CursorIcon {
/// Custom cursor image.
Custom(CustomCursor),