Add FromReflect where Reflect is used (#8776)

# Objective

Discovered that PointLight did not implement FromReflect. Adding
FromReflect where Reflect is used. I overreached and applied this rule
everywhere there was a Reflect without a FromReflect, except from where
the compiler wouldn't allow me.

Based from question: https://github.com/bevyengine/bevy/discussions/8774

## Solution

- Adding FromReflect where Reflect was already derived

## Notes

First PR I do in this ecosystem, so not sure if this is the usual
approach, that is, to touch many files at once.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
Raffaele Ragni 2023-06-19 18:18:17 +02:00 committed by GitHub
parent 23863d526a
commit 7fc6db32ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 225 additions and 185 deletions

View file

@ -11,7 +11,8 @@ use crate::{
};
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_reflect::{
std_traits::ReflectDefault, FromReflect, Reflect, ReflectDeserialize, ReflectSerialize,
std_traits::ReflectDefault, FromReflect, Reflect, ReflectDeserialize, ReflectFromReflect,
ReflectSerialize,
};
use bevy_utils::Uuid;
use crossbeam_channel::{Receiver, Sender};
@ -103,7 +104,7 @@ impl HandleId {
/// collisions no longer being detected for that entity.
///
#[derive(Component, Reflect, FromReflect)]
#[reflect(Component, Default)]
#[reflect(Component, Default, FromReflect)]
pub struct Handle<T>
where
T: Asset,

View file

@ -69,16 +69,38 @@ impl<'a> AssetPath<'a> {
/// An unique identifier to an asset path.
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, Deserialize, Reflect,
Debug,
Clone,
Copy,
Eq,
PartialEq,
Hash,
Ord,
PartialOrd,
Serialize,
Deserialize,
Reflect,
FromReflect,
)]
#[reflect_value(PartialEq, Hash, Serialize, Deserialize)]
#[reflect_value(PartialEq, Hash, Serialize, Deserialize, FromReflect)]
pub struct AssetPathId(SourcePathId, LabelId);
/// An unique identifier to the source path of an asset.
#[derive(
Debug, Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, Deserialize, Reflect,
Debug,
Clone,
Copy,
Eq,
PartialEq,
Hash,
Ord,
PartialOrd,
Serialize,
Deserialize,
Reflect,
FromReflect,
)]
#[reflect_value(PartialEq, Hash, Serialize, Deserialize)]
#[reflect_value(PartialEq, Hash, Serialize, Deserialize, FromReflect)]
pub struct SourcePathId(u64);
/// An unique identifier to a sub-asset label.

View file

