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:
parent
23863d526a
commit
7fc6db32ce
@ -11,7 +11,8 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
||||||
use bevy_reflect::{
|
use bevy_reflect::{
|
||||||
std_traits::ReflectDefault, FromReflect, Reflect, ReflectDeserialize, ReflectSerialize,
|
std_traits::ReflectDefault, FromReflect, Reflect, ReflectDeserialize, ReflectFromReflect,
|
||||||
|
ReflectSerialize,
|
||||||
};
|
};
|
||||||
use bevy_utils::Uuid;
|
use bevy_utils::Uuid;
|
||||||
use crossbeam_channel::{Receiver, Sender};
|
use crossbeam_channel::{Receiver, Sender};
|
||||||
@ -103,7 +104,7 @@ impl HandleId {
|
|||||||
/// collisions no longer being detected for that entity.
|
/// collisions no longer being detected for that entity.
|
||||||
///
|
///
|
||||||
#[derive(Component, Reflect, FromReflect)]
|
#[derive(Component, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct Handle<T>
|
pub struct Handle<T>
|
||||||
where
|
where
|
||||||
T: Asset,
|
T: Asset,
|
||||||
|
|||||||
@ -69,16 +69,38 @@ impl<'a> AssetPath<'a> {
|
|||||||
|
|
||||||
/// An unique identifier to an asset path.
|
/// An unique identifier to an asset path.
|
||||||
#[derive(
|
#[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);
|
pub struct AssetPathId(SourcePathId, LabelId);
|
||||||
|
|
||||||
/// An unique identifier to the source path of an asset.
|
/// An unique identifier to the source path of an asset.
|
||||||
#[derive(
|
#[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);
|
pub struct SourcePathId(u64);
|
||||||
|
|
||||||
/// An unique identifier to a sub-asset label.
|
/// An unique identifier to a sub-asset label.
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
component::Component, entity::Entity, query::WorldQuery, reflect::ReflectComponent,
|
component::Component, entity::Entity, query::WorldQuery, reflect::ReflectComponent,
|
||||||
};
|
};
|
||||||
use bevy_reflect::Reflect;
|
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, FromReflect};
|
use bevy_reflect::{std_traits::ReflectDefault, FromReflect};
|
||||||
|
use bevy_reflect::{Reflect, ReflectFromReflect};
|
||||||
use bevy_utils::AHasher;
|
use bevy_utils::AHasher;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -18,7 +18,7 @@ use std::{
|
|||||||
/// as multiple entities can have the same name. [`bevy_ecs::entity::Entity`] should be
|
/// as multiple entities can have the same name. [`bevy_ecs::entity::Entity`] should be
|
||||||
/// used instead as the default unique identifier.
|
/// used instead as the default unique identifier.
|
||||||
#[derive(Reflect, FromReflect, Component, Clone)]
|
#[derive(Reflect, FromReflect, Component, Clone)]
|
||||||
#[reflect(Component, Default, Debug)]
|
#[reflect(Component, Default, Debug, FromReflect)]
|
||||||
pub struct Name {
|
pub struct Name {
|
||||||
hash: u64, // TODO: Shouldn't be serialized
|
hash: u64, // TODO: Shouldn't be serialized
|
||||||
name: Cow<'static, str>,
|
name: Cow<'static, str>,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use super::downsampling_pipeline::BloomUniforms;
|
use super::downsampling_pipeline::BloomUniforms;
|
||||||
use bevy_ecs::{prelude::Component, query::QueryItem, reflect::ReflectComponent};
|
use bevy_ecs::{prelude::Component, query::QueryItem, reflect::ReflectComponent};
|
||||||
use bevy_math::{UVec4, Vec4};
|
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};
|
use bevy_render::{extract_component::ExtractComponent, prelude::Camera};
|
||||||
|
|
||||||
/// Applies a bloom effect to an HDR-enabled 2d or 3d 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 creates a physically inaccurate image
|
||||||
/// * Changing these settings makes it easy to make the final result look worse
|
/// * 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`]
|
/// * 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 {
|
pub struct BloomPrefilterSettings {
|
||||||
/// Baseline of the quadratic threshold curve (default: 0.0).
|
/// Baseline of the quadratic threshold curve (default: 0.0).
|
||||||
///
|
///
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_ecs::prelude::*;
|
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 bevy_render::{color::Color, extract_resource::ExtractResource};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Reflect, Serialize, Deserialize, Clone, Debug, Default)]
|
#[derive(Reflect, FromReflect, Serialize, Deserialize, Clone, Debug, Default)]
|
||||||
#[reflect(Serialize, Deserialize)]
|
#[reflect(Serialize, Deserialize, FromReflect)]
|
||||||
pub enum ClearColorConfig {
|
pub enum ClearColorConfig {
|
||||||
#[default]
|
#[default]
|
||||||
Default,
|
Default,
|
||||||
@ -17,8 +19,8 @@ pub enum 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, FromReflect)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource, FromReflect)]
|
||||||
pub struct ClearColor(pub Color);
|
pub struct ClearColor(pub Color);
|
||||||
|
|
||||||
impl Default for ClearColor {
|
impl Default for ClearColor {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use crate::{
|
|||||||
tonemapping::{DebandDither, Tonemapping},
|
tonemapping::{DebandDither, Tonemapping},
|
||||||
};
|
};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::{Camera, CameraProjection, CameraRenderGraph, OrthographicProjection},
|
camera::{Camera, CameraProjection, CameraRenderGraph, OrthographicProjection},
|
||||||
extract_component::ExtractComponent,
|
extract_component::ExtractComponent,
|
||||||
@ -12,9 +12,9 @@ use bevy_render::{
|
|||||||
};
|
};
|
||||||
use bevy_transform::prelude::{GlobalTransform, Transform};
|
use bevy_transform::prelude::{GlobalTransform, Transform};
|
||||||
|
|
||||||
#[derive(Component, Default, Reflect, Clone, ExtractComponent)]
|
#[derive(Component, Default, Reflect, FromReflect, Clone, ExtractComponent)]
|
||||||
#[extract_component_filter(With<Camera>)]
|
#[extract_component_filter(With<Camera>)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct Camera2d {
|
pub struct Camera2d {
|
||||||
pub clear_color: ClearColorConfig,
|
pub clear_color: ClearColorConfig,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,9 @@ use crate::{
|
|||||||
tonemapping::{DebandDither, Tonemapping},
|
tonemapping::{DebandDither, Tonemapping},
|
||||||
};
|
};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{
|
||||||
|
FromReflect, Reflect, ReflectDeserialize, ReflectFromReflect, ReflectSerialize,
|
||||||
|
};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
camera::{Camera, CameraRenderGraph, Projection},
|
camera::{Camera, CameraRenderGraph, Projection},
|
||||||
extract_component::ExtractComponent,
|
extract_component::ExtractComponent,
|
||||||
@ -15,9 +17,9 @@ use bevy_transform::prelude::{GlobalTransform, Transform};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Configuration for the "main 3d render graph".
|
/// Configuration for the "main 3d render graph".
|
||||||
#[derive(Component, Reflect, Clone, ExtractComponent)]
|
#[derive(Component, Reflect, FromReflect, Clone, ExtractComponent)]
|
||||||
#[extract_component_filter(With<Camera>)]
|
#[extract_component_filter(With<Camera>)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct Camera3d {
|
pub struct Camera3d {
|
||||||
/// The clear color operation to perform for the main 3d pass.
|
/// The clear color operation to perform for the main 3d pass.
|
||||||
pub clear_color: ClearColorConfig,
|
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);
|
pub struct Camera3dDepthTextureUsage(u32);
|
||||||
|
|
||||||
impl From<TextureUsages> for Camera3dDepthTextureUsage {
|
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.
|
/// The depth clear operation to perform for the main 3d pass.
|
||||||
#[derive(Reflect, Serialize, Deserialize, Clone, Debug)]
|
#[derive(Reflect, FromReflect, Serialize, Deserialize, Clone, Debug)]
|
||||||
#[reflect(Serialize, Deserialize)]
|
#[reflect(Serialize, Deserialize, FromReflect)]
|
||||||
pub enum Camera3dDepthLoadOp {
|
pub enum Camera3dDepthLoadOp {
|
||||||
/// Clear with a specified value.
|
/// Clear with a specified value.
|
||||||
/// Note that 0.0 is the far plane due to bevy's use of reverse-z projections.
|
/// Note that 0.0 is the far plane due to bevy's use of reverse-z projections.
|
||||||
|
|||||||
@ -30,7 +30,7 @@ pub mod node;
|
|||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
|
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
render_phase::{CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem},
|
render_phase::{CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem},
|
||||||
render_resource::{CachedRenderPipelineId, Extent3d, TextureFormat},
|
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;
|
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.
|
/// 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;
|
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.
|
/// 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.
|
/// Normals will have normal map textures already applied.
|
||||||
#[derive(Component, Default, Reflect)]
|
#[derive(Component, Default, Reflect, FromReflect)]
|
||||||
|
#[reflect(FromReflect)]
|
||||||
pub struct NormalPrepass;
|
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.
|
/// 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;
|
pub struct MotionVectorPrepass;
|
||||||
|
|
||||||
/// Textures that are written to by the prepass.
|
/// Textures that are written to by the prepass.
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
|
|||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_asset::{load_internal_asset, Assets, Handle, HandleUntyped};
|
use bevy_asset::{load_internal_asset, Assets, Handle, HandleUntyped};
|
||||||
use bevy_ecs::prelude::*;
|
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::camera::Camera;
|
||||||
use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
||||||
use bevy_render::extract_resource::{ExtractResource, ExtractResourcePlugin};
|
use bevy_render::extract_resource::{ExtractResource, ExtractResourcePlugin};
|
||||||
@ -127,7 +127,7 @@ pub struct TonemappingPipeline {
|
|||||||
FromReflect,
|
FromReflect,
|
||||||
)]
|
)]
|
||||||
#[extract_component_filter(With<Camera>)]
|
#[extract_component_filter(With<Camera>)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub enum Tonemapping {
|
pub enum Tonemapping {
|
||||||
/// Bypass tonemapping.
|
/// Bypass tonemapping.
|
||||||
None,
|
None,
|
||||||
@ -314,7 +314,7 @@ pub fn queue_view_tonemapping_pipelines(
|
|||||||
FromReflect,
|
FromReflect,
|
||||||
)]
|
)]
|
||||||
#[extract_component_filter(With<Camera>)]
|
#[extract_component_filter(With<Camera>)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub enum DebandDither {
|
pub enum DebandDither {
|
||||||
#[default]
|
#[default]
|
||||||
Disabled,
|
Disabled,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use bevy_app::prelude::*;
|
|||||||
use bevy_asset::{AddAsset, Handle};
|
use bevy_asset::{AddAsset, Handle};
|
||||||
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
|
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
|
||||||
use bevy_pbr::StandardMaterial;
|
use bevy_pbr::StandardMaterial;
|
||||||
use bevy_reflect::{Reflect, TypePath, TypeUuid};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypePath, TypeUuid};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
mesh::{Mesh, MeshVertexAttribute},
|
mesh::{Mesh, MeshVertexAttribute},
|
||||||
renderer::RenderDevice,
|
renderer::RenderDevice,
|
||||||
@ -106,8 +106,8 @@ pub struct GltfPrimitive {
|
|||||||
pub material_extras: Option<GltfExtras>,
|
pub material_extras: Option<GltfExtras>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Reflect, Default, Component)]
|
#[derive(Clone, Debug, Reflect, FromReflect, Default, Component)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct GltfExtras {
|
pub struct GltfExtras {
|
||||||
pub value: String,
|
pub value: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use bevy_ecs::{
|
|||||||
reflect::{ReflectComponent, ReflectMapEntities},
|
reflect::{ReflectComponent, ReflectMapEntities},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use core::slice;
|
use core::slice;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
@ -16,8 +16,8 @@ use std::ops::Deref;
|
|||||||
///
|
///
|
||||||
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
|
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
|
||||||
/// [`Query`]: bevy_ecs::system::Query
|
/// [`Query`]: bevy_ecs::system::Query
|
||||||
#[derive(Component, Debug, Reflect)]
|
#[derive(Component, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Component, MapEntities)]
|
#[reflect(Component, MapEntities, FromReflect)]
|
||||||
pub struct Children(pub(crate) SmallVec<[Entity; 8]>);
|
pub struct Children(pub(crate) SmallVec<[Entity; 8]>);
|
||||||
|
|
||||||
impl MapEntities for Children {
|
impl MapEntities for Children {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use bevy_ecs::{
|
|||||||
reflect::{ReflectComponent, ReflectMapEntities},
|
reflect::{ReflectComponent, ReflectMapEntities},
|
||||||
world::{FromWorld, World},
|
world::{FromWorld, World},
|
||||||
};
|
};
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
/// Holds a reference to the parent entity of this entity.
|
/// Holds a reference to the parent entity of this entity.
|
||||||
@ -14,8 +14,8 @@ use std::ops::Deref;
|
|||||||
///
|
///
|
||||||
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
|
/// [`HierarchyQueryExt`]: crate::query_extension::HierarchyQueryExt
|
||||||
/// [`Query`]: bevy_ecs::system::Query
|
/// [`Query`]: bevy_ecs::system::Query
|
||||||
#[derive(Component, Debug, Eq, PartialEq, Reflect)]
|
#[derive(Component, Debug, Eq, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Component, MapEntities, PartialEq)]
|
#[reflect(Component, MapEntities, PartialEq, FromReflect)]
|
||||||
pub struct Parent(pub(crate) Entity);
|
pub struct Parent(pub(crate) Entity);
|
||||||
|
|
||||||
impl Parent {
|
impl Parent {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ use bevy_ecs::{
|
|||||||
change_detection::DetectChangesMut,
|
change_detection::DetectChangesMut,
|
||||||
system::{Res, ResMut, Resource},
|
system::{Res, ResMut, Resource},
|
||||||
};
|
};
|
||||||
|
use bevy_reflect::ReflectFromReflect;
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
|
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
|
||||||
use bevy_utils::Duration;
|
use bevy_utils::Duration;
|
||||||
use bevy_utils::{tracing::info, HashMap};
|
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.
|
/// 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)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -93,7 +94,7 @@ impl Gamepad {
|
|||||||
|
|
||||||
/// Metadata associated with a [`Gamepad`].
|
/// Metadata associated with a [`Gamepad`].
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -154,7 +155,7 @@ impl Gamepads {
|
|||||||
/// which in turn is used to create the [`Input<GamepadButton>`] or
|
/// which in turn is used to create the [`Input<GamepadButton>`] or
|
||||||
/// [`Axis<GamepadButton>`] `bevy` resources.
|
/// [`Axis<GamepadButton>`] `bevy` resources.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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`].
|
/// The gamepad button resources are updated inside of the [`gamepad_button_event_system`].
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -261,7 +262,7 @@ impl GamepadButton {
|
|||||||
/// [`GamepadAxisChangedEvent`]. It is also used in the [`GamepadAxis`]
|
/// [`GamepadAxisChangedEvent`]. It is also used in the [`GamepadAxis`]
|
||||||
/// which in turn is used to create the [`Axis<GamepadAxis>`] `bevy` resource.
|
/// which in turn is used to create the [`Axis<GamepadAxis>`] `bevy` resource.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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`].
|
/// The gamepad axes resources are updated inside of the [`gamepad_axis_event_system`].
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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`]
|
/// 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.
|
/// will not register. To modify these settings, mutate the corresponding resource.
|
||||||
#[derive(Resource, Default, Debug, Reflect, FromReflect)]
|
#[derive(Resource, Default, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Default)]
|
#[reflect(Debug, Default, FromReflect)]
|
||||||
pub struct GamepadSettings {
|
pub struct GamepadSettings {
|
||||||
/// The default button settings.
|
/// The default button settings.
|
||||||
pub default_button_settings: ButtonSettings,
|
pub default_button_settings: ButtonSettings,
|
||||||
@ -425,7 +426,7 @@ impl GamepadSettings {
|
|||||||
///
|
///
|
||||||
/// Allowed values: `0.0 <= ``release_threshold`` <= ``press_threshold`` <= 1.0`
|
/// Allowed values: `0.0 <= ``release_threshold`` <= ``press_threshold`` <= 1.0`
|
||||||
#[derive(Debug, Clone, Reflect, FromReflect)]
|
#[derive(Debug, Clone, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Default)]
|
#[reflect(Debug, Default, FromReflect)]
|
||||||
pub struct ButtonSettings {
|
pub struct ButtonSettings {
|
||||||
press_threshold: f32,
|
press_threshold: f32,
|
||||||
release_threshold: f32,
|
release_threshold: f32,
|
||||||
@ -585,7 +586,7 @@ impl ButtonSettings {
|
|||||||
///
|
///
|
||||||
/// The valid range is `[-1.0, 1.0]`.
|
/// The valid range is `[-1.0, 1.0]`.
|
||||||
#[derive(Debug, Clone, Reflect, FromReflect, PartialEq)]
|
#[derive(Debug, Clone, Reflect, FromReflect, PartialEq)]
|
||||||
#[reflect(Debug, Default)]
|
#[reflect(Debug, Default, FromReflect)]
|
||||||
pub struct AxisSettings {
|
pub struct AxisSettings {
|
||||||
/// Values that are higher than `livezone_upperbound` will be rounded up to 1.0.
|
/// Values that are higher than `livezone_upperbound` will be rounded up to 1.0.
|
||||||
livezone_upperbound: f32,
|
livezone_upperbound: f32,
|
||||||
@ -917,7 +918,7 @@ impl AxisSettings {
|
|||||||
///
|
///
|
||||||
/// The current value of a button is received through the [`GamepadButtonChangedEvent`].
|
/// The current value of a button is received through the [`GamepadButtonChangedEvent`].
|
||||||
#[derive(Debug, Clone, Reflect, FromReflect)]
|
#[derive(Debug, Clone, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Default)]
|
#[reflect(Debug, Default, FromReflect)]
|
||||||
pub struct ButtonAxisSettings {
|
pub struct ButtonAxisSettings {
|
||||||
/// The high value at which to apply rounding.
|
/// The high value at which to apply rounding.
|
||||||
pub high: f32,
|
pub high: f32,
|
||||||
@ -1026,7 +1027,7 @@ pub fn gamepad_connection_system(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -1040,7 +1041,7 @@ pub enum GamepadConnection {
|
|||||||
/// A Gamepad connection event. Created when a connection to a gamepad
|
/// A Gamepad connection event. Created when a connection to a gamepad
|
||||||
/// is established and when a gamepad is disconnected.
|
/// is established and when a gamepad is disconnected.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -1071,7 +1072,7 @@ impl GamepadConnectionEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -1096,7 +1097,7 @@ impl GamepadAxisChangedEvent {
|
|||||||
/// Gamepad event for when the "value" (amount of pressure) on the button
|
/// Gamepad event for when the "value" (amount of pressure) on the button
|
||||||
/// changes by an amount larger than the threshold defined in [`GamepadSettings`].
|
/// changes by an amount larger than the threshold defined in [`GamepadSettings`].
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -1159,7 +1160,7 @@ pub fn gamepad_button_event_system(
|
|||||||
/// [`GamepadButtonChangedEvent`] and [`GamepadAxisChangedEvent`] when
|
/// [`GamepadButtonChangedEvent`] and [`GamepadAxisChangedEvent`] when
|
||||||
/// the in-frame relative ordering of events is important.
|
/// the in-frame relative ordering of events is important.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use bevy_ecs::system::Resource;
|
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 bevy_utils::HashSet;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ use bevy_ecs::schedule::State;
|
|||||||
///
|
///
|
||||||
///[`ResMut`]: bevy_ecs::system::ResMut
|
///[`ResMut`]: bevy_ecs::system::ResMut
|
||||||
///[`DetectChangesMut::bypass_change_detection`]: bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection
|
///[`DetectChangesMut::bypass_change_detection`]: bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection
|
||||||
#[derive(Debug, Clone, Resource, Reflect)]
|
#[derive(Debug, Clone, Resource, Reflect, FromReflect)]
|
||||||
#[reflect(Default)]
|
#[reflect(Default, FromReflect)]
|
||||||
pub struct Input<T: Copy + Eq + Hash + Send + Sync + 'static> {
|
pub struct Input<T: Copy + Eq + Hash + Send + Sync + 'static> {
|
||||||
/// A collection of every button that is currently being pressed.
|
/// A collection of every button that is currently being pressed.
|
||||||
pressed: HashSet<T>,
|
pressed: HashSet<T>,
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use bevy_ecs::{
|
|||||||
event::{Event, EventReader},
|
event::{Event, EventReader},
|
||||||
system::ResMut,
|
system::ResMut,
|
||||||
};
|
};
|
||||||
use bevy_reflect::{FromReflect, Reflect};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
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)
|
/// The event is consumed inside of the [`keyboard_input_system`](crate::keyboard::keyboard_input_system)
|
||||||
/// to update the [`Input<KeyCode>`](crate::Input<KeyCode>) resource.
|
/// to update the [`Input<KeyCode>`](crate::Input<KeyCode>) resource.
|
||||||
#[derive(Event, Debug, Clone, Copy, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, Copy, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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).
|
/// 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)]
|
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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).
|
/// 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)]
|
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
|
|||||||
@ -28,7 +28,7 @@ pub mod prelude {
|
|||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::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 keyboard::{keyboard_input_system, KeyCode, KeyboardInput, ScanCode};
|
||||||
use mouse::{
|
use mouse::{
|
||||||
mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion, MouseScrollUnit,
|
mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion, MouseScrollUnit,
|
||||||
@ -141,7 +141,7 @@ impl Plugin for InputPlugin {
|
|||||||
|
|
||||||
/// The current "press" state of an element
|
/// The current "press" state of an element
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Reflect, FromReflect)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use bevy_ecs::{
|
|||||||
system::ResMut,
|
system::ResMut,
|
||||||
};
|
};
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
use bevy_reflect::{FromReflect, Reflect};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
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)
|
/// 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.
|
/// to update the [`Input<MouseButton>`](crate::Input<MouseButton>) resource.
|
||||||
#[derive(Event, Debug, Clone, Copy, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, Copy, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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).
|
/// 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)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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
|
/// [`DeviceEvent::MouseMotion`]: https://docs.rs/winit/latest/winit/event/enum.DeviceEvent.html#variant.MouseMotion
|
||||||
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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
|
/// The value of the event can either be interpreted as the amount of lines or the amount of pixels
|
||||||
/// to scroll.
|
/// to scroll.
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Reflect, FromReflect)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// This event is the translated version of the `WindowEvent::MouseWheel` from the `winit` crate.
|
||||||
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use bevy_ecs::event::{Event, EventReader};
|
use bevy_ecs::event::{Event, EventReader};
|
||||||
use bevy_ecs::system::{ResMut, Resource};
|
use bevy_ecs::system::{ResMut, Resource};
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
use bevy_reflect::{FromReflect, Reflect};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
#[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.
|
/// 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.
|
/// It is available to the end user and can be used for game logic.
|
||||||
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -53,7 +53,7 @@ pub struct TouchInput {
|
|||||||
|
|
||||||
/// A force description of a [`Touch`](crate::touch::Touch) input.
|
/// A force description of a [`Touch`](crate::touch::Touch) input.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
#[derive(Debug, Clone, Copy, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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
|
/// or that a finger has moved. There is also a canceled phase that indicates that
|
||||||
/// the system canceled the tracking of the finger.
|
/// the system canceled the tracking of the finger.
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, Hash, PartialEq)]
|
#[reflect(Debug, Hash, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use bevy_reflect::std_traits::ReflectDefault;
|
use bevy_reflect::std_traits::ReflectDefault;
|
||||||
use bevy_reflect::{FromReflect, Reflect};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
|
|
||||||
// TODO: add discussion about performance.
|
// TODO: add discussion about performance.
|
||||||
/// Sets how a material's base color alpha channel is used for transparency.
|
/// Sets how a material's base color alpha channel is used for transparency.
|
||||||
#[derive(Debug, Default, Reflect, Copy, Clone, PartialEq, FromReflect)]
|
#[derive(Debug, Default, Reflect, Copy, Clone, PartialEq, FromReflect)]
|
||||||
#[reflect(Default, Debug)]
|
#[reflect(Default, Debug, FromReflect)]
|
||||||
pub enum AlphaMode {
|
pub enum AlphaMode {
|
||||||
/// Base color alpha values are overridden to be fully opaque (1.0).
|
/// Base color alpha values are overridden to be fully opaque (1.0).
|
||||||
#[default]
|
#[default]
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use bevy_asset::Handle;
|
use bevy_asset::Handle;
|
||||||
use bevy_ecs::{bundle::Bundle, component::Component, prelude::Entity, reflect::ReflectComponent};
|
use bevy_ecs::{bundle::Bundle, component::Component, prelude::Entity, reflect::ReflectComponent};
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
mesh::Mesh,
|
mesh::Mesh,
|
||||||
primitives::{CascadesFrusta, CubemapFrusta, Frustum},
|
primitives::{CascadesFrusta, CubemapFrusta, Frustum},
|
||||||
@ -42,8 +42,8 @@ impl<M: Material> Default for MaterialMeshBundle<M> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Debug, Default, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct CubemapVisibleEntities {
|
pub struct CubemapVisibleEntities {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
data: [VisibleEntities; 6],
|
data: [VisibleEntities; 6],
|
||||||
@ -67,8 +67,8 @@ impl CubemapVisibleEntities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Debug, Default, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct CascadesVisibleEntities {
|
pub struct CascadesVisibleEntities {
|
||||||
/// Map of view entity to the visible entities for each cascade frustum.
|
/// Map of view entity to the visible entities for each cascade frustum.
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use crate::ReflectComponent;
|
use crate::ReflectComponent;
|
||||||
use bevy_ecs::{prelude::*, query::QueryItem};
|
use bevy_ecs::{prelude::*, query::QueryItem};
|
||||||
use bevy_math::Vec3;
|
use bevy_math::Vec3;
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Camera};
|
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,
|
/// 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
|
/// Once enabled for a specific camera, the fog effect can also be disabled for individual
|
||||||
/// [`StandardMaterial`](crate::StandardMaterial) instances via the `fog_enabled` flag.
|
/// [`StandardMaterial`](crate::StandardMaterial) instances via the `fog_enabled` flag.
|
||||||
#[derive(Debug, Clone, Component, Reflect)]
|
#[derive(Debug, Clone, Component, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct FogSettings {
|
pub struct FogSettings {
|
||||||
/// The color of the fog effect.
|
/// The color of the fog effect.
|
||||||
///
|
///
|
||||||
@ -94,7 +94,8 @@ pub struct FogSettings {
|
|||||||
/// - [`FogFalloff::from_visibility_colors()`]
|
/// - [`FogFalloff::from_visibility_colors()`]
|
||||||
/// - [`FogFalloff::from_visibility_contrast_color()`]
|
/// - [`FogFalloff::from_visibility_contrast_color()`]
|
||||||
/// - [`FogFalloff::from_visibility_contrast_colors()`]
|
/// - [`FogFalloff::from_visibility_contrast_colors()`]
|
||||||
#[derive(Debug, Clone, Reflect)]
|
#[derive(Debug, Clone, Reflect, FromReflect)]
|
||||||
|
#[reflect(FromReflect)]
|
||||||
pub enum FogFalloff {
|
pub enum FogFalloff {
|
||||||
/// A linear fog falloff that grows in intensity between `start` and `end` distances.
|
/// A linear fog falloff that grows in intensity between `start` and `end` distances.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -40,8 +40,8 @@ use crate::{
|
|||||||
/// | 4000 | 300 | | 75-100 | 40.5 |
|
/// | 4000 | 300 | | 75-100 | 40.5 |
|
||||||
///
|
///
|
||||||
/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
|
/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
|
||||||
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
#[derive(Component, Debug, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct PointLight {
|
pub struct PointLight {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
pub intensity: f32,
|
pub intensity: f32,
|
||||||
@ -75,8 +75,8 @@ impl PointLight {
|
|||||||
pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 0.6;
|
pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Clone, Debug, Reflect)]
|
#[derive(Resource, Clone, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource, FromReflect)]
|
||||||
pub struct PointLightShadowMap {
|
pub struct PointLightShadowMap {
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
}
|
}
|
||||||
@ -91,8 +91,8 @@ impl Default for PointLightShadowMap {
|
|||||||
/// Behaves like a point light in a perfectly absorbent housing that
|
/// Behaves like a point light in a perfectly absorbent housing that
|
||||||
/// shines light only in a given direction. The direction is taken from
|
/// 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).
|
/// the transform, and can be specified with [`Transform::looking_at`](bevy_transform::components::Transform::looking_at).
|
||||||
#[derive(Component, Debug, Clone, Copy, Reflect)]
|
#[derive(Component, Debug, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct SpotLight {
|
pub struct SpotLight {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
pub intensity: f32,
|
pub intensity: f32,
|
||||||
@ -187,8 +187,8 @@ impl Default for SpotLight {
|
|||||||
/// App::new()
|
/// App::new()
|
||||||
/// .insert_resource(DirectionalLightShadowMap { size: 2048 });
|
/// .insert_resource(DirectionalLightShadowMap { size: 2048 });
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Component, Debug, Clone, Reflect)]
|
#[derive(Component, Debug, Clone, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct DirectionalLight {
|
pub struct DirectionalLight {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
/// Illuminance in lux
|
/// Illuminance in lux
|
||||||
@ -218,8 +218,8 @@ impl DirectionalLight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Controls the resolution of [`DirectionalLight`] shadow maps.
|
/// Controls the resolution of [`DirectionalLight`] shadow maps.
|
||||||
#[derive(Resource, Clone, Debug, Reflect)]
|
#[derive(Resource, Clone, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource, FromReflect)]
|
||||||
pub struct DirectionalLightShadowMap {
|
pub struct DirectionalLightShadowMap {
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
}
|
}
|
||||||
@ -243,8 +243,8 @@ impl Default for DirectionalLightShadowMap {
|
|||||||
/// ..default()
|
/// ..default()
|
||||||
/// }.into();
|
/// }.into();
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Component, Clone, Debug, Reflect)]
|
#[derive(Component, Clone, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct CascadeShadowConfig {
|
pub struct CascadeShadowConfig {
|
||||||
/// The (positive) distance to the far boundary of each cascade.
|
/// The (positive) distance to the far boundary of each cascade.
|
||||||
pub bounds: Vec<f32>,
|
pub bounds: Vec<f32>,
|
||||||
@ -380,14 +380,15 @@ impl From<CascadeShadowConfigBuilder> for CascadeShadowConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Debug, Default, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct Cascades {
|
pub struct Cascades {
|
||||||
/// Map from a view to the configuration of each of its [`Cascade`]s.
|
/// Map from a view to the configuration of each of its [`Cascade`]s.
|
||||||
pub(crate) cascades: HashMap<Entity, Vec<Cascade>>,
|
pub(crate) cascades: HashMap<Entity, Vec<Cascade>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Reflect, FromReflect)]
|
#[derive(Clone, Debug, Default, Reflect, FromReflect)]
|
||||||
|
#[reflect(FromReflect)]
|
||||||
pub struct Cascade {
|
pub struct Cascade {
|
||||||
/// The transform of the light, i.e. the view to world matrix.
|
/// The transform of the light, i.e. the view to world matrix.
|
||||||
pub(crate) view_transform: Mat4,
|
pub(crate) view_transform: Mat4,
|
||||||
@ -580,8 +581,8 @@ fn calculate_cascade(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An ambient light, which lights the entire scene equally.
|
/// An ambient light, which lights the entire scene equally.
|
||||||
#[derive(Resource, Clone, Debug, ExtractResource, Reflect)]
|
#[derive(Resource, Clone, Debug, ExtractResource, Reflect, FromReflect)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource, FromReflect)]
|
||||||
pub struct AmbientLight {
|
pub struct AmbientLight {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
/// A direct scale factor multiplied with `color` before being passed to the shader.
|
/// 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.
|
/// Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not cast shadows.
|
||||||
#[derive(Component, Reflect, Default)]
|
#[derive(Component, Reflect, FromReflect, Default)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct NotShadowCaster;
|
pub struct NotShadowCaster;
|
||||||
/// Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not receive shadows.
|
/// Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not receive shadows.
|
||||||
#[derive(Component, Reflect, Default)]
|
#[derive(Component, Reflect, FromReflect, Default)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct NotShadowReceiver;
|
pub struct NotShadowReceiver;
|
||||||
|
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
||||||
@ -640,7 +641,7 @@ pub enum ClusterFarZMode {
|
|||||||
|
|
||||||
/// Configure the depth-slicing strategy for clustered forward rendering
|
/// Configure the depth-slicing strategy for clustered forward rendering
|
||||||
#[derive(Debug, Copy, Clone, Reflect, FromReflect)]
|
#[derive(Debug, Copy, Clone, Reflect, FromReflect)]
|
||||||
#[reflect(Default)]
|
#[reflect(Default, FromReflect)]
|
||||||
pub struct ClusterZConfig {
|
pub struct ClusterZConfig {
|
||||||
/// Far `Z` plane of the first depth slice
|
/// Far `Z` plane of the first depth slice
|
||||||
pub first_slice_depth: f32,
|
pub first_slice_depth: f32,
|
||||||
@ -658,8 +659,8 @@ impl Default for ClusterZConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration of the clustering strategy for clustered forward rendering
|
/// Configuration of the clustering strategy for clustered forward rendering
|
||||||
#[derive(Debug, Copy, Clone, Component, Reflect)]
|
#[derive(Debug, Copy, Clone, Component, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub enum ClusterConfig {
|
pub enum ClusterConfig {
|
||||||
/// Disable light cluster calculations for this view
|
/// Disable light cluster calculations for this view
|
||||||
None,
|
None,
|
||||||
|
|||||||
@ -4,7 +4,9 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use bevy_asset::Handle;
|
use bevy_asset::Handle;
|
||||||
use bevy_math::Vec4;
|
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::{
|
use bevy_render::{
|
||||||
color::Color, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, render_resource::*,
|
color::Color, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, render_resource::*,
|
||||||
texture::Image,
|
texture::Image,
|
||||||
@ -19,7 +21,7 @@ use bevy_render::{
|
|||||||
#[uuid = "7494888b-c082-457b-aacf-517228cc0c22"]
|
#[uuid = "7494888b-c082-457b-aacf-517228cc0c22"]
|
||||||
#[bind_group_data(StandardMaterialKey)]
|
#[bind_group_data(StandardMaterialKey)]
|
||||||
#[uniform(0, StandardMaterialUniform)]
|
#[uniform(0, StandardMaterialUniform)]
|
||||||
#[reflect(Default, Debug)]
|
#[reflect(Default, Debug, FromReflect)]
|
||||||
pub struct StandardMaterial {
|
pub struct StandardMaterial {
|
||||||
/// The color of the surface of the material before lighting.
|
/// The color of the surface of the material before lighting.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use bevy_asset::{load_internal_asset, Handle, HandleUntyped};
|
|||||||
use bevy_core_pipeline::core_3d::Opaque3d;
|
use bevy_core_pipeline::core_3d::Opaque3d;
|
||||||
use bevy_ecs::{prelude::*, reflect::ReflectComponent};
|
use bevy_ecs::{prelude::*, reflect::ReflectComponent};
|
||||||
use bevy_reflect::std_traits::ReflectDefault;
|
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::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
||||||
use bevy_render::Render;
|
use bevy_render::Render;
|
||||||
use bevy_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
|
/// Controls whether an entity should rendered in wireframe-mode if the [`WireframePlugin`] is enabled
|
||||||
#[derive(Component, Debug, Clone, Default, ExtractComponent, Reflect)]
|
#[derive(Component, Debug, Clone, Default, ExtractComponent, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct Wireframe;
|
pub struct Wireframe;
|
||||||
|
|
||||||
#[derive(Resource, Debug, Clone, Default, ExtractResource, Reflect)]
|
#[derive(Resource, Debug, Clone, Default, ExtractResource, Reflect, FromReflect)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource, FromReflect)]
|
||||||
pub struct WireframeConfig {
|
pub struct WireframeConfig {
|
||||||
/// Whether to show wireframes for all meshes. If `false`, only meshes with a [Wireframe] component will be rendered.
|
/// Whether to show wireframes for all meshes. If `false`, only meshes with a [Wireframe] component will be rendered.
|
||||||
pub global: bool,
|
pub global: bool,
|
||||||
|
|||||||
@ -377,7 +377,8 @@ impl CameraRenderGraph {
|
|||||||
|
|
||||||
/// The "target" that a [`Camera`] will render to. For example, this could be a [`Window`](bevy_window::Window)
|
/// The "target" that a [`Camera`] will render to. For example, this could be a [`Window`](bevy_window::Window)
|
||||||
/// swapchain or an [`Image`].
|
/// swapchain or an [`Image`].
|
||||||
#[derive(Debug, Clone, Reflect)]
|
#[derive(Debug, Clone, Reflect, FromReflect)]
|
||||||
|
#[reflect(FromReflect)]
|
||||||
pub enum RenderTarget {
|
pub enum RenderTarget {
|
||||||
/// Window to which the camera's view is rendered.
|
/// Window to which the camera's view is rendered.
|
||||||
Window(WindowRef),
|
Window(WindowRef),
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use bevy_ecs::{prelude::*, reflect::ReflectComponent};
|
|||||||
use bevy_math::{Mat4, Rect, Vec2};
|
use bevy_math::{Mat4, Rect, Vec2};
|
||||||
use bevy_reflect::{
|
use bevy_reflect::{
|
||||||
std_traits::ReflectDefault, FromReflect, GetTypeRegistration, Reflect, ReflectDeserialize,
|
std_traits::ReflectDefault, FromReflect, GetTypeRegistration, Reflect, ReflectDeserialize,
|
||||||
ReflectSerialize,
|
ReflectFromReflect, ReflectSerialize,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -62,8 +62,8 @@ 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, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub enum Projection {
|
pub enum Projection {
|
||||||
Perspective(PerspectiveProjection),
|
Perspective(PerspectiveProjection),
|
||||||
Orthographic(OrthographicProjection),
|
Orthographic(OrthographicProjection),
|
||||||
|
|||||||
@ -6,11 +6,11 @@ use bevy_ecs::{
|
|||||||
reflect::ReflectMapEntities,
|
reflect::ReflectMapEntities,
|
||||||
};
|
};
|
||||||
use bevy_math::Mat4;
|
use bevy_math::Mat4;
|
||||||
use bevy_reflect::{Reflect, TypePath, TypeUuid};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypePath, TypeUuid};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[derive(Component, Debug, Default, Clone, Reflect)]
|
#[derive(Component, Debug, Default, Clone, Reflect, FromReflect)]
|
||||||
#[reflect(Component, MapEntities)]
|
#[reflect(Component, MapEntities, FromReflect)]
|
||||||
pub struct SkinnedMesh {
|
pub struct SkinnedMesh {
|
||||||
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
|
pub inverse_bindposes: Handle<SkinnedMeshInverseBindposes>,
|
||||||
pub joints: Vec<Entity>,
|
pub joints: Vec<Entity>,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use bevy_ecs::{component::Component, prelude::Entity, reflect::ReflectComponent};
|
use bevy_ecs::{component::Component, prelude::Entity, reflect::ReflectComponent};
|
||||||
use bevy_math::{Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles};
|
use bevy_math::{Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles};
|
||||||
use bevy_reflect::{FromReflect, Reflect};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
|
||||||
/// An axis-aligned bounding box.
|
/// An axis-aligned bounding box.
|
||||||
@ -126,8 +126,8 @@ impl HalfSpace {
|
|||||||
/// A frustum made up of the 6 defining half spaces.
|
/// A frustum made up of the 6 defining half spaces.
|
||||||
/// Half spaces are ordered left, right, top, bottom, near, far.
|
/// Half spaces are ordered left, right, top, bottom, near, far.
|
||||||
/// The normal vectors of the half spaces point towards the interior of the frustum.
|
/// The normal vectors of the half spaces point towards the interior of the frustum.
|
||||||
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
|
#[derive(Component, Clone, Copy, Debug, Default, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct Frustum {
|
pub struct Frustum {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub half_spaces: [HalfSpace; 6],
|
pub half_spaces: [HalfSpace; 6],
|
||||||
@ -223,8 +223,8 @@ impl Frustum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Debug, Default, Reflect)]
|
#[derive(Component, Debug, Default, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct CubemapFrusta {
|
pub struct CubemapFrusta {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub frusta: [Frustum; 6],
|
pub frusta: [Frustum; 6],
|
||||||
@ -239,8 +239,8 @@ impl CubemapFrusta {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Debug, Default, Reflect)]
|
#[derive(Component, Debug, Default, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct CascadesFrusta {
|
pub struct CascadesFrusta {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub frusta: HashMap<Entity, Vec<Frustum>>,
|
pub frusta: HashMap<Entity, Vec<Frustum>>,
|
||||||
|
|||||||
@ -171,8 +171,8 @@ pub struct NoFrustumCulling;
|
|||||||
///
|
///
|
||||||
/// Currently this component is ignored by the sprite renderer, so sprite rendering
|
/// Currently this component is ignored by the sprite renderer, so sprite rendering
|
||||||
/// is not optimized per view.
|
/// is not optimized per view.
|
||||||
#[derive(Clone, Component, Default, Debug, Reflect)]
|
#[derive(Clone, Component, Default, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct VisibleEntities {
|
pub struct VisibleEntities {
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub entities: Vec<Entity>,
|
pub entities: Vec<Entity>,
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use bevy_ecs::{
|
|||||||
system::{lifetimeless::*, SystemParamItem, SystemState},
|
system::{lifetimeless::*, SystemParamItem, SystemState},
|
||||||
};
|
};
|
||||||
use bevy_math::{Mat4, Vec2};
|
use bevy_math::{Mat4, Vec2};
|
||||||
use bevy_reflect::{Reflect, TypeUuid};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect, TypeUuid};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin},
|
extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin},
|
||||||
globals::{GlobalsBuffer, GlobalsUniform},
|
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).
|
/// 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
|
/// It wraps a [`Handle<Mesh>`] to differentiate from the 3d pipelines which use the handles directly as components
|
||||||
#[derive(Default, Clone, Component, Debug, Reflect)]
|
#[derive(Default, Clone, Component, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct Mesh2dHandle(pub Handle<Mesh>);
|
pub struct Mesh2dHandle(pub Handle<Mesh>);
|
||||||
|
|
||||||
impl From<Handle<Mesh>> for Mesh2dHandle {
|
impl From<Handle<Mesh>> for Mesh2dHandle {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use bevy_ecs::{
|
|||||||
system::{Local, Query, Res, ResMut},
|
system::{Local, Query, Res, ResMut},
|
||||||
};
|
};
|
||||||
use bevy_math::{Vec2, Vec3};
|
use bevy_math::{Vec2, Vec3};
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
prelude::Color,
|
prelude::Color,
|
||||||
texture::Image,
|
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
|
/// 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
|
/// reliable limit if it is necessary to contain the text strictly in the bounds. Currently this
|
||||||
/// component is mainly useful for text wrapping only.
|
/// component is mainly useful for text wrapping only.
|
||||||
#[derive(Component, Copy, Clone, Debug, Reflect)]
|
#[derive(Component, Copy, Clone, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct Text2dBounds {
|
pub struct Text2dBounds {
|
||||||
pub size: Vec2,
|
pub size: Vec2,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use std::ops::Mul;
|
|||||||
use super::Transform;
|
use super::Transform;
|
||||||
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
||||||
use bevy_math::{Affine3A, Mat4, Quat, Vec3, Vec3A};
|
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.
|
/// 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
|
/// [`transform`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs
|
||||||
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect, FromReflect)]
|
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[reflect(Component, Default, PartialEq)]
|
#[reflect(Component, Default, PartialEq, FromReflect)]
|
||||||
pub struct GlobalTransform(Affine3A);
|
pub struct GlobalTransform(Affine3A);
|
||||||
|
|
||||||
macro_rules! impl_local_axis {
|
macro_rules! impl_local_axis {
|
||||||
|
|||||||
@ -37,7 +37,7 @@ use std::ops::Mul;
|
|||||||
/// [`Transform`]: super::Transform
|
/// [`Transform`]: super::Transform
|
||||||
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect, FromReflect)]
|
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect, FromReflect)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[reflect(Component, Default, PartialEq)]
|
#[reflect(Component, Default, PartialEq, FromReflect)]
|
||||||
pub struct Transform {
|
pub struct Transform {
|
||||||
/// Position of the entity. In 2d, the last value of the `Vec3` is used for z-ordering.
|
/// Position of the entity. In 2d, the last value of the `Vec3` is used for z-ordering.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use bevy_ecs::prelude::Component;
|
use bevy_ecs::prelude::Component;
|
||||||
use bevy_ecs::reflect::ReflectComponent;
|
use bevy_ecs::reflect::ReflectComponent;
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
use bevy_reflect::Reflect;
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
pub use taffy::style::AvailableSpace;
|
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
|
/// A node with a `ContentSize` component is a node where its size
|
||||||
/// is based on its content.
|
/// is based on its content.
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Reflect, FromReflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct ContentSize {
|
pub struct ContentSize {
|
||||||
/// The `Measure` used to compute the intrinsic size
|
/// The `Measure` used to compute the intrinsic size
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
|
|||||||
@ -15,8 +15,8 @@ use std::ops::{Div, DivAssign, Mul, MulAssign};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// Describes the size of a UI node
|
/// Describes the size of a UI node
|
||||||
#[derive(Component, Debug, Copy, Clone, Reflect)]
|
#[derive(Component, Debug, Copy, Clone, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct Node {
|
pub struct Node {
|
||||||
/// The size of the node as width and height in logical pixels
|
/// The size of the node as width and height in logical pixels
|
||||||
/// automatically calculated by [`super::layout::ui_layout_system`]
|
/// automatically calculated by [`super::layout::ui_layout_system`]
|
||||||
@ -1585,8 +1585,8 @@ impl Default for BorderColor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The 2D texture displayed for this UI node
|
/// The 2D texture displayed for this UI node
|
||||||
#[derive(Component, Clone, Debug, Reflect)]
|
#[derive(Component, Clone, Debug, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct UiImage {
|
pub struct UiImage {
|
||||||
/// Handle to the texture
|
/// Handle to the texture
|
||||||
pub texture: Handle<Image>,
|
pub texture: Handle<Image>,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use bevy_ecs::{
|
|||||||
world::{Mut, Ref},
|
world::{Mut, Ref},
|
||||||
};
|
};
|
||||||
use bevy_math::Vec2;
|
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_render::texture::Image;
|
||||||
use bevy_sprite::TextureAtlas;
|
use bevy_sprite::TextureAtlas;
|
||||||
use bevy_text::{
|
use bevy_text::{
|
||||||
@ -21,8 +21,8 @@ use taffy::style::AvailableSpace;
|
|||||||
/// Text system flags
|
/// Text system flags
|
||||||
///
|
///
|
||||||
/// Used internally by [`measure_text_system`] and [`text_system`] to schedule text for processing.
|
/// Used internally by [`measure_text_system`] and [`text_system`] to schedule text for processing.
|
||||||
#[derive(Component, Debug, Clone, Reflect)]
|
#[derive(Component, Debug, Clone, Reflect, FromReflect)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct TextFlags {
|
pub struct TextFlags {
|
||||||
/// If set a new measure function for the text node will be created
|
/// If set a new measure function for the text node will be created
|
||||||
needs_new_measure_func: bool,
|
needs_new_measure_func: bool,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use bevy_reflect::{prelude::ReflectDefault, FromReflect, Reflect};
|
use bevy_reflect::{prelude::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
||||||
@ -14,7 +14,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq, Default)]
|
#[reflect(Debug, PartialEq, Default, FromReflect)]
|
||||||
pub enum CursorIcon {
|
pub enum CursorIcon {
|
||||||
/// The platform-dependent default cursor.
|
/// The platform-dependent default cursor.
|
||||||
#[default]
|
#[default]
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
|||||||
use bevy_ecs::entity::Entity;
|
use bevy_ecs::entity::Entity;
|
||||||
use bevy_ecs::event::Event;
|
use bevy_ecs::event::Event;
|
||||||
use bevy_math::{IVec2, Vec2};
|
use bevy_math::{IVec2, Vec2};
|
||||||
use bevy_reflect::{FromReflect, Reflect};
|
use bevy_reflect::{FromReflect, Reflect, ReflectFromReflect};
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
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.
|
/// A window event that is sent whenever a window's logical size has changed.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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,
|
/// 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.
|
/// even if their control flow is set to `Wait` and there have been no window events.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// To create a new window, spawn an entity with a [`crate::Window`] on it.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -64,7 +64,7 @@ pub struct WindowCreated {
|
|||||||
/// [`WindowPlugin`]: crate::WindowPlugin
|
/// [`WindowPlugin`]: crate::WindowPlugin
|
||||||
/// [`Window`]: crate::Window
|
/// [`Window`]: crate::Window
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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
|
/// 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.
|
/// the window entity loses its [`Window`](crate::window::Window) component or is despawned.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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
|
/// [`WindowEvent::CursorMoved`]: https://docs.rs/winit/latest/winit/event/enum.WindowEvent.html#variant.CursorMoved
|
||||||
/// [`MouseMotion`]: bevy_input::mouse::MouseMotion
|
/// [`MouseMotion`]: bevy_input::mouse::MouseMotion
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// An event that is sent whenever the user's cursor enters a window.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// An event that is sent whenever the user's cursor leaves a window.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// 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)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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).
|
/// 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)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -203,7 +203,7 @@ pub enum Ime {
|
|||||||
|
|
||||||
/// An event that indicates a window has received or lost focus.
|
/// An event that indicates a window has received or lost focus.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -218,7 +218,7 @@ pub struct WindowFocused {
|
|||||||
|
|
||||||
/// An event that indicates a window's scale factor has changed.
|
/// An event that indicates a window's scale factor has changed.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// An event that indicates a window's OS-reported scale factor has changed.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
@ -248,7 +248,7 @@ pub struct WindowBackendScaleFactorChanged {
|
|||||||
|
|
||||||
/// Events related to files being dragged and dropped on a window.
|
/// Events related to files being dragged and dropped on a window.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// An event that is sent when a window is repositioned in physical pixels.
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
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.
|
/// 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.
|
/// 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)]
|
#[derive(Event, Debug, Clone, PartialEq, Eq, Reflect, FromReflect)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serialize",
|
feature = "serialize",
|
||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use bevy_ecs::{
|
|||||||
prelude::{Component, ReflectComponent},
|
prelude::{Component, ReflectComponent},
|
||||||
};
|
};
|
||||||
use bevy_math::{DVec2, IVec2, Vec2};
|
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")]
|
#[cfg(feature = "serialize")]
|
||||||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
||||||
@ -15,8 +15,10 @@ use crate::CursorIcon;
|
|||||||
/// Marker component for the window considered the primary window.
|
/// Marker component for the window considered the primary window.
|
||||||
///
|
///
|
||||||
/// Currently this is assumed to only exist on 1 entity at a time.
|
/// Currently this is assumed to only exist on 1 entity at a time.
|
||||||
#[derive(Default, Debug, Component, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Reflect)]
|
#[derive(
|
||||||
#[reflect(Component)]
|
Default, Debug, Component, PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Reflect, FromReflect,
|
||||||
|
)]
|
||||||
|
#[reflect(Component, FromReflect)]
|
||||||
pub struct PrimaryWindow;
|
pub struct PrimaryWindow;
|
||||||
|
|
||||||
/// Reference to a window, whether it be a direct link to a specific entity or
|
/// 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),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default, FromReflect)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
/// The cursor of this window.
|
/// The cursor of this window.
|
||||||
pub cursor: Cursor,
|
pub cursor: Cursor,
|
||||||
@ -307,7 +309,7 @@ impl Window {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq, Default)]
|
#[reflect(Debug, PartialEq, Default, FromReflect)]
|
||||||
pub struct WindowResizeConstraints {
|
pub struct WindowResizeConstraints {
|
||||||
/// The minimum width the window can have.
|
/// The minimum width the window can have.
|
||||||
pub min_width: f32,
|
pub min_width: f32,
|
||||||
@ -374,7 +376,7 @@ impl WindowResizeConstraints {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, Default)]
|
#[reflect(Debug, Default, FromReflect)]
|
||||||
pub struct Cursor {
|
pub struct Cursor {
|
||||||
/// Get the current [`CursorIcon`] while inside the window.
|
/// Get the current [`CursorIcon`] while inside the window.
|
||||||
pub icon: CursorIcon,
|
pub icon: CursorIcon,
|
||||||
@ -426,7 +428,7 @@ impl Default for Cursor {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
pub enum WindowPosition {
|
pub enum WindowPosition {
|
||||||
/// Position will be set by the window manager
|
/// Position will be set by the window manager
|
||||||
#[default]
|
#[default]
|
||||||
@ -477,7 +479,7 @@ impl WindowPosition {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq, Default)]
|
#[reflect(Debug, PartialEq, Default, FromReflect)]
|
||||||
pub struct WindowResolution {
|
pub struct WindowResolution {
|
||||||
physical_width: u32,
|
physical_width: u32,
|
||||||
physical_height: u32,
|
physical_height: u32,
|
||||||
@ -641,7 +643,7 @@ impl From<bevy_math::DVec2> for WindowResolution {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq, Default)]
|
#[reflect(Debug, PartialEq, Default, FromReflect)]
|
||||||
pub enum CursorGrabMode {
|
pub enum CursorGrabMode {
|
||||||
/// The cursor can freely leave the window.
|
/// The cursor can freely leave the window.
|
||||||
#[default]
|
#[default]
|
||||||
@ -659,7 +661,7 @@ pub enum CursorGrabMode {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq, Default)]
|
#[reflect(Debug, PartialEq, Default, FromReflect)]
|
||||||
pub struct InternalWindowState {
|
pub struct InternalWindowState {
|
||||||
/// If this is true then next frame we will ask to minimize the window.
|
/// If this is true then next frame we will ask to minimize the window.
|
||||||
minimize_request: Option<bool>,
|
minimize_request: Option<bool>,
|
||||||
@ -688,7 +690,7 @@ impl InternalWindowState {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
pub enum MonitorSelection {
|
pub enum MonitorSelection {
|
||||||
/// Uses current monitor of the window.
|
/// Uses current monitor of the window.
|
||||||
///
|
///
|
||||||
@ -726,7 +728,7 @@ pub enum MonitorSelection {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq, Hash)]
|
#[reflect(Debug, PartialEq, Hash, FromReflect)]
|
||||||
#[doc(alias = "vsync")]
|
#[doc(alias = "vsync")]
|
||||||
pub enum PresentMode {
|
pub enum PresentMode {
|
||||||
/// Chooses FifoRelaxed -> Fifo based on availability.
|
/// Chooses FifoRelaxed -> Fifo based on availability.
|
||||||
@ -766,7 +768,7 @@ pub enum PresentMode {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq, Hash)]
|
#[reflect(Debug, PartialEq, Hash, FromReflect)]
|
||||||
pub enum CompositeAlphaMode {
|
pub enum CompositeAlphaMode {
|
||||||
/// Chooses either [`Opaque`](CompositeAlphaMode::Opaque) or [`Inherit`](CompositeAlphaMode::Inherit)
|
/// Chooses either [`Opaque`](CompositeAlphaMode::Opaque) or [`Inherit`](CompositeAlphaMode::Inherit)
|
||||||
/// automatically, depending on the `alpha_mode` that the current surface can support.
|
/// automatically, depending on the `alpha_mode` that the current surface can support.
|
||||||
@ -801,7 +803,7 @@ pub enum CompositeAlphaMode {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
pub enum WindowMode {
|
pub enum WindowMode {
|
||||||
/// Creates a window that uses the given size.
|
/// Creates a window that uses the given size.
|
||||||
#[default]
|
#[default]
|
||||||
@ -829,7 +831,7 @@ pub enum WindowMode {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
pub enum WindowLevel {
|
pub enum WindowLevel {
|
||||||
/// The window will always be below normal windows.
|
/// The window will always be below normal windows.
|
||||||
///
|
///
|
||||||
@ -849,7 +851,7 @@ pub enum WindowLevel {
|
|||||||
derive(serde::Serialize, serde::Deserialize),
|
derive(serde::Serialize, serde::Deserialize),
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
#[reflect(Debug, PartialEq)]
|
#[reflect(Debug, PartialEq, FromReflect)]
|
||||||
pub enum WindowTheme {
|
pub enum WindowTheme {
|
||||||
/// Use the light variant.
|
/// Use the light variant.
|
||||||
Light,
|
Light,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user