mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Reflect default in some types on bevy_render
(#12580)
# Objective - Many types in bevy_render doesn't reflect Default even if it could. ## Solution - Reflect it. --- --------- Co-authored-by: Pablo Reinhardt <pabloreinhardt@gmail.com>
This commit is contained in:
parent
d7372f2c75
commit
40f82b867b
9 changed files with 22 additions and 22 deletions
|
@ -88,7 +88,7 @@ pub struct ComputedCameraValues {
|
|||
///
|
||||
/// <https://en.wikipedia.org/wiki/Exposure_(photography)>
|
||||
#[derive(Component, Clone, Copy, Reflect)]
|
||||
#[reflect_value(Component)]
|
||||
#[reflect_value(Component, Default)]
|
||||
pub struct Exposure {
|
||||
/// <https://en.wikipedia.org/wiki/Exposure_value#Tabulated_exposure_values>
|
||||
pub ev100: f32,
|
||||
|
@ -184,7 +184,7 @@ impl Default for PhysicalCameraParameters {
|
|||
/// Adding a camera is typically done by adding a bundle, either the `Camera2dBundle` or the
|
||||
/// `Camera3dBundle`.
|
||||
#[derive(Component, Debug, Reflect, Clone)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct Camera {
|
||||
/// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`].
|
||||
pub viewport: Option<Viewport>,
|
||||
|
@ -771,7 +771,7 @@ pub fn camera_system<T: CameraProjection + Component>(
|
|||
|
||||
/// This component lets you control the [`TextureUsages`] field of the main texture generated for the camera
|
||||
#[derive(Component, ExtractComponent, Clone, Copy, Reflect)]
|
||||
#[reflect_value(Component)]
|
||||
#[reflect_value(Component, Default)]
|
||||
pub struct CameraMainTextureUsages(pub TextureUsages);
|
||||
impl Default for CameraMainTextureUsages {
|
||||
fn default() -> Self {
|
||||
|
|
|
@ -2,12 +2,12 @@ use crate::extract_resource::ExtractResource;
|
|||
use bevy_color::Color;
|
||||
use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::prelude::*;
|
||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
||||
use bevy_reflect::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// For a camera, specifies the color used to clear the viewport before rendering.
|
||||
#[derive(Reflect, Serialize, Deserialize, Clone, Debug, Default)]
|
||||
#[reflect(Serialize, Deserialize)]
|
||||
#[reflect(Serialize, Deserialize, Default)]
|
||||
pub enum ClearColorConfig {
|
||||
/// The clear color is taken from the world's [`ClearColor`] resource.
|
||||
#[default]
|
||||
|
@ -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)]
|
||||
#[reflect(Resource, Default)]
|
||||
pub struct ClearColor(pub Color);
|
||||
|
||||
/// Match the dark gray bevy website code block color by default.
|
||||
|
|
|
@ -9,7 +9,7 @@ use bevy_app::{App, Plugin};
|
|||
use bevy_asset::{load_internal_asset, Handle};
|
||||
use bevy_core::FrameCount;
|
||||
use bevy_ecs::prelude::*;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_reflect::prelude::*;
|
||||
use bevy_time::Time;
|
||||
|
||||
pub const GLOBALS_TYPE_HANDLE: Handle<Shader> = Handle::weak_from_u128(17924628719070609599);
|
||||
|
@ -45,7 +45,7 @@ fn extract_time(mut commands: Commands, time: Extract<Res<Time>>) {
|
|||
/// Contains global values useful when writing shaders.
|
||||
/// Currently only contains values related to time.
|
||||
#[derive(Default, Clone, Resource, ExtractResource, Reflect, ShaderType)]
|
||||
#[reflect(Resource)]
|
||||
#[reflect(Resource, Default)]
|
||||
pub struct GlobalsUniform {
|
||||
/// The time since startup in seconds.
|
||||
/// Wraps to 0 after 1 hour.
|
||||
|
|
|
@ -6,11 +6,11 @@ use bevy_ecs::{
|
|||
reflect::ReflectMapEntities,
|
||||
};
|
||||
use bevy_math::Mat4;
|
||||
use bevy_reflect::{Reflect, TypePath};
|
||||
use bevy_reflect::prelude::*;
|
||||
use std::ops::Deref;
|
||||
|
||||
#[derive(Component, Debug, Default, Clone, Reflect)]
|
||||
#[reflect(Component, MapEntities)]
|
||||
#[reflect(Component, MapEntities, Default)]
|
||||
pub struct SkinnedMesh {
|
||||
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
|
||||
pub joints: Vec<Entity>,
|
||||
|
|
|
@ -9,7 +9,7 @@ use bevy_asset::Handle;
|
|||
use bevy_ecs::prelude::*;
|
||||
use bevy_hierarchy::Children;
|
||||
use bevy_math::Vec3;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_reflect::prelude::*;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use std::{iter, mem};
|
||||
use thiserror::Error;
|
||||
|
@ -128,7 +128,7 @@ impl MorphTargetImage {
|
|||
///
|
||||
/// [morph targets]: https://en.wikipedia.org/wiki/Morph_target_animation
|
||||
#[derive(Reflect, Default, Debug, Clone, Component)]
|
||||
#[reflect(Debug, Component)]
|
||||
#[reflect(Debug, Component, Default)]
|
||||
pub struct MorphWeights {
|
||||
weights: Vec<f32>,
|
||||
/// The first mesh primitive assigned to these weights
|
||||
|
@ -173,7 +173,7 @@ impl MorphWeights {
|
|||
///
|
||||
/// [morph targets]: https://en.wikipedia.org/wiki/Morph_target_animation
|
||||
#[derive(Reflect, Default, Debug, Clone, Component)]
|
||||
#[reflect(Debug, Component)]
|
||||
#[reflect(Debug, Component, Default)]
|
||||
pub struct MeshMorphWeights {
|
||||
weights: Vec<f32>,
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::borrow::Borrow;
|
|||
|
||||
use bevy_ecs::{component::Component, entity::EntityHashMap, reflect::ReflectComponent};
|
||||
use bevy_math::{Affine3A, Mat3A, Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles};
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_reflect::prelude::*;
|
||||
|
||||
/// An axis-aligned bounding box, defined by:
|
||||
/// - a center,
|
||||
|
@ -31,7 +31,7 @@ use bevy_reflect::Reflect;
|
|||
/// [`Mesh`]: crate::mesh::Mesh
|
||||
/// [`Handle<Mesh>`]: crate::mesh::Mesh
|
||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect, PartialEq)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Default)]
|
||||
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)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct Frustum {
|
||||
#[reflect(ignore)]
|
||||
pub half_spaces: [HalfSpace; 6],
|
||||
|
@ -303,7 +303,7 @@ impl Frustum {
|
|||
}
|
||||
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct CubemapFrusta {
|
||||
#[reflect(ignore)]
|
||||
pub frusta: [Frustum; 6],
|
||||
|
@ -319,7 +319,7 @@ impl CubemapFrusta {
|
|||
}
|
||||
|
||||
#[derive(Component, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct CascadesFrusta {
|
||||
#[reflect(ignore)]
|
||||
pub frusta: EntityHashMap<Vec<Frustum>>,
|
||||
|
|
|
@ -15,7 +15,7 @@ use bevy_asset::Asset;
|
|||
use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::system::{lifetimeless::SRes, Resource, SystemParamItem};
|
||||
use bevy_math::{AspectRatio, UVec2, Vec2};
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_reflect::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::hash::Hash;
|
||||
use thiserror::Error;
|
||||
|
@ -112,7 +112,7 @@ impl ImageFormat {
|
|||
}
|
||||
|
||||
#[derive(Asset, Reflect, Debug, Clone)]
|
||||
#[reflect_value]
|
||||
#[reflect_value(Default)]
|
||||
pub struct Image {
|
||||
pub data: Vec<u8>,
|
||||
// TODO: this nesting makes accessing Image metadata verbose. Either flatten out descriptor or add accessors
|
||||
|
|
|
@ -90,7 +90,7 @@ impl Plugin for ViewPlugin {
|
|||
#[derive(
|
||||
Resource, Default, Clone, Copy, ExtractResource, Reflect, PartialEq, PartialOrd, Debug,
|
||||
)]
|
||||
#[reflect(Resource)]
|
||||
#[reflect(Resource, Default)]
|
||||
pub enum Msaa {
|
||||
Off = 1,
|
||||
Sample2 = 2,
|
||||
|
|
|
@ -168,7 +168,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)]
|
||||
#[reflect(Component, Default)]
|
||||
pub struct VisibleEntities {
|
||||
#[reflect(ignore)]
|
||||
pub entities: Vec<Entity>,
|
||||
|
|
Loading…
Reference in a new issue