@ -1,8 +1,8 @@
use bevy_ecs::{
component::Component, entity::Entity, query::WorldQuery, reflect::ReflectComponent,
};
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, FromReflect};
use bevy_reflect::{Reflect, ReflectFromReflect};
use bevy_utils::AHasher;
use std::{
borrow::Cow,
@ -18,7 +18,7 @@ use std::{
/// as multiple entities can have the same name. [`bevy_ecs::entity::Entity`] should be
/// used instead as the default unique identifier.
#[derive(Reflect, FromReflect, Component, Clone)]
#[reflect(Component, Default, Debug)]
#[reflect(Component, Default, Debug, FromReflect)]
pub struct Name {
hash: u64, // TODO: Shouldn't be serialized
name: Cow<'static, str>,

View file

@ -1,7 +1,7 @@
use super::downsampling_pipeline::BloomUniforms;
use bevy_ecs::{prelude::Component, query::QueryItem, reflect::ReflectComponent};
use bevy_math::{UVec4, Vec4};
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
use bevy_render::{extract_component::ExtractComponent, prelude::Camera};
/// Applies a bloom effect to an HDR-enabled 2d or 3d camera.
@ -160,7 +160,8 @@ impl Default for BloomSettings {
/// * Changing these settings creates a physically inaccurate image
/// * Changing these settings makes it easy to make the final result look worse
/// * Non-default prefilter settings should be used in conjuction with [`BloomCompositeMode::Additive`]
#[derive(Default, Clone, Reflect)]
#[derive(Default, Clone, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub struct BloomPrefilterSettings {
/// Baseline of the quadratic threshold curve (default: 0.0).
///

View file

@ -1,11 +1,13 @@
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::prelude::*;
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_reflect::{
FromReflect, Reflect, ReflectDeserialize, ReflectFromReflect, ReflectSerialize,
};
use bevy_render::{color::Color, extract_resource::ExtractResource};
use serde::{Deserialize, Serialize};
#[derive(Reflect, Serialize, Deserialize, Clone, Debug, Default)]
#[reflect(Serialize, Deserialize)]
#[derive(Reflect, FromReflect, Serialize, Deserialize, Clone, Debug, Default)]
#[reflect(Serialize, Deserialize, FromReflect)]
pub enum ClearColorConfig {
#[default]
Default,
@ -17,8 +19,8 @@ pub enum 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)]
#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect, FromReflect)]
#[reflect(Resource, FromReflect)]
pub struct ClearColor(pub Color);
impl Default for ClearColor {

View file

@ -3,7 +3,7 @@ use crate::{
tonemapping::{DebandDither, Tonemapping},
};
use bevy_ecs::prelude::*;
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use bevy_render::{
camera::{Camera, CameraProjection, CameraRenderGraph, OrthographicProjection},
extract_component::ExtractComponent,
@ -12,9 +12,9 @@ use bevy_render::{
};
use bevy_transform::prelude::{GlobalTransform, Transform};
#[derive(Component, Default, Reflect, Clone, ExtractComponent)]
#[derive(Component, Default, Reflect, FromReflect, Clone, ExtractComponent)]
#[extract_component_filter(With<Camera>)]
#[reflect(Component)]
#[reflect(Component, FromReflect)]
pub struct Camera2d {
pub clear_color: ClearColorConfig,
}

View file

@ -3,7 +3,9 @@ use crate::{
tonemapping::{DebandDither, Tonemapping},
};
use bevy_ecs::prelude::*;
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_reflect::{
FromReflect, Reflect, ReflectDeserialize, ReflectFromReflect, ReflectSerialize,
};
use bevy_render::{
camera::{Camera, CameraRenderGraph, Projection},
extract_component::ExtractComponent,
@ -15,9 +17,9 @@ use bevy_transform::prelude::{GlobalTransform, Transform};
use serde::{Deserialize, Serialize};
/// Configuration for the "main 3d render graph".
#[derive(Component, Reflect, Clone, ExtractComponent)]
#[derive(Component, Reflect, FromReflect, Clone, ExtractComponent)]
#[extract_component_filter(With<Camera>)]
#[reflect(Component)]
#[reflect(Component, FromReflect)]
pub struct Camera3d {
/// The clear color operation to perform for the main 3d pass.
pub clear_color: ClearColorConfig,
@ -37,7 +39,8 @@ impl Default for Camera3d {
}
}
#[derive(Clone, Copy, Reflect)]
#[derive(Clone, Copy, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub struct Camera3dDepthTextureUsage(u32);
impl From<TextureUsages> for Camera3dDepthTextureUsage {
@ -52,8 +55,8 @@ impl From<Camera3dDepthTextureUsage> for TextureUsages {
}
/// The depth clear operation to perform for the main 3d pass.
#[derive(Reflect, Serialize, Deserialize, Clone, Debug)]
#[reflect(Serialize, Deserialize)]
#[derive(Reflect, FromReflect, Serialize, Deserialize, Clone, Debug)]
#[reflect(Serialize, Deserialize, FromReflect)]
pub enum Camera3dDepthLoadOp {
/// Clear with a specified value.
/// Note that 0.0 is the far plane due to bevy's use of reverse-z projections.

View file

@ -30,7 +30,7 @@ pub mod node;
use std::cmp::Reverse;
use bevy_ecs::prelude::*;
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use bevy_render::{
render_phase::{CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem},
render_resource::{CachedRenderPipelineId, Extent3d, TextureFormat},
@ -43,16 +43,19 @@ pub const NORMAL_PREPASS_FORMAT: TextureFormat = TextureFormat::Rgb10a2Unorm;
pub const MOTION_VECTOR_PREPASS_FORMAT: TextureFormat = TextureFormat::Rg16Float;
/// If added to a [`crate::prelude::Camera3d`] then depth values will be copied to a separate texture available to the main pass.
#[derive(Component, Default, Reflect)]
#[derive(Component, Default, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub struct DepthPrepass;
/// If added to a [`crate::prelude::Camera3d`] then vertex world normals will be copied to a separate texture available to the main pass.
/// Normals will have normal map textures already applied.
#[derive(Component, Default, Reflect)]
#[derive(Component, Default, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub struct NormalPrepass;
/// If added to a [`crate::prelude::Camera3d`] then screen space motion vectors will be copied to a separate texture available to the main pass.
#[derive(Component, Default, Reflect)]
#[derive(Component, Default, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub struct MotionVectorPrepass;
/// Textures that are written to by the prepass.

View file

@ -2,7 +2,7 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, Assets, Handle, HandleUntyped};
use bevy_ecs::prelude::*;
use bevy_reflect::{FromReflect, Reflect, TypeUuid};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypeUuid};
use bevy_render::camera::Camera;
use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin};
use bevy_render::extract_resource::{ExtractResource, ExtractResourcePlugin};
@ -127,7 +127,7 @@ pub struct TonemappingPipeline {
FromReflect,
)]
#[extract_component_filter(With<Camera>)]
#[reflect(Component)]
#[reflect(Component, FromReflect)]
pub enum Tonemapping {
/// Bypass tonemapping.
None,
@ -314,7 +314,7 @@ pub fn queue_view_tonemapping_pipelines(
FromReflect,
)]
#[extract_component_filter(With<Camera>)]
#[reflect(Component)]
#[reflect(Component, FromReflect)]
pub enum DebandDither {
#[default]
Disabled,

View file

@ -12,7 +12,7 @@ use bevy_app::prelude::*;
use bevy_asset::{AddAsset, Handle};
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
use bevy_pbr::StandardMaterial;
use bevy_reflect::{Reflect, TypePath, TypeUuid};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypePath, TypeUuid};
use bevy_render::{
mesh::{Mesh, MeshVertexAttribute},
renderer::RenderDevice,
@ -106,8 +106,8 @@ pub struct GltfPrimitive {
pub material_extras: Option<GltfExtras>,
}
#[derive(Clone, Debug, Reflect, Default, Component)]
#[reflect(Component)]
#[derive(Clone, Debug, Reflect, FromReflect, Default, Component)]
#[reflect(Component, FromReflect)]
pub struct GltfExtras {
pub value: String,
}

View file

@ -5,7 +5,7 @@ use bevy_ecs::{
reflect::{ReflectComponent, ReflectMapEntities},
world::World,
};
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use core::slice;
use smallvec::SmallVec;
use std::ops::Deref;
@ -16,8 +16,8 @@ use std::ops::Deref;
///
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
/// [`Query`]: bevy_ecs::system::Query
#[derive(Component, Debug, Reflect)]
#[reflect(Component, MapEntities)]
#[derive(Component, Debug, Reflect, FromReflect)]
#[reflect(Component, MapEntities, FromReflect)]
pub struct Children(pub(crate) SmallVec<[Entity; 8]>);
impl MapEntities for Children {

View file

@ -4,7 +4,7 @@ use bevy_ecs::{
reflect::{ReflectComponent, ReflectMapEntities},
world::{FromWorld, World},
};
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use std::ops::Deref;
/// Holds a reference to the parent entity of this entity.
@ -14,8 +14,8 @@ use std::ops::Deref;
///
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
/// [`Query`]: bevy_ecs::system::Query
#[derive(Component, Debug, Eq, PartialEq, Reflect)]
#[reflect(Component, MapEntities, PartialEq)]
#[derive(Component, Debug, Eq, PartialEq, Reflect, FromReflect)]
#[reflect(Component, MapEntities, PartialEq, FromReflect)]
pub struct Parent(pub(crate) Entity);
impl Parent {

View file

@ -4,6 +4,7 @@ use bevy_ecs::{
change_detection::DetectChangesMut,
system::{Res, ResMut, Resource},
};
use bevy_reflect::ReflectFromReflect;
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
use bevy_utils::Duration;
use bevy_utils::{tracing::info, HashMap};
@ -73,7 +74,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
///
/// The `ID` of a gamepad is fixed until the gamepad disconnects or the app is restarted.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -93,7 +94,7 @@ impl Gamepad {
/// Metadata associated with a [`Gamepad`].
#[derive(Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -154,7 +155,7 @@ impl Gamepads {
/// which in turn is used to create the [`Input<GamepadButton>`] or
/// [`Axis<GamepadButton>`] `bevy` resources.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -219,7 +220,7 @@ pub enum GamepadButtonType {
///
/// The gamepad button resources are updated inside of the [`gamepad_button_event_system`].
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -261,7 +262,7 @@ impl GamepadButton {
/// [`GamepadAxisChangedEvent`]. It is also used in the [`GamepadAxis`]
/// which in turn is used to create the [`Axis<GamepadAxis>`] `bevy` resource.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -297,7 +298,7 @@ pub enum GamepadAxisType {
///
/// The gamepad axes resources are updated inside of the [`gamepad_axis_event_system`].
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -342,7 +343,7 @@ impl GamepadAxis {
/// should register as a [`GamepadEvent`]. Events that don't meet the change thresholds defined in [`GamepadSettings`]
/// will not register. To modify these settings, mutate the corresponding resource.
#[derive(Resource, Default, Debug, Reflect, FromReflect)]
#[reflect(Debug, Default)]
#[reflect(Debug, Default, FromReflect)]
pub struct GamepadSettings {
/// The default button settings.
pub default_button_settings: ButtonSettings,
@ -425,7 +426,7 @@ impl GamepadSettings {
///
/// Allowed values: `0.0 <= ``release_threshold`` <= ``press_threshold`` <= 1.0`
#[derive(Debug, Clone, Reflect, FromReflect)]
#[reflect(Debug, Default)]
#[reflect(Debug, Default, FromReflect)]
pub struct ButtonSettings {
press_threshold: f32,
release_threshold: f32,
@ -585,7 +586,7 @@ impl ButtonSettings {
///
/// The valid range is `[-1.0, 1.0]`.
#[derive(Debug, Clone, Reflect, FromReflect, PartialEq)]
#[reflect(Debug, Default)]
#[reflect(Debug, Default, FromReflect)]
pub struct AxisSettings {
/// Values that are higher than `livezone_upperbound` will be rounded up to 1.0.
livezone_upperbound: f32,
@ -917,7 +918,7 @@ impl AxisSettings {
///
/// The current value of a button is received through the [`GamepadButtonChangedEvent`].
#[derive(Debug, Clone, Reflect, FromReflect)]
#[reflect(Debug, Default)]
#[reflect(Debug, Default, FromReflect)]
pub struct ButtonAxisSettings {
/// The high value at which to apply rounding.
pub high: f32,
@ -1026,7 +1027,7 @@ pub fn gamepad_connection_system(
}
#[derive(Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -1040,7 +1041,7 @@ pub enum GamepadConnection {
/// A Gamepad connection event. Created when a connection to a gamepad
/// is established and when a gamepad is disconnected.
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -1071,7 +1072,7 @@ impl GamepadConnectionEvent {
}
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -1096,7 +1097,7 @@ impl GamepadAxisChangedEvent {
/// Gamepad event for when the "value" (amount of pressure) on the button
/// changes by an amount larger than the threshold defined in [`GamepadSettings`].
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -1159,7 +1160,7 @@ pub fn gamepad_button_event_system(
/// [`GamepadButtonChangedEvent`] and [`GamepadAxisChangedEvent`] when
/// the in-frame relative ordering of events is important.
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),

View file

@ -1,5 +1,5 @@
use bevy_ecs::system::Resource;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
use bevy_utils::HashSet;
use std::hash::Hash;
@ -41,8 +41,8 @@ use bevy_ecs::schedule::State;
///
///[`ResMut`]: bevy_ecs::system::ResMut
///[`DetectChangesMut::bypass_change_detection`]: bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection
#[derive(Debug, Clone, Resource, Reflect)]
#[reflect(Default)]
#[derive(Debug, Clone, Resource, Reflect, FromReflect)]
#[reflect(Default, FromReflect)]
pub struct Input<T: Copy + Eq + Hash + Send + Sync + 'static> {
/// A collection of every button that is currently being pressed.
pressed: HashSet<T>,

View file

@ -5,7 +5,7 @@ use bevy_ecs::{
event::{Event, EventReader},
system::ResMut,
};
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
#[cfg(feature = "serialize")]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
@ -20,7 +20,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
/// The event is consumed inside of the [`keyboard_input_system`](crate::keyboard::keyboard_input_system)
/// to update the [`Input<KeyCode>`](crate::Input<KeyCode>) resource.
#[derive(Event, Debug, Clone, Copy, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -79,7 +79,7 @@ pub fn keyboard_input_system(
///
/// The resource is updated inside of the [`keyboard_input_system`](crate::keyboard::keyboard_input_system).
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -452,7 +452,7 @@ pub enum KeyCode {
///
/// The resource is updated inside of the [`keyboard_input_system`](crate::keyboard::keyboard_input_system).
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),

View file

@ -28,7 +28,7 @@ pub mod prelude {
use bevy_app::prelude::*;
use bevy_ecs::prelude::*;
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use keyboard::{keyboard_input_system, KeyCode, KeyboardInput, ScanCode};
use mouse::{
mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion, MouseScrollUnit,
@ -141,7 +141,7 @@ impl Plugin for InputPlugin {
/// The current "press" state of an element
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),

View file

@ -6,7 +6,7 @@ use bevy_ecs::{
system::ResMut,
};
use bevy_math::Vec2;
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
#[cfg(feature = "serialize")]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
@ -20,7 +20,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
/// The event is read inside of the [`mouse_button_input_system`](crate::mouse::mouse_button_input_system)
/// to update the [`Input<MouseButton>`](crate::Input<MouseButton>) resource.
#[derive(Event, Debug, Clone, Copy, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -46,7 +46,7 @@ pub struct MouseButtonInput {
///
/// The resource is updated inside of the [`mouse_button_input_system`](crate::mouse::mouse_button_input_system).
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -73,7 +73,7 @@ pub enum MouseButton {
///
/// [`DeviceEvent::MouseMotion`]: https://docs.rs/winit/latest/winit/event/enum.DeviceEvent.html#variant.MouseMotion
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -91,7 +91,7 @@ pub struct MouseMotion {
/// The value of the event can either be interpreted as the amount of lines or the amount of pixels
/// to scroll.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -114,7 +114,7 @@ pub enum MouseScrollUnit {
///
/// This event is the translated version of the `WindowEvent::MouseWheel` from the `winit` crate.
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),

View file

@ -1,7 +1,7 @@
use bevy_ecs::event::{Event, EventReader};
use bevy_ecs::system::{ResMut, Resource};
use bevy_math::Vec2;
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use bevy_utils::HashMap;
#[cfg(feature = "serialize")]
@ -31,7 +31,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
/// This event is the translated version of the `WindowEvent::Touch` from the `winit` crate.
/// It is available to the end user and can be used for game logic.
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -53,7 +53,7 @@ pub struct TouchInput {
/// A force description of a [`Touch`](crate::touch::Touch) input.
#[derive(Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -99,7 +99,7 @@ pub enum ForceTouch {
/// or that a finger has moved. There is also a canceled phase that indicates that
/// the system canceled the tracking of the finger.
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
#[reflect(Debug, Hash, PartialEq)]
#[reflect(Debug, Hash, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),

View file

@ -1,10 +1,10 @@
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
// TODO: add discussion about performance.
/// Sets how a material's base color alpha channel is used for transparency.
#[derive(Debug, Default, Reflect, Copy, Clone, PartialEq, FromReflect)]
#[reflect(Default, Debug)]
#[reflect(Default, Debug, FromReflect)]
pub enum AlphaMode {
/// Base color alpha values are overridden to be fully opaque (1.0).
#[default]

View file

@ -4,7 +4,7 @@ use crate::{
};
use bevy_asset::Handle;
use bevy_ecs::{bundle::Bundle, component::Component, prelude::Entity, reflect::ReflectComponent};
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use bevy_render::{
mesh::Mesh,
primitives::{CascadesFrusta, CubemapFrusta, Frustum},
@ -42,8 +42,8 @@ impl<M: Material> Default for MaterialMeshBundle<M> {
}
}
#[derive(Component, Clone, Debug, Default, Reflect)]
#[reflect(Component)]
#[derive(Component, Clone, Debug, Default, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct CubemapVisibleEntities {
#[reflect(ignore)]
data: [VisibleEntities; 6],
@ -67,8 +67,8 @@ impl CubemapVisibleEntities {
}
}
#[derive(Component, Clone, Debug, Default, Reflect)]
#[reflect(Component)]
#[derive(Component, Clone, Debug, Default, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct CascadesVisibleEntities {
/// Map of view entity to the visible entities for each cascade frustum.
#[reflect(ignore)]

View file

@ -1,7 +1,7 @@
use crate::ReflectComponent;
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_math::Vec3;
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Camera};
/// Configures the “classic” computer graphics [distance fog](https://en.wikipedia.org/wiki/Distance_fog) effect,
@ -47,8 +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)]
#[reflect(Component)]
#[derive(Debug, Clone, Component, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct FogSettings {
/// The color of the fog effect.
///
@ -94,7 +94,8 @@ pub struct FogSettings {
/// - [`FogFalloff::from_visibility_colors()`]
/// - [`FogFalloff::from_visibility_contrast_color()`]
/// - [`FogFalloff::from_visibility_contrast_colors()`]
#[derive(Debug, Clone, Reflect)]
#[derive(Debug, Clone, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub enum FogFalloff {
/// A linear fog falloff that grows in intensity between `start` and `end` distances.
///

View file

@ -40,8 +40,8 @@ use crate::{
/// | 4000 | 300 | | 75-100 | 40.5 |
///
/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
#[derive(Component, Debug, Clone, Copy, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Debug, Clone, Copy, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub struct PointLight {
pub color: Color,
pub intensity: f32,
@ -75,8 +75,8 @@ impl PointLight {
pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 0.6;
}
#[derive(Resource, Clone, Debug, Reflect)]
#[reflect(Resource)]
#[derive(Resource, Clone, Debug, Reflect, FromReflect)]
#[reflect(Resource, FromReflect)]
pub struct PointLightShadowMap {
pub size: usize,
}
@ -91,8 +91,8 @@ impl Default for PointLightShadowMap {
/// Behaves like a point light in a perfectly absorbent housing that
/// shines light only in a given direction. The direction is taken from
/// the transform, and can be specified with [`Transform::looking_at`](bevy_transform::components::Transform::looking_at).
#[derive(Component, Debug, Clone, Copy, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Debug, Clone, Copy, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub struct SpotLight {
pub color: Color,
pub intensity: f32,
@ -187,8 +187,8 @@ impl Default for SpotLight {
/// App::new()
/// .insert_resource(DirectionalLightShadowMap { size: 2048 });
/// ```
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Debug, Clone, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub struct DirectionalLight {
pub color: Color,
/// Illuminance in lux
@ -218,8 +218,8 @@ impl DirectionalLight {
}
/// Controls the resolution of [`DirectionalLight`] shadow maps.
#[derive(Resource, Clone, Debug, Reflect)]
#[reflect(Resource)]
#[derive(Resource, Clone, Debug, Reflect, FromReflect)]
#[reflect(Resource, FromReflect)]
pub struct DirectionalLightShadowMap {
pub size: usize,
}
@ -243,8 +243,8 @@ impl Default for DirectionalLightShadowMap {
/// ..default()
/// }.into();
/// ```
#[derive(Component, Clone, Debug, Reflect)]
#[reflect(Component)]
#[derive(Component, Clone, Debug, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct CascadeShadowConfig {
/// The (positive) distance to the far boundary of each cascade.
pub bounds: Vec<f32>,
@ -380,14 +380,15 @@ impl From<CascadeShadowConfigBuilder> for CascadeShadowConfig {
}
}
#[derive(Component, Clone, Debug, Default, Reflect)]
#[reflect(Component)]
#[derive(Component, Clone, Debug, Default, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct Cascades {
/// Map from a view to the configuration of each of its [`Cascade`]s.
pub(crate) cascades: HashMap<Entity, Vec<Cascade>>,
}
#[derive(Clone, Debug, Default, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub struct Cascade {
/// The transform of the light, i.e. the view to world matrix.
pub(crate) view_transform: Mat4,
@ -580,8 +581,8 @@ fn calculate_cascade(
}
/// An ambient light, which lights the entire scene equally.
#[derive(Resource, Clone, Debug, ExtractResource, Reflect)]
#[reflect(Resource)]
#[derive(Resource, Clone, Debug, ExtractResource, Reflect, FromReflect)]
#[reflect(Resource, FromReflect)]
pub struct AmbientLight {
pub color: Color,
/// A direct scale factor multiplied with `color` before being passed to the shader.
@ -598,12 +599,12 @@ impl Default for AmbientLight {
}
/// Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not cast shadows.
#[derive(Component, Reflect, Default)]
#[reflect(Component, Default)]
#[derive(Component, Reflect, FromReflect, Default)]
#[reflect(Component, Default, FromReflect)]
pub struct NotShadowCaster;
/// Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not receive shadows.
#[derive(Component, Reflect, Default)]
#[reflect(Component, Default)]
#[derive(Component, Reflect, FromReflect, Default)]
#[reflect(Component, Default, FromReflect)]
pub struct NotShadowReceiver;
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
@ -640,7 +641,7 @@ pub enum ClusterFarZMode {
/// Configure the depth-slicing strategy for clustered forward rendering
#[derive(Debug, Copy, Clone, Reflect, FromReflect)]
#[reflect(Default)]
#[reflect(Default, FromReflect)]
pub struct ClusterZConfig {
/// Far `Z` plane of the first depth slice
pub first_slice_depth: f32,
@ -658,8 +659,8 @@ impl Default for ClusterZConfig {
}
/// Configuration of the clustering strategy for clustered forward rendering
#[derive(Debug, Copy, Clone, Component, Reflect)]
#[reflect(Component)]
#[derive(Debug, Copy, Clone, Component, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub enum ClusterConfig {
/// Disable light cluster calculations for this view
None,

View file

@ -4,7 +4,9 @@ use crate::{
};
use bevy_asset::Handle;
use bevy_math::Vec4;
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect, TypeUuid};
use bevy_reflect::{
std_traits::ReflectDefault, FromReflect, Reflect, ReflectFromReflect, TypeUuid,
};
use bevy_render::{
color::Color, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, render_resource::*,
texture::Image,
@ -19,7 +21,7 @@ use bevy_render::{
#[uuid = "7494888b-c082-457b-aacf-517228cc0c22"]
#[bind_group_data(StandardMaterialKey)]
#[uniform(0, StandardMaterialUniform)]
#[reflect(Default, Debug)]
#[reflect(Default, Debug, FromReflect)]
pub struct StandardMaterial {
/// The color of the surface of the material before lighting.
///

View file

@ -5,7 +5,7 @@ use bevy_asset::{load_internal_asset, Handle, HandleUntyped};
use bevy_core_pipeline::core_3d::Opaque3d;
use bevy_ecs::{prelude::*, reflect::ReflectComponent};
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::{Reflect, TypeUuid};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypeUuid};
use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin};
use bevy_render::Render;
use bevy_render::{
@ -59,12 +59,12 @@ impl Plugin for WireframePlugin {
}
/// Controls whether an entity should rendered in wireframe-mode if the [`WireframePlugin`] is enabled
#[derive(Component, Debug, Clone, Default, ExtractComponent, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Debug, Clone, Default, ExtractComponent, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub struct Wireframe;
#[derive(Resource, Debug, Clone, Default, ExtractResource, Reflect)]
#[reflect(Resource)]
#[derive(Resource, Debug, Clone, Default, ExtractResource, Reflect, FromReflect)]
#[reflect(Resource, FromReflect)]
pub struct WireframeConfig {
/// Whether to show wireframes for all meshes. If `false`, only meshes with a [Wireframe] component will be rendered.
pub global: bool,

View file

@ -377,7 +377,8 @@ impl CameraRenderGraph {
/// The "target" that a [`Camera`] will render to. For example, this could be a [`Window`](bevy_window::Window)
/// swapchain or an [`Image`].
#[derive(Debug, Clone, Reflect)]
#[derive(Debug, Clone, Reflect, FromReflect)]
#[reflect(FromReflect)]
pub enum RenderTarget {
/// Window to which the camera's view is rendered.
Window(WindowRef),

View file

@ -5,7 +5,7 @@ use bevy_ecs::{prelude::*, reflect::ReflectComponent};
use bevy_math::{Mat4, Rect, Vec2};
use bevy_reflect::{
std_traits::ReflectDefault, FromReflect, GetTypeRegistration, Reflect, ReflectDeserialize,
ReflectSerialize,
ReflectFromReflect, ReflectSerialize,
};
use serde::{Deserialize, Serialize};
@ -62,8 +62,8 @@ pub trait CameraProjection {
}
/// A configurable [`CameraProjection`] that can select its projection type at runtime.
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Debug, Clone, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub enum Projection {
Perspective(PerspectiveProjection),
Orthographic(OrthographicProjection),

View file

@ -6,11 +6,11 @@ use bevy_ecs::{
reflect::ReflectMapEntities,
};
use bevy_math::Mat4;
use bevy_reflect::{Reflect, TypePath, TypeUuid};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypePath, TypeUuid};
use std::ops::Deref;
#[derive(Component, Debug, Default, Clone, Reflect)]
#[reflect(Component, MapEntities)]
#[derive(Component, Debug, Default, Clone, Reflect, FromReflect)]
#[reflect(Component, MapEntities, FromReflect)]
pub struct SkinnedMesh {
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
pub joints: Vec<Entity>,

View file

@ -1,6 +1,6 @@
use bevy_ecs::{component::Component, prelude::Entity, reflect::ReflectComponent};
use bevy_math::{Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles};
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use bevy_utils::HashMap;
/// An axis-aligned bounding box.
@ -126,8 +126,8 @@ impl HalfSpace {
/// A frustum made up of the 6 defining half spaces.
/// Half spaces are ordered left, right, top, bottom, near, far.
/// The normal vectors of the half spaces point towards the interior of the frustum.
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
#[reflect(Component)]
#[derive(Component, Clone, Copy, Debug, Default, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct Frustum {
#[reflect(ignore)]
pub half_spaces: [HalfSpace; 6],
@ -223,8 +223,8 @@ impl Frustum {
}
}
#[derive(Component, Debug, Default, Reflect)]
#[reflect(Component)]
#[derive(Component, Debug, Default, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct CubemapFrusta {
#[reflect(ignore)]
pub frusta: [Frustum; 6],
@ -239,8 +239,8 @@ impl CubemapFrusta {
}
}
#[derive(Component, Debug, Default, Reflect)]
#[reflect(Component)]
#[derive(Component, Debug, Default, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct CascadesFrusta {
#[reflect(ignore)]
pub frusta: HashMap<Entity, Vec<Frustum>>,

View file

@ -171,8 +171,8 @@ pub struct NoFrustumCulling;
///
/// Currently this component is ignored by the sprite renderer, so sprite rendering
/// is not optimized per view.
#[derive(Clone, Component, Default, Debug, Reflect)]
#[reflect(Component)]
#[derive(Clone, Component, Default, Debug, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct VisibleEntities {
#[reflect(ignore)]
pub entities: Vec<Entity>,

View file

@ -7,7 +7,7 @@ use bevy_ecs::{
system::{lifetimeless::*, SystemParamItem, SystemState},
};
use bevy_math::{Mat4, Vec2};
use bevy_reflect::{Reflect, TypeUuid};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypeUuid};
use bevy_render::{
extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin},
globals::{GlobalsBuffer, GlobalsUniform},
@ -29,8 +29,8 @@ use bevy_transform::components::GlobalTransform;
/// Component for rendering with meshes in the 2d pipeline, usually with a [2d material](crate::Material2d) such as [`ColorMaterial`](crate::ColorMaterial).
///
/// It wraps a [`Handle<Mesh>`] to differentiate from the 3d pipelines which use the handles directly as components
#[derive(Default, Clone, Component, Debug, Reflect)]
#[reflect(Component)]
#[derive(Default, Clone, Component, Debug, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct Mesh2dHandle(pub Handle<Mesh>);
impl From<Handle<Mesh>> for Mesh2dHandle {

View file

@ -10,7 +10,7 @@ use bevy_ecs::{
system::{Local, Query, Res, ResMut},
};
use bevy_math::{Vec2, Vec3};
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use bevy_render::{
prelude::Color,
texture::Image,
@ -34,8 +34,8 @@ use crate::{
/// Note: only characters that are completely out of the bounds will be truncated, so this is not a
/// reliable limit if it is necessary to contain the text strictly in the bounds. Currently this
/// component is mainly useful for text wrapping only.
#[derive(Component, Copy, Clone, Debug, Reflect)]
#[reflect(Component)]
#[derive(Component, Copy, Clone, Debug, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct Text2dBounds {
pub size: Vec2,
}

View file

@ -3,7 +3,7 @@ use std::ops::Mul;
use super::Transform;
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_math::{Affine3A, Mat4, Quat, Vec3, Vec3A};
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
/// Describe the position of an entity relative to the reference frame.
///
@ -35,7 +35,7 @@ use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
/// [`transform`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect, FromReflect)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[reflect(Component, Default, PartialEq)]
#[reflect(Component, Default, PartialEq, FromReflect)]
pub struct GlobalTransform(Affine3A);
macro_rules! impl_local_axis {

View file

@ -37,7 +37,7 @@ use std::ops::Mul;
/// [`Transform`]: super::Transform
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect, FromReflect)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[reflect(Component, Default, PartialEq)]
#[reflect(Component, Default, PartialEq, FromReflect)]
pub struct Transform {
/// Position of the entity. In 2d, the last value of the `Vec3` is used for z-ordering.
///

View file

@ -1,7 +1,7 @@
use bevy_ecs::prelude::Component;
use bevy_ecs::reflect::ReflectComponent;
use bevy_math::Vec2;
use bevy_reflect::Reflect;
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
use std::fmt::Formatter;
pub use taffy::style::AvailableSpace;
@ -45,8 +45,8 @@ impl Measure for FixedMeasure {
/// A node with a `ContentSize` component is a node where its size
/// is based on its content.
#[derive(Component, Reflect)]
#[reflect(Component)]
#[derive(Component, Reflect, FromReflect)]
#[reflect(Component, FromReflect)]
pub struct ContentSize {
/// The `Measure` used to compute the intrinsic size
#[reflect(ignore)]

View file

@ -15,8 +15,8 @@ use std::ops::{Div, DivAssign, Mul, MulAssign};
use thiserror::Error;
/// Describes the size of a UI node
#[derive(Component, Debug, Copy, Clone, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Debug, Copy, Clone, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub struct Node {
/// The size of the node as width and height in logical pixels
/// automatically calculated by [`super::layout::ui_layout_system`]
@ -1585,8 +1585,8 @@ impl Default for BorderColor {
}
/// The 2D texture displayed for this UI node
#[derive(Component, Clone, Debug, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Clone, Debug, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub struct UiImage {
/// Handle to the texture
pub texture: Handle<Image>,

View file

@ -8,7 +8,7 @@ use bevy_ecs::{
world::{Mut, Ref},
};
use bevy_math::Vec2;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
use bevy_render::texture::Image;
use bevy_sprite::TextureAtlas;
use bevy_text::{
@ -21,8 +21,8 @@ use taffy::style::AvailableSpace;
/// Text system flags
///
/// Used internally by [`measure_text_system`] and [`text_system`] to schedule text for processing.
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default)]
#[derive(Component, Debug, Clone, Reflect, FromReflect)]
#[reflect(Component, Default, FromReflect)]
pub struct TextFlags {
/// If set a new measure function for the text node will be created
needs_new_measure_func: bool,

View file

@ -1,4 +1,4 @@
use bevy_reflect::{prelude::ReflectDefault, FromReflect, Reflect};
use bevy_reflect::{prelude::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
#[cfg(feature = "serialize")]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
@ -14,7 +14,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq, Default)]
#[reflect(Debug, PartialEq, Default, FromReflect)]
pub enum CursorIcon {
/// The platform-dependent default cursor.
#[default]

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
use bevy_ecs::entity::Entity;
use bevy_ecs::event::Event;
use bevy_math::{IVec2, Vec2};
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
#[cfg(feature = "serialize")]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
@ -12,7 +12,7 @@ use crate::WindowTheme;
/// A window event that is sent whenever a window's logical size has changed.
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -30,7 +30,7 @@ pub struct WindowResized {
/// An event that indicates all of the application's windows should be redrawn,
/// even if their control flow is set to `Wait` and there have been no window events.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -42,7 +42,7 @@ pub struct RequestRedraw;
///
/// To create a new window, spawn an entity with a [`crate::Window`] on it.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -64,7 +64,7 @@ pub struct WindowCreated {
/// [`WindowPlugin`]: crate::WindowPlugin
/// [`Window`]: crate::Window
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -78,7 +78,7 @@ pub struct WindowCloseRequested {
/// An event that is sent whenever a window is closed. This will be sent when
/// the window entity loses its [`Window`](crate::window::Window) component or is despawned.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -101,7 +101,7 @@ pub struct WindowClosed {
/// [`WindowEvent::CursorMoved`]: https://docs.rs/winit/latest/winit/event/enum.WindowEvent.html#variant.CursorMoved
/// [`MouseMotion`]: bevy_input::mouse::MouseMotion
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -116,7 +116,7 @@ pub struct CursorMoved {
/// An event that is sent whenever the user's cursor enters a window.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -129,7 +129,7 @@ pub struct CursorEntered {
/// An event that is sent whenever the user's cursor leaves a window.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -142,7 +142,7 @@ pub struct CursorLeft {
/// An event that is sent whenever a window receives a character from the OS or underlying system.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -161,7 +161,7 @@ pub struct ReceivedCharacter {
///
/// It is only sent if IME was enabled on the window with [`Window::ime_enabled`](crate::window::Window::ime_enabled).
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -203,7 +203,7 @@ pub enum Ime {
/// An event that indicates a window has received or lost focus.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -218,7 +218,7 @@ pub struct WindowFocused {
/// An event that indicates a window's scale factor has changed.
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -233,7 +233,7 @@ pub struct WindowScaleFactorChanged {
/// An event that indicates a window's OS-reported scale factor has changed.
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -248,7 +248,7 @@ pub struct WindowBackendScaleFactorChanged {
/// Events related to files being dragged and dropped on a window.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -280,7 +280,7 @@ pub enum FileDragAndDrop {
/// An event that is sent when a window is repositioned in physical pixels.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
@ -298,7 +298,7 @@ pub struct WindowMoved {
/// This event is only sent when the window is relying on the system theme to control its appearance.
/// i.e. It is only sent when [`Window::window_theme`](crate::window::Window::window_theme) is `None` and the system theme changes.
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),

View file

@ -3,7 +3,7 @@ use bevy_ecs::{
prelude::{Component, ReflectComponent},
};
use bevy_math::{DVec2, IVec2, Vec2};
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
#[cfg(feature = "serialize")]
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
@ -15,8 +15,10 @@ use crate::CursorIcon;
/// Marker component for the window considered the primary window.
///
/// Currently this is assumed to only exist on 1 entity at a time.
#[derive(Default, Debug, Component, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Reflect)]
#[reflect(Component)]
#[derive(
Default, Debug, Component, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Reflect, FromReflect,
)]
#[reflect(Component, FromReflect)]
pub struct PrimaryWindow;
/// Reference to a window, whether it be a direct link to a specific entity or
@ -91,7 +93,7 @@ impl NormalizedWindowRef {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Component, Default)]
#[reflect(Component, Default, FromReflect)]
pub struct Window {
/// The cursor of this window.
pub cursor: Cursor,
@ -307,7 +309,7 @@ impl Window {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq, Default)]
#[reflect(Debug, PartialEq, Default, FromReflect)]
pub struct WindowResizeConstraints {
/// The minimum width the window can have.
pub min_width: f32,
@ -374,7 +376,7 @@ impl WindowResizeConstraints {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, Default)]
#[reflect(Debug, Default, FromReflect)]
pub struct Cursor {
/// Get the current [`CursorIcon`] while inside the window.
pub icon: CursorIcon,
@ -426,7 +428,7 @@ impl Default for Cursor {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
pub enum WindowPosition {
/// Position will be set by the window manager
#[default]
@ -477,7 +479,7 @@ impl WindowPosition {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq, Default)]
#[reflect(Debug, PartialEq, Default, FromReflect)]
pub struct WindowResolution {
physical_width: u32,
physical_height: u32,
@ -641,7 +643,7 @@ impl From<bevy_math::DVec2> for WindowResolution {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq, Default)]
#[reflect(Debug, PartialEq, Default, FromReflect)]
pub enum CursorGrabMode {
/// The cursor can freely leave the window.
#[default]
@ -659,7 +661,7 @@ pub enum CursorGrabMode {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq, Default)]
#[reflect(Debug, PartialEq, Default, FromReflect)]
pub struct InternalWindowState {
/// If this is true then next frame we will ask to minimize the window.
minimize_request: Option<bool>,
@ -688,7 +690,7 @@ impl InternalWindowState {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
pub enum MonitorSelection {
/// Uses current monitor of the window.
///
@ -726,7 +728,7 @@ pub enum MonitorSelection {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq, Hash)]
#[reflect(Debug, PartialEq, Hash, FromReflect)]
#[doc(alias = "vsync")]
pub enum PresentMode {
/// Chooses FifoRelaxed -> Fifo based on availability.
@ -766,7 +768,7 @@ pub enum PresentMode {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq, Hash)]
#[reflect(Debug, PartialEq, Hash, FromReflect)]
pub enum CompositeAlphaMode {
/// Chooses either [`Opaque`](CompositeAlphaMode::Opaque) or [`Inherit`](CompositeAlphaMode::Inherit)
/// automatically, depending on the `alpha_mode` that the current surface can support.
@ -801,7 +803,7 @@ pub enum CompositeAlphaMode {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
pub enum WindowMode {
/// Creates a window that uses the given size.
#[default]
@ -829,7 +831,7 @@ pub enum WindowMode {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
pub enum WindowLevel {
/// The window will always be below normal windows.
///
@ -849,7 +851,7 @@ pub enum WindowLevel {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
#[reflect(Debug, PartialEq)]
#[reflect(Debug, PartialEq, FromReflect)]
pub enum WindowTheme {
/// Use the light variant.
Light,