From c02613b77b8012847c50abc0ddc4438c0e8334bf Mon Sep 17 00:00:00 2001 From: Nate Casey Date: Tue, 13 Dec 2022 23:26:26 -0500 Subject: [PATCH 01/14] Changed Msaa to take level rather than int --- crates/bevy_core_pipeline/src/core_3d/mod.rs | 2 +- crates/bevy_pbr/src/material.rs | 4 +-- crates/bevy_pbr/src/wireframe.rs | 2 +- crates/bevy_render/src/lib.rs | 2 +- crates/bevy_render/src/view/mod.rs | 31 ++++++++++++++++---- crates/bevy_sprite/src/mesh2d/material.rs | 2 +- crates/bevy_sprite/src/render/mod.rs | 2 +- examples/2d/mesh2d_manual.rs | 2 +- examples/3d/fxaa.rs | 16 +++++----- examples/3d/msaa.rs | 10 +++---- examples/3d/transparency_3d.rs | 4 +-- examples/shader/shader_instancing.rs | 2 +- 12 files changed, 51 insertions(+), 28 deletions(-) diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index 8dc51d760ac1c..579ebf3482176 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -283,7 +283,7 @@ pub fn prepare_core_3d_depth_textures( height: physical_target_size.y, }, mip_level_count: 1, - sample_count: msaa.samples, + sample_count: msaa.level as u32, dimension: TextureDimension::D2, format: TextureFormat::Depth32Float, /* PERF: vulkan docs recommend using 24 * bit depth for better performance */ diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index c1d0fc8297325..7d9a77b5ac9b3 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -347,8 +347,8 @@ pub fn queue_material_meshes( let draw_alpha_mask_pbr = alpha_mask_draw_functions.read().id::>(); let draw_transparent_pbr = transparent_draw_functions.read().id::>(); - let mut view_key = - MeshPipelineKey::from_msaa_samples(msaa.samples) | MeshPipelineKey::from_hdr(view.hdr); + let mut view_key = MeshPipelineKey::from_msaa_samples(msaa.level as u32) + | MeshPipelineKey::from_hdr(view.hdr); if let Some(Tonemapping::Enabled { deband_dither }) = tonemapping { if !view.hdr { diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index 2b31a051317d2..09bc4dcb417b3 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -117,7 +117,7 @@ fn queue_wireframes( mut views: Query<(&ExtractedView, &VisibleEntities, &mut RenderPhase)>, ) { let draw_custom = opaque_3d_draw_functions.read().id::(); - let msaa_key = MeshPipelineKey::from_msaa_samples(msaa.samples); + let msaa_key = MeshPipelineKey::from_msaa_samples(msaa.level as u32); for (view, visible_entities, mut opaque_phase) in &mut views { let rangefinder = view.rangefinder3d(); diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index f595023588e76..2d816f2601921 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -31,7 +31,7 @@ pub mod prelude { render_resource::Shader, spatial_bundle::SpatialBundle, texture::{Image, ImagePlugin}, - view::{ComputedVisibility, Msaa, Visibility, VisibilityBundle}, + view::{ComputedVisibility, Msaa, MultiSampleLevel, Visibility, VisibilityBundle}, }; } diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index bc0c12b023135..23933a675a16f 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -61,11 +61,12 @@ impl Plugin for ViewPlugin { /// # use bevy_app::prelude::App; /// # use bevy_render::prelude::Msaa; /// App::new() -/// .insert_resource(Msaa { samples: 4 }) +/// .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) /// .run(); /// ``` #[derive(Resource, Clone, ExtractResource, Reflect)] #[reflect(Resource)] +#[non_exhaustive] pub struct Msaa { /// The number of samples to run for Multi-Sample Anti-Aliasing. Higher numbers result in /// smoother edges. @@ -74,15 +75,35 @@ pub struct Msaa { /// Note that WGPU currently only supports 1 or 4 samples. /// Ultimately we plan on supporting whatever is natively supported on a given device. /// Check out this issue for more info: - pub samples: u32, + pub level: MultiSampleLevel, +} + +impl Msaa { + pub fn samples(&self) -> u32 { + self.level as u32 + } } impl Default for Msaa { fn default() -> Self { - Self { samples: 4 } + Self { + level: MultiSampleLevel::Sample4, + } } } +impl From for Msaa { + fn from(level: MultiSampleLevel) -> Self { + Self { level } + } +} + +#[derive(Clone, Copy, Reflect, PartialEq)] +pub enum MultiSampleLevel { + Off = 1, + Sample4 = 4, +} + #[derive(Component)] pub struct ExtractedView { pub projection: Mat4, @@ -334,7 +355,7 @@ fn prepare_view_targets( }, ) .default_view, - sampled: (msaa.samples > 1).then(|| { + sampled: (msaa.level as u32 > 1).then(|| { texture_cache .get( &render_device, @@ -342,7 +363,7 @@ fn prepare_view_targets( label: Some("main_texture_sampled"), size, mip_level_count: 1, - sample_count: msaa.samples, + sample_count: msaa.level as u32, dimension: TextureDimension::D2, format: main_texture_format, usage: TextureUsages::RENDER_ATTACHMENT, diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index 0f3b86bf9e1d5..3e0889a399480 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -322,7 +322,7 @@ pub fn queue_material2d_meshes( for (view, visible_entities, tonemapping, mut transparent_phase) in &mut views { let draw_transparent_pbr = transparent_draw_functions.read().id::>(); - let mut view_key = Mesh2dPipelineKey::from_msaa_samples(msaa.samples) + let mut view_key = Mesh2dPipelineKey::from_msaa_samples(msaa.level as u32) | Mesh2dPipelineKey::from_hdr(view.hdr); if let Some(Tonemapping::Enabled { deband_dither }) = tonemapping { diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 1cdc6d93782d8..d7b41dc5cd8f4 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -470,7 +470,7 @@ pub fn queue_sprites( }; } - let msaa_key = SpritePipelineKey::from_msaa_samples(msaa.samples); + let msaa_key = SpritePipelineKey::from_msaa_samples(msaa.level as u32); if let Some(view_binding) = view_uniforms.uniforms.binding() { let sprite_meta = &mut sprite_meta; diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 977095e87f9f0..1fa5df953abb2 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -329,7 +329,7 @@ pub fn queue_colored_mesh2d( for (visible_entities, mut transparent_phase, view) in &mut views { let draw_colored_mesh2d = transparent_draw_functions.read().id::(); - let mesh_key = Mesh2dPipelineKey::from_msaa_samples(msaa.samples) + let mesh_key = Mesh2dPipelineKey::from_msaa_samples(msaa.level as u32) | Mesh2dPipelineKey::from_hdr(view.hdr); // Queue all entities visible to that view diff --git a/examples/3d/fxaa.rs b/examples/3d/fxaa.rs index 9a51145badb35..0101a677735ef 100644 --- a/examples/3d/fxaa.rs +++ b/examples/3d/fxaa.rs @@ -1,6 +1,6 @@ //! This examples compares MSAA (Multi-Sample Anti-Aliasing) and FXAA (Fast Approximate Anti-Aliasing). -use std::f32::consts::PI; +use std::{f32::consts::PI, ops::Mul}; use bevy::{ core_pipeline::fxaa::{Fxaa, Sensitivity}, @@ -8,13 +8,14 @@ use bevy::{ render::{ render_resource::{Extent3d, SamplerDescriptor, TextureDimension, TextureFormat}, texture::ImageSampler, + view::MultiSampleLevel, }, }; fn main() { App::new() - // Disable MSAA be default - .insert_resource(Msaa { samples: 1 }) + // Disable MSAA by default + .insert_resource(Msaa::from(MultiSampleLevel::Off)) .add_plugins(DefaultPlugins) .add_startup_system(setup) .add_system(toggle_fxaa) @@ -118,19 +119,20 @@ fn toggle_fxaa(keys: Res>, mut query: Query<&mut Fxaa>, mut msaa: let fxaa_ultra = keys.just_pressed(KeyCode::Key9); let fxaa_extreme = keys.just_pressed(KeyCode::Key0); let set_fxaa = set_fxaa | fxaa_low | fxaa_med | fxaa_high | fxaa_ultra | fxaa_extreme; + for mut fxaa in &mut query { if set_msaa { fxaa.enabled = false; - msaa.samples = 4; + msaa.level = MultiSampleLevel::Sample4; info!("MSAA 4x"); } if set_no_aa { fxaa.enabled = false; - msaa.samples = 1; + msaa.level = MultiSampleLevel::Off; info!("NO AA"); } if set_no_aa | set_fxaa { - msaa.samples = 1; + msaa.level = MultiSampleLevel::Off; } if fxaa_low { fxaa.edge_threshold = Sensitivity::Low; @@ -150,7 +152,7 @@ fn toggle_fxaa(keys: Res>, mut query: Query<&mut Fxaa>, mut msaa: } if set_fxaa { fxaa.enabled = true; - msaa.samples = 1; + msaa.level = MultiSampleLevel::Off; info!("FXAA {}", fxaa.edge_threshold.get_str()); } } diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index b59c1ba566c6f..21e27708315aa 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -6,11 +6,11 @@ //! Ultimately we plan on supporting whatever is natively supported on a given device. //! Check out [this issue](https://github.com/gfx-rs/wgpu/issues/1832) for more info. -use bevy::prelude::*; +use bevy::{prelude::*, render::view::MultiSampleLevel}; fn main() { App::new() - .insert_resource(Msaa { samples: 4 }) + .insert_resource(Msaa::from(MultiSampleLevel::Off)) .add_plugins(DefaultPlugins) .add_startup_system(setup) .add_system(cycle_msaa) @@ -46,12 +46,12 @@ fn setup( fn cycle_msaa(input: Res>, mut msaa: ResMut) { if input.just_pressed(KeyCode::M) { - if msaa.samples == 4 { + if msaa.level == MultiSampleLevel::Sample4 { info!("Not using MSAA"); - msaa.samples = 1; + msaa.level = MultiSampleLevel::Off; } else { info!("Using 4x MSAA"); - msaa.samples = 4; + msaa.level = MultiSampleLevel::Sample4; } } } diff --git a/examples/3d/transparency_3d.rs b/examples/3d/transparency_3d.rs index 437c291589f2d..3f1348620dbff 100644 --- a/examples/3d/transparency_3d.rs +++ b/examples/3d/transparency_3d.rs @@ -2,11 +2,11 @@ //! Shows the effects of different blend modes. //! The `fade_transparency` system smoothly changes the transparency over time. -use bevy::prelude::*; +use bevy::{prelude::*, render::view::MultiSampleLevel}; fn main() { App::new() - .insert_resource(Msaa { samples: 4 }) + .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) .add_plugins(DefaultPlugins) .add_startup_system(setup) .add_system(fade_transparency) diff --git a/examples/shader/shader_instancing.rs b/examples/shader/shader_instancing.rs index 5d8c8b816f473..fa832f7f98f77 100644 --- a/examples/shader/shader_instancing.rs +++ b/examples/shader/shader_instancing.rs @@ -111,7 +111,7 @@ fn queue_custom( ) { let draw_custom = transparent_3d_draw_functions.read().id::(); - let msaa_key = MeshPipelineKey::from_msaa_samples(msaa.samples); + let msaa_key = MeshPipelineKey::from_msaa_samples(msaa.samples()); for (view, mut transparent_phase) in &mut views { let view_key = msaa_key | MeshPipelineKey::from_hdr(view.hdr); From 5f1f5be560307f3110f7bc503d1cd1d212fb52d0 Mon Sep 17 00:00:00 2001 From: Nate Casey Date: Thu, 15 Dec 2022 22:49:47 -0500 Subject: [PATCH 02/14] Moved non-exhaustive attribute to MultiSampleLevel --- crates/bevy_render/src/view/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 23933a675a16f..c5faf7cfb9d0e 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -66,7 +66,6 @@ impl Plugin for ViewPlugin { /// ``` #[derive(Resource, Clone, ExtractResource, Reflect)] #[reflect(Resource)] -#[non_exhaustive] pub struct Msaa { /// The number of samples to run for Multi-Sample Anti-Aliasing. Higher numbers result in /// smoother edges. @@ -99,6 +98,7 @@ impl From for Msaa { } #[derive(Clone, Copy, Reflect, PartialEq)] +#[non_exhaustive] pub enum MultiSampleLevel { Off = 1, Sample4 = 4, From 37416518bc5d2390b3c199217cde5b7cef484397 Mon Sep 17 00:00:00 2001 From: Nate Casey Date: Thu, 15 Dec 2022 22:59:26 -0500 Subject: [PATCH 03/14] Changed some code to use .samples() --- crates/bevy_core_pipeline/src/core_3d/mod.rs | 2 +- crates/bevy_pbr/src/material.rs | 2 +- crates/bevy_pbr/src/wireframe.rs | 2 +- crates/bevy_render/src/view/mod.rs | 4 ++-- crates/bevy_sprite/src/mesh2d/material.rs | 2 +- crates/bevy_sprite/src/render/mod.rs | 2 +- examples/2d/mesh2d_manual.rs | 2 +- examples/3d/fxaa.rs | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index 579ebf3482176..dcfed87af9afc 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -283,7 +283,7 @@ pub fn prepare_core_3d_depth_textures( height: physical_target_size.y, }, mip_level_count: 1, - sample_count: msaa.level as u32, + sample_count: msaa.samples(), dimension: TextureDimension::D2, format: TextureFormat::Depth32Float, /* PERF: vulkan docs recommend using 24 * bit depth for better performance */ diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 7d9a77b5ac9b3..6f4e958a1b9d2 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -347,7 +347,7 @@ pub fn queue_material_meshes( let draw_alpha_mask_pbr = alpha_mask_draw_functions.read().id::>(); let draw_transparent_pbr = transparent_draw_functions.read().id::>(); - let mut view_key = MeshPipelineKey::from_msaa_samples(msaa.level as u32) + let mut view_key = MeshPipelineKey::from_msaa_samples(msaa.samples()) | MeshPipelineKey::from_hdr(view.hdr); if let Some(Tonemapping::Enabled { deband_dither }) = tonemapping { diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index 09bc4dcb417b3..dcba9232cc235 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -117,7 +117,7 @@ fn queue_wireframes( mut views: Query<(&ExtractedView, &VisibleEntities, &mut RenderPhase)>, ) { let draw_custom = opaque_3d_draw_functions.read().id::(); - let msaa_key = MeshPipelineKey::from_msaa_samples(msaa.level as u32); + let msaa_key = MeshPipelineKey::from_msaa_samples(msaa.samples()); for (view, visible_entities, mut opaque_phase) in &mut views { let rangefinder = view.rangefinder3d(); diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index c5faf7cfb9d0e..d036361aea6fb 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -355,7 +355,7 @@ fn prepare_view_targets( }, ) .default_view, - sampled: (msaa.level as u32 > 1).then(|| { + sampled: (msaa.samples() > 1).then(|| { texture_cache .get( &render_device, @@ -363,7 +363,7 @@ fn prepare_view_targets( label: Some("main_texture_sampled"), size, mip_level_count: 1, - sample_count: msaa.level as u32, + sample_count: msaa.samples(), dimension: TextureDimension::D2, format: main_texture_format, usage: TextureUsages::RENDER_ATTACHMENT, diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index 3e0889a399480..d94cfc7faaa55 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -322,7 +322,7 @@ pub fn queue_material2d_meshes( for (view, visible_entities, tonemapping, mut transparent_phase) in &mut views { let draw_transparent_pbr = transparent_draw_functions.read().id::>(); - let mut view_key = Mesh2dPipelineKey::from_msaa_samples(msaa.level as u32) + let mut view_key = Mesh2dPipelineKey::from_msaa_samples(msaa.samples()) | Mesh2dPipelineKey::from_hdr(view.hdr); if let Some(Tonemapping::Enabled { deband_dither }) = tonemapping { diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index d7b41dc5cd8f4..fd9e31927246a 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -470,7 +470,7 @@ pub fn queue_sprites( }; } - let msaa_key = SpritePipelineKey::from_msaa_samples(msaa.level as u32); + let msaa_key = SpritePipelineKey::from_msaa_samples(msaa.samples()); if let Some(view_binding) = view_uniforms.uniforms.binding() { let sprite_meta = &mut sprite_meta; diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 1fa5df953abb2..2ceb5518ba38a 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -329,7 +329,7 @@ pub fn queue_colored_mesh2d( for (visible_entities, mut transparent_phase, view) in &mut views { let draw_colored_mesh2d = transparent_draw_functions.read().id::(); - let mesh_key = Mesh2dPipelineKey::from_msaa_samples(msaa.level as u32) + let mesh_key = Mesh2dPipelineKey::from_msaa_samples(msaa.samples()) | Mesh2dPipelineKey::from_hdr(view.hdr); // Queue all entities visible to that view diff --git a/examples/3d/fxaa.rs b/examples/3d/fxaa.rs index 0101a677735ef..940413e0d4704 100644 --- a/examples/3d/fxaa.rs +++ b/examples/3d/fxaa.rs @@ -1,6 +1,6 @@ //! This examples compares MSAA (Multi-Sample Anti-Aliasing) and FXAA (Fast Approximate Anti-Aliasing). -use std::{f32::consts::PI, ops::Mul}; +use std::f32::consts::PI; use bevy::{ core_pipeline::fxaa::{Fxaa, Sensitivity}, From 79b0d02e0ab317134066e0875cebe69e380134cf Mon Sep 17 00:00:00 2001 From: Nate Casey Date: Thu, 15 Dec 2022 23:12:06 -0500 Subject: [PATCH 04/14] check doc --- crates/bevy_render/src/view/mod.rs | 1 + examples/3d/msaa.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index d036361aea6fb..6d3ee8fb99a2d 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -60,6 +60,7 @@ impl Plugin for ViewPlugin { /// ``` /// # use bevy_app::prelude::App; /// # use bevy_render::prelude::Msaa; +/// # use bevy_render::prelude::MultiSampleLevel; /// App::new() /// .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) /// .run(); diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index 21e27708315aa..6869cb5f7798e 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -6,7 +6,7 @@ //! Ultimately we plan on supporting whatever is natively supported on a given device. //! Check out [this issue](https://github.com/gfx-rs/wgpu/issues/1832) for more info. -use bevy::{prelude::*, render::view::MultiSampleLevel}; +use bevy::prelude::*; fn main() { App::new() From bd3e95562102ba7607ab3ef7339c9418dae79106 Mon Sep 17 00:00:00 2001 From: Nate Casey Date: Fri, 16 Dec 2022 10:52:53 -0500 Subject: [PATCH 05/14] Msaa::samples() now inline --- crates/bevy_render/src/view/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 6d3ee8fb99a2d..dcacf053a6142 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -79,6 +79,7 @@ pub struct Msaa { } impl Msaa { + #[inline] pub fn samples(&self) -> u32 { self.level as u32 } From e6543928935fd80166567ee3b6a6225b22dfa866 Mon Sep 17 00:00:00 2001 From: Sjael Date: Thu, 19 Jan 2023 21:27:28 -0800 Subject: [PATCH 06/14] squashed --- crates/bevy_render/src/lib.rs | 2 +- crates/bevy_render/src/view/mod.rs | 24 ++++++------------------ examples/3d/fxaa.rs | 11 +++++------ examples/3d/msaa.rs | 17 ++++++++++------- examples/3d/transparency_3d.rs | 4 ++-- 5 files changed, 24 insertions(+), 34 deletions(-) diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 5d8661ff2b230..2cb1868939fd2 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -33,7 +33,7 @@ pub mod prelude { render_resource::Shader, spatial_bundle::SpatialBundle, texture::{Image, ImagePlugin}, - view::{ComputedVisibility, Msaa, MultiSampleLevel, Visibility, VisibilityBundle}, + view::{ComputedVisibility, Msaa, Visibility, VisibilityBundle}, }; } diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 4bc8416ff6843..d1260bbb55d2e 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -65,9 +65,9 @@ impl Plugin for ViewPlugin { /// .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) /// .run(); /// ``` -#[derive(Resource, Clone, ExtractResource, Reflect)] +#[derive(Resource, Clone, Copy, ExtractResource, Reflect, PartialEq, PartialOrd)] #[reflect(Resource)] -pub struct Msaa { +pub enum Msaa { /// The number of samples to run for Multi-Sample Anti-Aliasing. Higher numbers result in /// smoother edges. /// Defaults to 4. @@ -75,36 +75,24 @@ pub struct Msaa { /// Note that WGPU currently only supports 1 or 4 samples. /// Ultimately we plan on supporting whatever is natively supported on a given device. /// Check out this issue for more info: - pub level: MultiSampleLevel, + Off = 1, + Sample4 = 4, } impl Msaa { #[inline] pub fn samples(&self) -> u32 { - self.level as u32 + *self as u32 } } impl Default for Msaa { fn default() -> Self { - Self { - level: MultiSampleLevel::Sample4, - } + Self::Sample4 } } -impl From for Msaa { - fn from(level: MultiSampleLevel) -> Self { - Self { level } - } -} -#[derive(Clone, Copy, Reflect, PartialEq)] -#[non_exhaustive] -pub enum MultiSampleLevel { - Off = 1, - Sample4 = 4, -} #[derive(Component)] pub struct ExtractedView { diff --git a/examples/3d/fxaa.rs b/examples/3d/fxaa.rs index 940413e0d4704..bf2425593f35e 100644 --- a/examples/3d/fxaa.rs +++ b/examples/3d/fxaa.rs @@ -8,14 +8,13 @@ use bevy::{ render::{ render_resource::{Extent3d, SamplerDescriptor, TextureDimension, TextureFormat}, texture::ImageSampler, - view::MultiSampleLevel, }, }; fn main() { App::new() // Disable MSAA by default - .insert_resource(Msaa::from(MultiSampleLevel::Off)) + .insert_resource(Msaa::default()) .add_plugins(DefaultPlugins) .add_startup_system(setup) .add_system(toggle_fxaa) @@ -123,16 +122,16 @@ fn toggle_fxaa(keys: Res>, mut query: Query<&mut Fxaa>, mut msaa: for mut fxaa in &mut query { if set_msaa { fxaa.enabled = false; - msaa.level = MultiSampleLevel::Sample4; + *msaa = Msaa::Sample4; info!("MSAA 4x"); } if set_no_aa { fxaa.enabled = false; - msaa.level = MultiSampleLevel::Off; + *msaa = Msaa::Off; info!("NO AA"); } if set_no_aa | set_fxaa { - msaa.level = MultiSampleLevel::Off; + *msaa = Msaa::Off; } if fxaa_low { fxaa.edge_threshold = Sensitivity::Low; @@ -152,7 +151,7 @@ fn toggle_fxaa(keys: Res>, mut query: Query<&mut Fxaa>, mut msaa: } if set_fxaa { fxaa.enabled = true; - msaa.level = MultiSampleLevel::Off; + *msaa = Msaa::Off; info!("FXAA {}", fxaa.edge_threshold.get_str()); } } diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index 6869cb5f7798e..1e3da8e8ea919 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -10,7 +10,7 @@ use bevy::prelude::*; fn main() { App::new() - .insert_resource(Msaa::from(MultiSampleLevel::Off)) + .insert_resource(Msaa::default()) .add_plugins(DefaultPlugins) .add_startup_system(setup) .add_system(cycle_msaa) @@ -46,12 +46,15 @@ fn setup( fn cycle_msaa(input: Res>, mut msaa: ResMut) { if input.just_pressed(KeyCode::M) { - if msaa.level == MultiSampleLevel::Sample4 { - info!("Not using MSAA"); - msaa.level = MultiSampleLevel::Off; - } else { - info!("Using 4x MSAA"); - msaa.level = MultiSampleLevel::Sample4; + match *msaa { + Msaa::Sample4 => { + info!("Not using MSAA"); + *msaa = Msaa::Off; + } + Msaa::Off => { + info!("Using 4x MSAA"); + *msaa = Msaa::Sample4; + } } } } diff --git a/examples/3d/transparency_3d.rs b/examples/3d/transparency_3d.rs index 3f1348620dbff..4ac093c82dbff 100644 --- a/examples/3d/transparency_3d.rs +++ b/examples/3d/transparency_3d.rs @@ -2,11 +2,11 @@ //! Shows the effects of different blend modes. //! The `fade_transparency` system smoothly changes the transparency over time. -use bevy::{prelude::*, render::view::MultiSampleLevel}; +use bevy::prelude::*; fn main() { App::new() - .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) + .insert_resource(Msaa::default()) .add_plugins(DefaultPlugins) .add_startup_system(setup) .add_system(fade_transparency) From ee20b69abaeb36715b9f0289693453af9c31416c Mon Sep 17 00:00:00 2001 From: Sjael Date: Thu, 19 Jan 2023 21:44:29 -0800 Subject: [PATCH 07/14] merged with core pipeline --- crates/bevy_core_pipeline/src/core_3d/mod.rs | 70 ++++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index 81b7470f71ae9..1da08fc83193c 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -277,34 +277,46 @@ pub fn prepare_core_3d_depth_textures( >, ) { let mut textures = HashMap::default(); - for (entity, camera) in &views_3d { - if let Some(physical_target_size) = camera.physical_target_size { - let cached_texture = textures - .entry(camera.target.clone()) - .or_insert_with(|| { - texture_cache.get( - &render_device, - TextureDescriptor { - label: Some("view_depth_texture"), - size: Extent3d { - depth_or_array_layers: 1, - width: physical_target_size.x, - height: physical_target_size.y, - }, - mip_level_count: 1, - sample_count: msaa.samples(), - dimension: TextureDimension::D2, - format: TextureFormat::Depth32Float, /* PERF: vulkan docs recommend using 24 - * bit depth for better performance */ - usage: TextureUsages::RENDER_ATTACHMENT, - }, - ) - }) - .clone(); - commands.entity(entity).insert(ViewDepthTexture { - texture: cached_texture.texture, - view: cached_texture.default_view, - }); - } + for (entity, camera, depth_prepass) in &views_3d { + let Some(physical_target_size) = camera.physical_target_size else { + continue; + }; + + let cached_texture = textures + .entry(camera.target.clone()) + .or_insert_with(|| { + // Default usage required to write to the depth texture + let mut usage = TextureUsages::RENDER_ATTACHMENT; + if depth_prepass.is_some() { + // Required to read the output of the prepass + usage |= TextureUsages::COPY_SRC; + } + + // The size of the depth texture + let size = Extent3d { + depth_or_array_layers: 1, + width: physical_target_size.x, + height: physical_target_size.y, + }; + + let descriptor = TextureDescriptor { + label: Some("view_depth_texture"), + size, + mip_level_count: 1, + sample_count: msaa.samples(), + dimension: TextureDimension::D2, + // PERF: vulkan docs recommend using 24 bit depth for better performance + format: TextureFormat::Depth32Float, + usage, + }; + + texture_cache.get(&render_device, descriptor) + }) + .clone(); + + commands.entity(entity).insert(ViewDepthTexture { + texture: cached_texture.texture, + view: cached_texture.default_view, + }); } } From 31fac8229e56457b4cf394a1ff7be0fc2a79a2a8 Mon Sep 17 00:00:00 2001 From: Sjael Date: Thu, 19 Jan 2023 21:46:39 -0800 Subject: [PATCH 08/14] docs --- crates/bevy_render/src/view/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index d1260bbb55d2e..510f6215183e9 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -60,9 +60,8 @@ impl Plugin for ViewPlugin { /// ``` /// # use bevy_app::prelude::App; /// # use bevy_render::prelude::Msaa; -/// # use bevy_render::prelude::MultiSampleLevel; /// App::new() -/// .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) +/// .insert_resource(Msaa::default()) /// .run(); /// ``` #[derive(Resource, Clone, Copy, ExtractResource, Reflect, PartialEq, PartialOrd)] From b75493913513a0982b666363fd8f95bde8c16150 Mon Sep 17 00:00:00 2001 From: Sjael Date: Thu, 19 Jan 2023 22:02:41 -0800 Subject: [PATCH 09/14] bevy_pbr merge --- crates/bevy_pbr/src/prepass/mod.rs | 6 +++--- crates/bevy_pbr/src/render/mesh.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 0a368da0ec94c..8c0af74df1c86 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -395,7 +395,7 @@ pub fn prepare_prepass_textures( label: Some("prepass_depth_texture"), size, mip_level_count: 1, - sample_count: msaa.samples, + sample_count: msaa.samples(), dimension: TextureDimension::D2, format: DEPTH_PREPASS_FORMAT, usage: TextureUsages::COPY_DST @@ -417,7 +417,7 @@ pub fn prepare_prepass_textures( label: Some("prepass_normal_texture"), size, mip_level_count: 1, - sample_count: msaa.samples, + sample_count: msaa.samples(), dimension: TextureDimension::D2, format: NORMAL_PREPASS_FORMAT, usage: TextureUsages::RENDER_ATTACHMENT @@ -499,7 +499,7 @@ pub fn queue_prepass_material_meshes( normal_prepass, ) in &mut views { - let mut view_key = MeshPipelineKey::from_msaa_samples(msaa.samples); + let mut view_key = MeshPipelineKey::from_msaa_samples(msaa.samples()); if depth_prepass.is_some() { view_key |= MeshPipelineKey::DEPTH_PREPASS; } diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index dc4d78876d9e5..bb828137ffa9c 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -877,7 +877,7 @@ pub fn queue_mesh_view_bind_groups( globals_buffer.buffer.binding(), ) { for (entity, view_shadow_bindings, view_cluster_bindings, prepass_textures) in &views { - let layout = if msaa.samples > 1 { + let layout = if msaa.samples() > 1 { &mesh_pipeline.view_layout_multisampled } else { &mesh_pipeline.view_layout @@ -937,7 +937,7 @@ pub fn queue_mesh_view_bind_groups( Some(texture) => &texture.default_view, None => { &fallback_depths - .image_for_samplecount(msaa.samples) + .image_for_samplecount(msaa.samples()) .texture_view } }; @@ -950,7 +950,7 @@ pub fn queue_mesh_view_bind_groups( Some(texture) => &texture.default_view, None => { &fallback_images - .image_for_samplecount(msaa.samples) + .image_for_samplecount(msaa.samples()) .texture_view } }; From 15f5988281a7b2ca5cf85691de5cdc664ebf2930 Mon Sep 17 00:00:00 2001 From: Sjael Date: Thu, 19 Jan 2023 22:11:27 -0800 Subject: [PATCH 10/14] cleanup --- crates/bevy_render/src/view/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 510f6215183e9..7203f56ba3036 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -91,8 +91,6 @@ impl Default for Msaa { } } - - #[derive(Component)] pub struct ExtractedView { pub projection: Mat4, From 34bbae55b62e85f2159777f3e59b0a89bca94fac Mon Sep 17 00:00:00 2001 From: Sjael Date: Thu, 19 Jan 2023 23:33:28 -0800 Subject: [PATCH 11/14] Update examples/3d/fxaa.rs Co-authored-by: Nicola Papale --- examples/3d/fxaa.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/3d/fxaa.rs b/examples/3d/fxaa.rs index bf2425593f35e..fd1ca6be2e327 100644 --- a/examples/3d/fxaa.rs +++ b/examples/3d/fxaa.rs @@ -14,7 +14,7 @@ use bevy::{ fn main() { App::new() // Disable MSAA by default - .insert_resource(Msaa::default()) + .insert_resource(Msaa::Off) .add_plugins(DefaultPlugins) .add_startup_system(setup) .add_system(toggle_fxaa) From a7b3f8d30b13b137ade039db1ba8e4954413f3e7 Mon Sep 17 00:00:00 2001 From: Sjael Date: Thu, 19 Jan 2023 23:40:16 -0800 Subject: [PATCH 12/14] derive default, docs --- crates/bevy_render/src/view/mod.rs | 24 +- q | 56240 +++++++++++++++++++++++++++ 2 files changed, 56250 insertions(+), 14 deletions(-) create mode 100644 q diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 7203f56ba3036..8e89ddb1cc5ad 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -56,6 +56,14 @@ impl Plugin for ViewPlugin { /// Configuration resource for [Multi-Sample Anti-Aliasing](https://en.wikipedia.org/wiki/Multisample_anti-aliasing). /// +/// The number of samples to run for Multi-Sample Anti-Aliasing. Higher numbers result in +/// smoother edges. +/// Defaults to 4. +/// +/// Note that WGPU currently only supports 1 or 4 samples. +/// Ultimately we plan on supporting whatever is natively supported on a given device. +/// Check out this issue for more info: +/// /// # Example /// ``` /// # use bevy_app::prelude::App; @@ -64,17 +72,11 @@ impl Plugin for ViewPlugin { /// .insert_resource(Msaa::default()) /// .run(); /// ``` -#[derive(Resource, Clone, Copy, ExtractResource, Reflect, PartialEq, PartialOrd)] +#[derive(Resource, Default, Clone, Copy, ExtractResource, Reflect, PartialEq, PartialOrd)] #[reflect(Resource)] pub enum Msaa { - /// The number of samples to run for Multi-Sample Anti-Aliasing. Higher numbers result in - /// smoother edges. - /// Defaults to 4. - /// - /// Note that WGPU currently only supports 1 or 4 samples. - /// Ultimately we plan on supporting whatever is natively supported on a given device. - /// Check out this issue for more info: Off = 1, + #[default] Sample4 = 4, } @@ -85,12 +87,6 @@ impl Msaa { } } -impl Default for Msaa { - fn default() -> Self { - Self::Sample4 - } -} - #[derive(Component)] pub struct ExtractedView { pub projection: Mat4, diff --git a/q b/q new file mode 100644 index 0000000000000..c5ddedaff259d --- /dev/null +++ b/q @@ -0,0 +1,56240 @@ +commit 15f5988281a7b2ca5cf85691de5cdc664ebf2930 (HEAD -> main, sjael/main) +Author: Sjael +Date: Thu Jan 19 22:11:27 2023 -0800 + + cleanup + +commit b75493913513a0982b666363fd8f95bde8c16150 +Author: Sjael +Date: Thu Jan 19 22:02:41 2023 -0800 + + bevy_pbr merge + +commit 31fac8229e56457b4cf394a1ff7be0fc2a79a2a8 +Author: Sjael +Date: Thu Jan 19 21:46:39 2023 -0800 + + docs + +commit ee20b69abaeb36715b9f0289693453af9c31416c +Author: Sjael +Date: Thu Jan 19 21:44:29 2023 -0800 + + merged with core pipeline + +commit 47da4e80746aca0565fa522fc215d7a98cbbf8c0 +Merge: e6543928 cab065ba +Author: Sjael +Date: Thu Jan 19 21:37:12 2023 -0800 + + squashed + +commit e6543928935fd80166567ee3b6a6225b22dfa866 +Author: Sjael +Date: Thu Jan 19 21:27:28 2023 -0800 + + squashed + +commit 9067d598bd8786e8e02968e656aedd1ed168fac6 +Merge: 519f6f45 bd3e9556 +Author: Sjael +Date: Thu Jan 19 18:37:09 2023 -0800 + + Merge branch 'main' of https://github.com/RedMachete/bevy + +commit cab065bad4302e4df427ffbafcdb112e755321ce (origin/staging, origin/main, origin/HEAD) +Author: ickshonpe +Date: Fri Jan 20 01:05:30 2023 +0000 + + remove the image loaded check for nodes without images in extract_uinodes (#7280) + + ## Problem + + `extract_uinodes` checks if an image is loaded for nodes without images + + ## Solution + + Move the image loading skip check so that it is only performed for nodes with a `UiImage` component. + +commit 2027af4c54082007fed2091f112a11cb0bc5fc08 +Author: Mike +Date: Thu Jan 19 23:45:46 2023 +0000 + + Pipelined Rendering (#6503) + + # Objective + + - Implement pipelined rendering + - Fixes #5082 + - Fixes #4718 + + ## User Facing Description + + Bevy now implements piplelined rendering! Pipelined rendering allows the app logic and rendering logic to run on different threads leading to large gains in performance. + + ![image](https://user-images.githubusercontent.com/2180432/202049871-3c00b801-58ab-448f-93fd-471e30aba55f.png) + *tracy capture of many_foxes example* + + To use pipelined rendering, you just need to add the `PipelinedRenderingPlugin`. If you're using `DefaultPlugins` then it will automatically be added for you on all platforms except wasm. Bevy does not currently support multithreading on wasm which is needed for this feature to work. If you aren't using `DefaultPlugins` you can add the plugin manually. + + ```rust + use bevy::prelude::*; + use bevy::render::pipelined_rendering::PipelinedRenderingPlugin; + + fn main() { + App::new() + // whatever other plugins you need + .add_plugin(RenderPlugin) + // needs to be added after RenderPlugin + .add_plugin(PipelinedRenderingPlugin) + .run(); + } + ``` + + If for some reason pipelined rendering needs to be removed. You can also disable the plugin the normal way. + + ```rust + use bevy::prelude::*; + use bevy::render::pipelined_rendering::PipelinedRenderingPlugin; + + fn main() { + App::new.add_plugins(DefaultPlugins.build().disable::()); + } + ``` + + ### A setup function was added to plugins + + A optional plugin lifecycle function was added to the `Plugin trait`. This function is called after all plugins have been built, but before the app runner is called. This allows for some final setup to be done. In the case of pipelined rendering, the function removes the sub app from the main app and sends it to the render thread. + + ```rust + struct MyPlugin; + impl Plugin for MyPlugin { + fn build(&self, app: &mut App) { + + } + + // optional function + fn setup(&self, app: &mut App) { + // do some final setup before runner is called + } + } + ``` + + ### A Stage for Frame Pacing + + In the `RenderExtractApp` there is a stage labelled `BeforeIoAfterRenderStart` that systems can be added to. The specific use case for this stage is for a frame pacing system that can delay the start of main app processing in render bound apps to reduce input latency i.e. "frame pacing". This is not currently built into bevy, but exists as `bevy` + + ```text + |-------------------------------------------------------------------| + | | BeforeIoAfterRenderStart | winit events | main schedule | + | extract |---------------------------------------------------------| + | | extract commands | rendering schedule | + |-------------------------------------------------------------------| + ``` + + ### Small API additions + + * `Schedule::remove_stage` + * `App::insert_sub_app` + * `App::remove_sub_app` + * `TaskPool::scope_with_executor` + + ## Problems and Solutions + + ### Moving render app to another thread + + Most of the hard bits for this were done with the render redo. This PR just sends the render app back and forth through channels which seems to work ok. I originally experimented with using a scope to run the render task. It was cuter, but that approach didn't allow render to start before i/o processing. So I switched to using channels. There is much complexity in the coordination that needs to be done, but it's worth it. By moving rendering during i/o processing the frame times should be much more consistent in render bound apps. See https://github.com/bevyengine/bevy/issues/4691. + + ### Unsoundness with Sending World with NonSend resources + + Dropping !Send things on threads other than the thread they were spawned on is considered unsound. The render world doesn't have any nonsend resources. So if we tell the users to "pretty please don't spawn nonsend resource on the render world", we can avoid this problem. + + More seriously there is this https://github.com/bevyengine/bevy/pull/6534 pr, which patches the unsoundness by aborting the app if a nonsend resource is dropped on the wrong thread. ~~That PR should probably be merged before this one.~~ For a longer term solution we have this discussion going https://github.com/bevyengine/bevy/discussions/6552. + + ### NonSend Systems in render world + + The render world doesn't have any !Send resources, but it does have a non send system. While Window is Send, winit does have some API's that can only be accessed on the main thread. `prepare_windows` in the render schedule thus needs to be scheduled on the main thread. Currently we run nonsend systems by running them on the thread the TaskPool::scope runs on. When we move render to another thread this no longer works. + + To fix this, a new `scope_with_executor` method was added that takes a optional `TheadExecutor` that can only be ticked on the thread it was initialized on. The render world then holds a `MainThreadExecutor` resource which can be passed to the scope in the parallel executor that it uses to spawn it's non send systems on. + + ### Scopes executors between render and main should not share tasks + + Since the render world and the app world share the `ComputeTaskPool`. Because `scope` has executors for the ComputeTaskPool a system from the main world could run on the render thread or a render system could run on the main thread. This can cause performance problems because it can delay a stage from finishing. See https://github.com/bevyengine/bevy/pull/6503#issuecomment-1309791442 for more details. + + To avoid this problem, `TaskPool::scope` has been changed to not tick the ComputeTaskPool when it's used by the parallel executor. In the future when we move closer to the 1 thread to 1 logical core model we may want to overprovide threads, because the render and main app threads don't do much when executing the schedule. + + ## Performance + + My machine is Windows 11, AMD Ryzen 5600x, RX 6600 + + ### Examples + + #### This PR with pipelining vs Main + + > Note that these were run on an older version of main and the performance profile has probably changed due to optimizations + + Seeing a perf gain from 29% on many lights to 7% on many sprites. + + + + + +   | percent |   |   | Diff |   |   | Main |   |   | PR |   |   + -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- + tracy frame time | mean | median | sigma | mean | median | sigma | mean | median | sigma | mean | median | sigma + many foxes | 27.01% | 27.34% | -47.09% | 1.58 | 1.55 | -1.78 | 5.85 | 5.67 | 3.78 | 4.27 | 4.12 | 5.56 + many lights | 29.35% | 29.94% | -10.84% | 3.02 | 3.03 | -0.57 | 10.29 | 10.12 | 5.26 | 7.27 | 7.09 | 5.83 + many animated sprites | 13.97% | 15.69% | 14.20% | 3.79 | 4.17 | 1.41 | 27.12 | 26.57 | 9.93 | 23.33 | 22.4 | 8.52 + 3d scene | 25.79% | 26.78% | 7.46% | 0.49 | 0.49 | 0.15 | 1.9 | 1.83 | 2.01 | 1.41 | 1.34 | 1.86 + many cubes | 11.97% | 11.28% | 14.51% | 1.93 | 1.78 | 1.31 | 16.13 | 15.78 | 9.03 | 14.2 | 14 | 7.72 + many sprites | 7.14% | 9.42% | -85.42% | 1.72 | 2.23 | -6.15 | 24.09 | 23.68 | 7.2 | 22.37 | 21.45 | 13.35 + + + + + + #### This PR with pipelining disabled vs Main + + Mostly regressions here. I don't think this should be a problem as users that are disabling pipelined rendering are probably running single threaded and not using the parallel executor. The regression is probably mostly due to the switch to use `async_executor::run` instead of `try_tick` and also having one less thread to run systems on. I'll do a writeup on why switching to `run` causes regressions, so we can try to eventually fix it. Using try_tick causes issues when pipeline rendering is enable as seen [here](https://github.com/bevyengine/bevy/pull/6503#issuecomment-1380803518) + + + + + +   | percent |   |   | Diff |   |   | Main |   |   | PR no pipelining |   |   + -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- + tracy frame time | mean | median | sigma | mean | median | sigma | mean | median | sigma | mean | median | sigma + many foxes | -3.72% | -4.42% | -1.07% | -0.21 | -0.24 | -0.04 | 5.64 | 5.43 | 3.74 | 5.85 | 5.67 | 3.78 + many lights | 0.29% | -0.30% | 4.75% | 0.03 | -0.03 | 0.25 | 10.29 | 10.12 | 5.26 | 10.26 | 10.15 | 5.01 + many animated sprites | 0.22% | 1.81% | -2.72% | 0.06 | 0.48 | -0.27 | 27.12 | 26.57 | 9.93 | 27.06 | 26.09 | 10.2 + 3d scene | -15.79% | -14.75% | -31.34% | -0.3 | -0.27 | -0.63 | 1.9 | 1.83 | 2.01 | 2.2 | 2.1 | 2.64 + many cubes | -2.85% | -3.30% | 0.00% | -0.46 | -0.52 | 0 | 16.13 | 15.78 | 9.03 | 16.59 | 16.3 | 9.03 + many sprites | 2.49% | 2.41% | 0.69% | 0.6 | 0.57 | 0.05 | 24.09 | 23.68 | 7.2 | 23.49 | 23.11 | 7.15 + + + + + + ### Benchmarks + + Mostly the same except empty_systems has got a touch slower. The maybe_pipelining+1 column has the compute task pool with an extra thread over default added. This is because pipelining loses one thread over main to execute systems on, since the main thread no longer runs normal systems. + +
+ Click Me + + ```text + group main maybe-pipelining+1 + ----- ------------------------- ------------------ + busy_systems/01x_entities_03_systems 1.07 30.7±1.32µs ? ?/sec 1.00 28.6±1.35µs ? ?/sec + busy_systems/01x_entities_06_systems 1.10 52.1±1.10µs ? ?/sec 1.00 47.2±1.08µs ? ?/sec + busy_systems/01x_entities_09_systems 1.00 74.6±1.36µs ? ?/sec 1.00 75.0±1.93µs ? ?/sec + busy_systems/01x_entities_12_systems 1.03 100.6±6.68µs ? ?/sec 1.00 98.0±1.46µs ? ?/sec + busy_systems/01x_entities_15_systems 1.11 128.5±3.53µs ? ?/sec 1.00 115.5±1.02µs ? ?/sec + busy_systems/02x_entities_03_systems 1.16 50.4±2.56µs ? ?/sec 1.00 43.5±3.00µs ? ?/sec + busy_systems/02x_entities_06_systems 1.00 87.1±1.27µs ? ?/sec 1.05 91.5±7.15µs ? ?/sec + busy_systems/02x_entities_09_systems 1.04 139.9±6.37µs ? ?/sec 1.00 134.0±1.06µs ? ?/sec + busy_systems/02x_entities_12_systems 1.05 179.2±3.47µs ? ?/sec 1.00 170.1±3.17µs ? ?/sec + busy_systems/02x_entities_15_systems 1.01 219.6±3.75µs ? ?/sec 1.00 218.1±2.55µs ? ?/sec + busy_systems/03x_entities_03_systems 1.10 70.6±2.33µs ? ?/sec 1.00 64.3±0.69µs ? ?/sec + busy_systems/03x_entities_06_systems 1.02 130.2±3.11µs ? ?/sec 1.00 128.0±1.34µs ? ?/sec + busy_systems/03x_entities_09_systems 1.00 195.0±10.11µs ? ?/sec 1.00 194.8±1.41µs ? ?/sec + busy_systems/03x_entities_12_systems 1.01 261.7±4.05µs ? ?/sec 1.00 259.8±4.11µs ? ?/sec + busy_systems/03x_entities_15_systems 1.00 318.0±3.04µs ? ?/sec 1.06 338.3±20.25µs ? ?/sec + busy_systems/04x_entities_03_systems 1.00 82.9±0.63µs ? ?/sec 1.02 84.3±0.63µs ? ?/sec + busy_systems/04x_entities_06_systems 1.01 181.7±3.65µs ? ?/sec 1.00 179.8±1.76µs ? ?/sec + busy_systems/04x_entities_09_systems 1.04 265.0±4.68µs ? ?/sec 1.00 255.3±1.98µs ? ?/sec + busy_systems/04x_entities_12_systems 1.00 335.9±3.00µs ? ?/sec 1.05 352.6±15.84µs ? ?/sec + busy_systems/04x_entities_15_systems 1.00 418.6±10.26µs ? ?/sec 1.08 450.2±39.58µs ? ?/sec + busy_systems/05x_entities_03_systems 1.07 114.3±0.95µs ? ?/sec 1.00 106.9±1.52µs ? ?/sec + busy_systems/05x_entities_06_systems 1.08 229.8±2.90µs ? ?/sec 1.00 212.3±4.18µs ? ?/sec + busy_systems/05x_entities_09_systems 1.03 329.3±1.99µs ? ?/sec 1.00 319.2±2.43µs ? ?/sec + busy_systems/05x_entities_12_systems 1.06 454.7±6.77µs ? ?/sec 1.00 430.1±3.58µs ? ?/sec + busy_systems/05x_entities_15_systems 1.03 554.6±6.15µs ? ?/sec 1.00 538.4±23.87µs ? ?/sec + contrived/01x_entities_03_systems 1.00 14.0±0.15µs ? ?/sec 1.08 15.1±0.21µs ? ?/sec + contrived/01x_entities_06_systems 1.04 28.5±0.37µs ? ?/sec 1.00 27.4±0.44µs ? ?/sec + contrived/01x_entities_09_systems 1.00 41.5±4.38µs ? ?/sec 1.02 42.2±2.24µs ? ?/sec + contrived/01x_entities_12_systems 1.06 55.9±1.49µs ? ?/sec 1.00 52.6±1.36µs ? ?/sec + contrived/01x_entities_15_systems 1.02 68.0±2.00µs ? ?/sec 1.00 66.5±0.78µs ? ?/sec + contrived/02x_entities_03_systems 1.03 25.2±0.38µs ? ?/sec 1.00 24.6±0.52µs ? ?/sec + contrived/02x_entities_06_systems 1.00 46.3±0.49µs ? ?/sec 1.04 48.1±4.13µs ? ?/sec + contrived/02x_entities_09_systems 1.02 70.4±0.99µs ? ?/sec 1.00 68.8±1.04µs ? ?/sec + contrived/02x_entities_12_systems 1.06 96.8±1.49µs ? ?/sec 1.00 91.5±0.93µs ? ?/sec + contrived/02x_entities_15_systems 1.02 116.2±0.95µs ? ?/sec 1.00 114.2±1.42µs ? ?/sec + contrived/03x_entities_03_systems 1.00 33.2±0.38µs ? ?/sec 1.01 33.6±0.45µs ? ?/sec + contrived/03x_entities_06_systems 1.00 62.4±0.73µs ? ?/sec 1.01 63.3±1.05µs ? ?/sec + contrived/03x_entities_09_systems 1.02 96.4±0.85µs ? ?/sec 1.00 94.8±3.02µs ? ?/sec + contrived/03x_entities_12_systems 1.01 126.3±4.67µs ? ?/sec 1.00 125.6±2.27µs ? ?/sec + contrived/03x_entities_15_systems 1.03 160.2±9.37µs ? ?/sec 1.00 156.0±1.53µs ? ?/sec + contrived/04x_entities_03_systems 1.02 41.4±3.39µs ? ?/sec 1.00 40.5±0.52µs ? ?/sec + contrived/04x_entities_06_systems 1.00 78.9±1.61µs ? ?/sec 1.02 80.3±1.06µs ? ?/sec + contrived/04x_entities_09_systems 1.02 121.8±3.97µs ? ?/sec 1.00 119.2±1.46µs ? ?/sec + contrived/04x_entities_12_systems 1.00 157.8±1.48µs ? ?/sec 1.01 160.1±1.72µs ? ?/sec + contrived/04x_entities_15_systems 1.00 197.9±1.47µs ? ?/sec 1.08 214.2±34.61µs ? ?/sec + contrived/05x_entities_03_systems 1.00 49.1±0.33µs ? ?/sec 1.01 49.7±0.75µs ? ?/sec + contrived/05x_entities_06_systems 1.00 95.0±0.93µs ? ?/sec 1.00 94.6±0.94µs ? ?/sec + contrived/05x_entities_09_systems 1.01 143.2±1.68µs ? ?/sec 1.00 142.2±2.00µs ? ?/sec + contrived/05x_entities_12_systems 1.00 191.8±2.03µs ? ?/sec 1.01 192.7±7.88µs ? ?/sec + contrived/05x_entities_15_systems 1.02 239.7±3.71µs ? ?/sec 1.00 235.8±4.11µs ? ?/sec + empty_systems/000_systems 1.01 47.8±0.67ns ? ?/sec 1.00 47.5±2.02ns ? ?/sec + empty_systems/001_systems 1.00 1743.2±126.14ns ? ?/sec 1.01 1761.1±70.10ns ? ?/sec + empty_systems/002_systems 1.01 2.2±0.04µs ? ?/sec 1.00 2.2±0.02µs ? ?/sec + empty_systems/003_systems 1.02 2.7±0.09µs ? ?/sec 1.00 2.7±0.16µs ? ?/sec + empty_systems/004_systems 1.00 3.1±0.11µs ? ?/sec 1.00 3.1±0.24µs ? ?/sec + empty_systems/005_systems 1.00 3.5±0.05µs ? ?/sec 1.11 3.9±0.70µs ? ?/sec + empty_systems/010_systems 1.00 5.5±0.12µs ? ?/sec 1.03 5.7±0.17µs ? ?/sec + empty_systems/015_systems 1.00 7.9±0.19µs ? ?/sec 1.06 8.4±0.16µs ? ?/sec + empty_systems/020_systems 1.00 10.4±1.25µs ? ?/sec 1.02 10.6±0.18µs ? ?/sec + empty_systems/025_systems 1.00 12.4±0.39µs ? ?/sec 1.14 14.1±1.07µs ? ?/sec + empty_systems/030_systems 1.00 15.1±0.39µs ? ?/sec 1.05 15.8±0.62µs ? ?/sec + empty_systems/035_systems 1.00 16.9±0.47µs ? ?/sec 1.07 18.0±0.37µs ? ?/sec + empty_systems/040_systems 1.00 19.3±0.41µs ? ?/sec 1.05 20.3±0.39µs ? ?/sec + empty_systems/045_systems 1.00 22.4±1.67µs ? ?/sec 1.02 22.9±0.51µs ? ?/sec + empty_systems/050_systems 1.00 24.4±1.67µs ? ?/sec 1.01 24.7±0.40µs ? ?/sec + empty_systems/055_systems 1.05 28.6±5.27µs ? ?/sec 1.00 27.2±0.70µs ? ?/sec + empty_systems/060_systems 1.02 29.9±1.64µs ? ?/sec 1.00 29.3±0.66µs ? ?/sec + empty_systems/065_systems 1.02 32.7±3.15µs ? ?/sec 1.00 32.1±0.98µs ? ?/sec + empty_systems/070_systems 1.00 33.0±1.42µs ? ?/sec 1.03 34.1±1.44µs ? ?/sec + empty_systems/075_systems 1.00 34.8±0.89µs ? ?/sec 1.04 36.2±0.70µs ? ?/sec + empty_systems/080_systems 1.00 37.0±1.82µs ? ?/sec 1.05 38.7±1.37µs ? ?/sec + empty_systems/085_systems 1.00 38.7±0.76µs ? ?/sec 1.05 40.8±0.83µs ? ?/sec + empty_systems/090_systems 1.00 41.5±1.09µs ? ?/sec 1.04 43.2±0.82µs ? ?/sec + empty_systems/095_systems 1.00 43.6±1.10µs ? ?/sec 1.04 45.2±0.99µs ? ?/sec + empty_systems/100_systems 1.00 46.7±2.27µs ? ?/sec 1.03 48.1±1.25µs ? ?/sec + ``` +
+ + ## Migration Guide + + ### App `runner` and SubApp `extract` functions are now required to be Send + + This was changed to enable pipelined rendering. If this breaks your use case please report it as these new bounds might be able to be relaxed. + + ## ToDo + + * [x] redo benchmarking + * [x] reinvestigate the perf of the try_tick -> run change for task pool scope + +commit b3224e135bd82b445fa506e6b68c71cb13a4e7be +Author: IceSentry +Date: Thu Jan 19 22:11:13 2023 +0000 + + Add depth and normal prepass (#6284) + + # Objective + + - Add a configurable prepass + - A depth prepass is useful for various shader effects and to reduce overdraw. It can be expansive depending on the scene so it's important to be able to disable it if you don't need any effects that uses it or don't suffer from excessive overdraw. + - The goal is to eventually use it for things like TAA, Ambient Occlusion, SSR and various other techniques that can benefit from having a prepass. + + ## Solution + + The prepass node is inserted before the main pass. It runs for each `Camera3d` with a prepass component (`DepthPrepass`, `NormalPrepass`). The presence of one of those components is used to determine which textures are generated in the prepass. When any prepass is enabled, the depth buffer generated will be used by the main pass to reduce overdraw. + + The prepass runs for each `Material` created with the `MaterialPlugin::prepass_enabled` option set to `true`. You can overload the shader used by the prepass by using `Material::prepass_vertex_shader()` and/or `Material::prepass_fragment_shader()`. It will also use the `Material::specialize()` for more advanced use cases. It is enabled by default on all materials. + + The prepass works on opaque materials and materials using an alpha mask. Transparent materials are ignored. + + The `StandardMaterial` overloads the prepass fragment shader to support alpha mask and normal maps. + + --- + + ## Changelog + + - Add a new `PrepassNode` that runs before the main pass + - Add a `PrepassPlugin` to extract/prepare/queue the necessary data + - Add a `DepthPrepass` and `NormalPrepass` component to control which textures will be created by the prepass and available in later passes. + - Add a new `prepass_enabled` flag to the `MaterialPlugin` that will control if a material uses the prepass or not. + - Add a new `prepass_enabled` flag to the `PbrPlugin` to control if the StandardMaterial uses the prepass. Currently defaults to false. + - Add `Material::prepass_vertex_shader()` and `Material::prepass_fragment_shader()` to control the prepass from the `Material` + + ## Notes + + In bevy's sample 3d scene, the performance is actually worse when enabling the prepass, but on more complex scenes the performance is generally better. I would like more testing on this, but @DGriffin91 has reported a very noticeable improvements in some scenes. + + The prepass is also used by @JMS55 for TAA and GTAO + + discord thread: + + This PR was built on top of the work of multiple people + + Co-Authored-By: @superdump + Co-Authored-By: @robtfm + Co-Authored-By: @JMS55 + + Co-authored-by: Charles + Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com> + +commit 519f6f45de0fc16592c7adcf40748f174569f807 +Author: Aceeri +Date: Thu Jan 19 06:05:39 2023 +0000 + + Remove unnecessary windows.rs file (#7277) + + # Objective + Accidentally re-added this old file at some point during the Windows as Entities PR apparently + + ## Solution + Removed the file, its unused + +commit 884ebbf4b7a61d8748b2b309ab0bcdf02b51abbf +Author: Mike +Date: Thu Jan 19 05:08:55 2023 +0000 + + min version of fixedbitset was changed (#7275) + + # Objective + + - schedule v3 is using is_clear which was added in 0.4.2, so bump the version + +commit fe382acfd09870992c0516173360fd7da8c108a8 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Thu Jan 19 04:35:46 2023 +0000 + + Fix a typo on `Window::set_minimized` (#7276) + + # Objective + + There is a typo on the method `Window::set_minimized`. + + ## Solution + + fix it + +commit 629cfab135e5f4087ad2a481a4a9be8921d13b83 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Thu Jan 19 03:04:39 2023 +0000 + + Improve safety for `CommandQueue` internals (#7039) + + # Objective + + - Safety comments for the `CommandQueue` type are quite sparse and very imprecise. Sometimes, they are right for the wrong reasons or use circular reasoning. + + ## Solution + + - Document previously-implicit safety invariants. + - Rewrite safety comments to actually reflect the specific invariants of each operation. + - Use `OwningPtr` instead of raw pointers, to encode an invariant in the type system instead of via comments. + - Use typed pointer methods when possible to increase reliability. + + --- + + ## Changelog + + + Added the function `OwningPtr::read_unaligned`. + +commit ddfafab971e335ce5a47d4e4b3fcf51f124d999f +Author: Aceeri +Date: Thu Jan 19 00:38:28 2023 +0000 + + Windows as Entities (#5589) + + # Objective + + Fix https://github.com/bevyengine/bevy/issues/4530 + + - Make it easier to open/close/modify windows by setting them up as `Entity`s with a `Window` component. + - Make multiple windows very simple to set up. (just add a `Window` component to an entity and it should open) + + ## Solution + + - Move all properties of window descriptor to ~components~ a component. + - Replace `WindowId` with `Entity`. + - ~Use change detection for components to update backend rather than events/commands. (The `CursorMoved`/`WindowResized`/... events are kept for user convenience.~ + Check each field individually to see what we need to update, events are still kept for user convenience. + + --- + + ## Changelog + + - `WindowDescriptor` renamed to `Window`. + - Width/height consolidated into a `WindowResolution` component. + - Requesting maximization/minimization is done on the [`Window::state`] field. + - `WindowId` is now `Entity`. + + ## Migration Guide + + - Replace `WindowDescriptor` with `Window`. + - Change `width` and `height` fields in a `WindowResolution`, either by doing + ```rust + WindowResolution::new(width, height) // Explicitly + // or using From<_> for tuples for convenience + (1920., 1080.).into() + ``` + - Replace any `WindowCommand` code to just modify the `Window`'s fields directly and creating/closing windows is now by spawning/despawning an entity with a `Window` component like so: + ```rust + let window = commands.spawn(Window { ... }).id(); // open window + commands.entity(window).despawn(); // close window + ``` + + ## Unresolved + - ~How do we tell when a window is minimized by a user?~ + ~Currently using the `Resize(0, 0)` as an indicator of minimization.~ + No longer attempting to tell given how finnicky this was across platforms, now the user can only request that a window be maximized/minimized. + + ## Future work + - Move `exit_on_close` functionality out from windowing and into app(?) + - https://github.com/bevyengine/bevy/issues/5621 + - https://github.com/bevyengine/bevy/issues/7099 + - https://github.com/bevyengine/bevy/issues/7098 + + + Co-authored-by: Carter Anderson + +commit f0c504947ce653068a424979faf226c1e990818d +Author: Stephen Martindale +Date: Wed Jan 18 23:02:38 2023 +0000 + + Docs: App::run() might never return; effect of WinitSettings::return_from_run. (#7228) + + # Objective + + See: + + - https://github.com/bevyengine/bevy/issues/7067#issuecomment-1381982285 + - (This does not fully close that issue in my opinion.) + - https://discord.com/channels/691052431525675048/1063454009769340989 + + ## Solution + + This merge request adds documentation: + + 1. Alert users to the fact that `App::run()` might never return and code placed after it might never be executed. + 2. Makes `winit::WinitSettings::return_from_run` discoverable. + 3. Better explains why `winit::WinitSettings::return_from_run` is discouraged and better links to up-stream docs. on that topic. + 4. Adds notes to the `app/return_after_run.rs` example which otherwise promotes a feature that carries caveats. + + Furthermore, w.r.t `winit::WinitSettings::return_from_run`: + + - Broken links to `winit` docs are fixed. + - Links now point to BOTH `EventLoop::run()` and `EventLoopExtRunReturn::run_return()` which are the salient up-stream pages and make more sense, taken together. + - Collateral damage: "Supported platforms" heading; disambiguation of "run" → `App::run()`; links. + + ## Future Work + + I deliberately structured the "`run()` might not return" section under `App::run()` to allow for alternative patterns (e.g. `AppExit` event, `WindowClosed` event) to be listed or mentioned, beneath it, in the future. + +commit f8feec6ef1a47a6c8a562399b883d92198f02222 +Author: targrub +Date: Wed Jan 18 17:20:27 2023 +0000 + + Fix tiny clippy issue for upcoming Rust version (#7266) + + + + Co-authored-by: targrub <62773321+targrub@users.noreply.github.com> + +commit e0b921fbd99dffb612860ac9684f800b472a66ec +Author: harudagondi +Date: Wed Jan 18 17:20:26 2023 +0000 + + AudioOutput is actually a normal resource now, not a non-send resource (#7262) + + # Objective + + - Fixes #7260 + + ## Solution + + - #6649 used `init_non_send_resource` for `AudioOutput`, but this is before #6436 was merged. + - Use `init_resource` instead. + +commit 46293ce1e4c61421e353dc0b0431da67af6b7568 +Author: Rob Parrett +Date: Wed Jan 18 17:06:08 2023 +0000 + + Fix init_non_send_resource overwriting previous values (#7261) + + # Objective + + Repeated calls to `init_non_send_resource` currently overwrite the old value because the wrong storage is being checked. + + ## Solution + + Use the correct storage. Add some tests. + + ## Notes + + Without the fix, the new test fails with + ``` + thread 'world::tests::init_non_send_resource_does_not_overwrite' panicked at 'assertion failed: `(left == right)` + left: `1`, + right: `0`', crates/bevy_ecs/src/world/mod.rs:2267:9 + note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + test world::tests::init_non_send_resource_does_not_overwrite ... FAILED + ``` + + This was introduced by #7174 and it seems like a fairly straightforward oopsie. + +commit d6bfd44f8f48af92c727a42ca7fe43f32a2ab747 +Author: Charles Bournhonesque +Date: Wed Jan 18 14:26:07 2023 +0000 + + update doc comment for new_archetype in query-state (#7241) + + # Objective + + I was reading through the bevy_ecs code, trying to understand how everything works. + I was getting a bit confused when reading the doc comment for the `new_archetype` function; it looks like it doesn't create a new archetype but instead updates some internal state in the SystemParam to facility QueryIteration. + + (I still couldn't find where a new archetype was actually created) + + + ## Solution + + - Adding a doc comment with a more correct explanation. + + If it's deemed correct, I can also update the doc-comment for the other `new_archetype` calls + +commit 88b353c4b1665625d5aabe6149e184ec5ba5984c +Author: James Liu +Date: Wed Jan 18 02:19:19 2023 +0000 + + Reduce the use of atomics in the render phase (#7084) + + # Objective + Speed up the render phase of rendering. An extension of #6885. + + `SystemState::get` increments the `World`'s change tick atomically every time it's called. This is notably more expensive than a unsynchronized increment, even without contention. It also updates the archetypes, even when there has been nothing to update when it's called repeatedly. + + ## Solution + Piggyback off of #6885. Split `SystemState::validate_world_and_update_archetypes` into `SystemState::validate_world` and `SystemState::update_archetypes`, and make the later `pub`. Then create safe variants of `SystemState::get_unchecked_manual` that still validate the `World` but do not update archetypes and do not increment the change tick using `World::read_change_tick` and `World::change_tick`. Update `RenderCommandState` to call `SystemState::update_archetypes` in `Draw::prepare` and `SystemState::get_manual` in `Draw::draw`. + + ## Performance + There's a slight perf benefit (~2%) for `main_opaque_pass_3d` on `many_foxes` (340.39 us -> 333.32 us) + + ![image](https://user-images.githubusercontent.com/3137680/210643746-25320b98-3e2b-4a95-8084-892c23bb8b4e.png) + + ## Alternatives + We can change `SystemState::get` to not increment the `World`'s change tick. Though this would still put updating the archetypes and an atomic read on the hot-path. + + --- + + ## Changelog + Added: `SystemState::get_manual` + Added: `SystemState::get_manual_mut` + Added: `SystemState::update_archetypes` + +commit 9eefd7c022efe572ffd2840cfc7a8b9eee982428 +Author: ickshonpe +Date: Wed Jan 18 02:19:17 2023 +0000 + + Remove VerticalAlign from TextAlignment (#6807) + + # Objective + + Remove the `VerticalAlign` enum. + + Text's alignment field should only affect the text's internal text alignment, not its position. The only way to control a `TextBundle`'s position and bounds should be through the manipulation of the constraints in the `Style` components of the nodes in the Bevy UI's layout tree. + + `Text2dBundle` should have a separate `Anchor` component that sets its position relative to its transform. + + Related issues: #676, #1490, #5502, #5513, #5834, #6717, #6724, #6741, #6748 + + ## Changelog + * Changed `TextAlignment` into an enum with `Left`, `Center`, and `Right` variants. + * Removed the `HorizontalAlign` and `VerticalAlign` types. + * Added an `Anchor` component to `Text2dBundle` + * Added `Component` derive to `Anchor` + * Use `f32::INFINITY` instead of `f32::MAX` to represent unbounded text in Text2dBounds + + ## Migration Guide + The `alignment` field of `Text` now only affects the text's internal alignment. + + ### Change `TextAlignment` to TextAlignment` which is now an enum. Replace: + * `TextAlignment::TOP_LEFT`, `TextAlignment::CENTER_LEFT`, `TextAlignment::BOTTOM_LEFT` with `TextAlignment::Left` + * `TextAlignment::TOP_CENTER`, `TextAlignment::CENTER_LEFT`, `TextAlignment::BOTTOM_CENTER` with `TextAlignment::Center` + * `TextAlignment::TOP_RIGHT`, `TextAlignment::CENTER_RIGHT`, `TextAlignment::BOTTOM_RIGHT` with `TextAlignment::Right` + + ### Changes for `Text2dBundle` + `Text2dBundle` has a new field 'text_anchor' that takes an `Anchor` component that controls its position relative to its transform. + +commit 4ff50f6b5062145592575c98d9cc85f04a23ec82 +Author: IceSentry +Date: Wed Jan 18 02:07:26 2023 +0000 + + fix load_internal_binary_asset with debug_asset_server (#7246) + + # Objective + + - Enabling the `debug_asset_server` feature doesn't compile when using it with `load_internal_binary_asset!()`. The issue is because it assumes the loader takes an `&'static str` as a parameter, but binary assets loader expect `&'static [u8]`. + + ## Solution + + - Add a generic type for the loader and use a different type in `load_internal_asset` and `load_internal_binary_asset` + +commit 0df67cdaae30becd35447c6767d5e30afeee17f1 +Author: dis-da-moe +Date: Tue Jan 17 22:42:00 2023 +0000 + + Add `AddAudioSource` trait and improve `Decodable` docs (#6649) + + # Objective + + - Fixes #6361 + - Fixes #6362 + - Fixes #6364 + + ## Solution + - Added an example for creating a custom `Decodable` type + - Clarified the documentation on `Decodable` + - Added an `AddAudioSource` trait and implemented it for `App` + + Co-authored-by: dis-da-moe <84386186+dis-da-moe@users.noreply.github.com> + +commit 7d0edbc4d65c483d3e73c574b93a4a36560c0d07 +Author: James Liu +Date: Tue Jan 17 22:26:51 2023 +0000 + + Improve change detection behavior for transform propagation (#6870) + + # Objective + Fix #4647. If any child is changed, or even reordered, `Changed` is true, which causes transform propagation to propagate changes to all siblings of a changed child, even if they don't need to be. + + ## Solution + As `Parent` and `Children` are updated in tandem in hierarchy commands after #4800. `Changed` is true on the child when `Changed` is true on the parent. However, unlike checking children, checking `Changed` is only localized to the current entity and will not force propagation to the siblings. + + Also took the opportunity to change propagation to use `Query::iter_many` instead of repeated `Query::get` calls. Should cut a bit of the overhead out of propagation. This means we won't panic when there isn't a `Parent` on the child, just skip over it. + + The tests from #4608 still pass, so the change detection here still works just fine under this approach. + +commit 0ca9c618e1dedecfe737d9a1a23748192e348441 +Author: Boxy +Date: Tue Jan 17 21:11:26 2023 +0000 + + Update "Classifying PRs" section to talk about `D-Complex` (#7216) + + The current section does not talk about `D-Complex` and lists things like "adds unsafe code" as a reason to mark a PR `S-Controversial`. This is not how `D-Complex` and `S-Controversial` are being used at the moment. + + This PR lists what classifies a PR as `D-Complex` and what classifies a PR as `S-Controversial`. It also links to some PRs with each combination of labels to help give an idea for what this means in practice. + + cc #7211 which is doing a similar thing + +commit 63a291c6a800a12e8beb3dbad8f64927380493ca +Author: Mike +Date: Tue Jan 17 17:54:53 2023 +0000 + + add tests for change detection and conditions for stageless (#7249) + + # Objective + + - add some tests for how change detection and run criteria interact in stageless + +commit 45dfa71e032fef2827f154f60928da84e11cc92d +Author: robtfm <50659922+robtfm@users.noreply.github.com> +Date: Tue Jan 17 17:39:28 2023 +0000 + + fix bloom viewport (#6802) + + # Objective + + fix bloom when used on a camera with a viewport specified + + ## Solution + + - pass viewport into the prefilter shader, and use it to read from the correct section of the original rendered screen + - don't apply viewport for the intermediate bloom passes, only for the final blend output + +commit 1cc663f2909e8d8a989668383bb0c3c5f034a816 +Author: wyhaya +Date: Tue Jan 17 13:26:43 2023 +0000 + + Improve `Color::hex` performance (#6940) + + # Objective + + Improve `Color::hex` performance + + #### Bench + + ```bash + running 2 tests + test bench_color_hex_after ... bench: 4 ns/iter (+/- 0) + test bench_color_hex_before ... bench: 14 ns/iter (+/- 0) + ``` + + ## Solution + + Use `const fn` decode hex value. + + --- + + ## Changelog + + Rename + + ```rust + HexColorError::Hex(FromHexError) -> HexColorError::Char(char) + ``` + +commit 16ff05acdf2f04c37059c76dc87457d36f78c2f8 +Author: 2ne1ugly +Date: Tue Jan 17 04:20:42 2023 +0000 + + Add `World::clear_resources` & `World::clear_all` (#3212) + + # Objective + + - Fixes #3158 + + ## Solution + + - clear columns + + My implementation of `clear_resources` do not remove the components itself but it clears the columns that keeps the resource data. I'm not sure if the issue meant to clear all resources, even the components and component ids (which I'm not sure if it's possible) + + Co-authored-by: 2ne1ugly <47616772+2ne1ugly@users.noreply.github.com> + +commit b5893e570d2a68471d2f3d147751dcc33bac32e0 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Tue Jan 17 03:29:08 2023 +0000 + + Add a missing impl of `ReadOnlySystemParam` for `Option>` (#7245) + + # Objective + + The trait `ReadOnlySystemParam` is not implemented for `Option>`, even though it should be. + + Follow-up to #7243. This fixes another mistake made in #6919. + + ## Solution + + Add the missing impl. + +commit 0efe66b081e0e8ea5bf089b7d2394598a9774993 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Tue Jan 17 01:39:19 2023 +0000 + + Remove an incorrect impl of `ReadOnlySystemParam` for `NonSendMut` (#7243) + + # Objective + + The trait `ReadOnlySystemParam` is implemented for `NonSendMut`, when it should not be. This mistake was made in #6919. + + ## Solution + + Remove the incorrect impl. + +commit 684f07595f2f440556cd26a3d8fb5af0d809f872 +Author: Cameron <51241057+maniwani@users.noreply.github.com> +Date: Tue Jan 17 01:39:17 2023 +0000 + + Add `bevy_ecs::schedule_v3` module (#6587) + + # Objective + + Complete the first part of the migration detailed in bevyengine/rfcs#45. + + ## Solution + + Add all the new stuff. + + ### TODO + + - [x] Impl tuple methods. + - [x] Impl chaining. + - [x] Port ambiguity detection. + - [x] Write docs. + - [x] ~~Write more tests.~~(will do later) + - [ ] Write changelog and examples here? + - [x] ~~Replace `petgraph`.~~ (will do later) + + + + Co-authored-by: james7132 + Co-authored-by: Michael Hsu + Co-authored-by: Mike Hsu + +commit 6b4795c428f694a332f0a4710df1ba9b5499bc26 +Author: ira +Date: Mon Jan 16 23:13:11 2023 +0000 + + Add `Camera::viewport_to_world_2d` (#6557) + + # Objective + + Add a simpler and less expensive 2D variant of `viewport_to_world`. + + Co-authored-by: devil-ira + +commit 39e14a4a40014fe5f14bef9cf39916ed3e799b2e +Author: Alice Cecile +Date: Mon Jan 16 22:10:51 2023 +0000 + + Make `EntityRef::new` unsafe (#7222) + + # Objective + + - We rely on the construction of `EntityRef` to be valid elsewhere in unsafe code. This construction is not checked (for performance reasons), and thus this private method must be unsafe. + - Fixes #7218. + + ## Solution + + - Make the method unsafe. + - Add safety docs. + - Improve safety docs slightly for the sibling `EntityMut::new`. + - Add debug asserts to start to verify these assumptions in debug mode. + + + ## Context for reviewers + + I attempted to verify the `EntityLocation` more thoroughly, but this turned out to be more work than expected. I've spun that off into #7221 as a result. + +commit e44990a48d97fe73aef8f53d2016bd05b260e1ba +Author: ld000 +Date: Mon Jan 16 21:24:15 2023 +0000 + + Add ReplaceChildren and ClearChildren EntityCommands (#6035) + + # Objective + + Fixes #5859 + + ## Solution + + - Add `ClearChildren` and `ReplaceChildren` commands in the `crates/bevy_hierarchy/src/child_builder.rs` + + --- + + ## Changelog + + - Added `ClearChildren` and `ReplaceChildren` struct + - Added `clear_children(&mut self) -> &mut Self` and `replace_children(&mut self, children: &[Entity]) -> &mut Self` function in `BuildChildren` trait + - Changed `PushChildren` `write` function body to a `push_children ` function to reused in `ReplaceChildren` + - Added `clear_children` function + - Added `push_and_replace_children_commands` and `push_and_clear_children_commands` test + + + + Co-authored-by: ld000 + Co-authored-by: lidong63 + +commit d4e3fcdfbf306c10cd28cb914e228cc0a24c2336 +Author: Elbert Ronnie +Date: Mon Jan 16 21:09:24 2023 +0000 + + Fix incorrect behavior of `just_pressed` and `just_released` in `Input` (#7238) + + # Objective + + - Fixes a bug where `just_pressed` and `just_released` in `Input` might behave incorrectly due calling `clear` 3 times in a single frame through these three different systems: `gamepad_button_event_system`, `gamepad_axis_event_system` and `gamepad_connection_system` in any order + + ## Solution + + - Call `clear` only once and before all the above three systems, i.e. in `gamepad_event_system` + + ## Additional Info + + - Discussion in Discord: https://discord.com/channels/691052431525675048/768253008416342076/1064621963693273279 + +commit addc36fe297bce3325cf1fa110a67692ac09d232 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Jan 16 20:35:15 2023 +0000 + + Add safety comments to usages of `byte_add` (`Ptr`, `PtrMut`, `OwningPtr`) (#7214) + + # Objective + + The usages of the unsafe function `byte_add` are not properly documented. + + Follow-up to #7151. + + ## Solution + + Add safety comments to each call-site. + +commit 5fd628ebd32aea9a38882dfc38cc3160cf4c82f7 +Author: ira +Date: Mon Jan 16 20:20:37 2023 +0000 + + Fix Alien Cake Addict example despawn warnings (#7236) + + # Problem + The example's `teardown` system despawns all entities besides the camera using `despawn_recursive` causing it to despawn child entities multiple times which logs a warning. + ![image](https://user-images.githubusercontent.com/29694403/212756554-06b3fa42-ddcb-4a05-b841-f587488a10fc.png) + + # Solution + Use `despawn` instead. + + Co-authored-by: Devil Ira + +commit 2f4cf768661839079f49fe5ef9527248a9131b95 +Author: Nicola Papale +Date: Mon Jan 16 18:13:04 2023 +0000 + + Fix axis settings constructor (#7233) + + # Objective + + Currently, the `AxisSettings::new` function is unusable due to + an implementation quirk. It only allows `AxisSettings` where + the bounds that are supposed to be positive are negative! + + ## Solution + + - We fix the bound check + - We add a test to make sure the method is usable + + + Seems like the error slipped through because of the relatively + verbose code style. With all those `if/else`, very long names, + range syntax, the bound check is actually hard to spot. I first + refactored a lot of code, but I left out the refactor because the + fix should be integrated independently. + + --- + + ## Changelog + + - Fix `AxisSettings::new` only accepting invalid bounds + +commit 83028994d17842e975b17bd849ab76c3ef6e5fbb +Author: Thierry Berger +Date: Mon Jan 16 17:36:09 2023 +0000 + + Optional BEVY_ASSET_ROOT to find assets directory (#5346) + + # Objective + + Fixes #5345 + + ## Changelog + + - Support optional env variable `BEVY_ASSET_ROOT` to explicitly specify root assets directory. + +commit a792f37040f5edb62a6a13166c72978e1cbc9c9c +Author: Dawid Piotrowski +Date: Mon Jan 16 17:17:45 2023 +0000 + + Relative cursor position (#7199) + + # Objective + + Add useful information about cursor position relative to a UI node. Fixes #7079. + + ## Solution + + - Added a new `RelativeCursorPosition` component + + --- + + ## Changelog + + - Added + - `RelativeCursorPosition` + - an example showcasing the new component + + Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com> + +commit 517deda215f58da2b6f27d373c42b97a93a95d58 +Author: Daniel Chia +Date: Mon Jan 16 15:41:14 2023 +0000 + + Make PipelineCache internally mutable. (#7205) + + # Objective + + - Allow rendering queue systems to use a `Res` even for queueing up new rendering pipelines. This is part of unblocking parallel execution queue systems. + + ## Solution + + - Make `PipelineCache` internally mutable w.r.t to queueing new pipelines. Pipelines are no longer immediately updated into the cache state, but rather queued into a Vec. The Vec of pending new pipelines is then later processed at the same time we actually create the queued pipelines on the GPU device. + + --- + + ## Changelog + + `PipelineCache` no longer requires mutable access in order to queue render / compute pipelines. + + ## Migration Guide + + * Most usages of `resource_mut::` and `ResMut` can be changed to `resource::` and `Res` as long as they don't use any methods requiring mutability - the only public method requiring it is `process_queue`. + +commit 4b326fb4caed0bcad85954083f87846adface8ad +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Jan 16 15:41:12 2023 +0000 + + Improve safety for `BlobVec::replace_unchecked` (#7181) + + # Objective + + - The function `BlobVec::replace_unchecked` has informal use of safety comments. + - This function does strange things with `OwningPtr` in order to get around the borrow checker. + + ## Solution + + - Put safety comments in front of each unsafe operation. Describe the specific invariants of each operation and how they apply here. + - Added a guard type `OnDrop`, which is used to simplify ownership transfer in case of a panic. + + --- + + ## Changelog + + + Added the guard type `bevy_utils::OnDrop`. + + Added conversions from `Ptr`, `PtrMut`, and `OwningPtr` to `NonNull`. + +commit 38005b07021691af5d36f07a78a69671e250a5f1 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Jan 16 15:22:38 2023 +0000 + + Support piping exclusive systems (#7023) + + # Objective + + Fix #5248. + + ## Solution + + Support `In` parameters and allow returning arbitrary types in exclusive systems. + + --- + + ## Changelog + + - Exclusive systems may now be used with system piping. + + ## Migration Guide + + Exclusive systems (systems that access `&mut World`) now support system piping, so the `ExclusiveSystemParamFunction` trait now has generics for the `In`put and `Out`put types. + + ```rust + // Before + fn my_generic_system(system_function: T) + where T: ExclusiveSystemParamFunction + { ... } + + // After + fn my_generic_system(system_function: T) + where T: ExclusiveSystemParamFunction + { ... } + ``` + +commit c56bbcb3b037916ffa64d4b753fb8636756ea9be +Author: Carter Anderson +Date: Sun Jan 15 06:13:56 2023 +0000 + + Use Bevy People links in The Bevy Organization Doc (#7200) + + Bevy People should be considered the source of truth for Bevy Organization roles. This replaces inline lists of maintainers and SMEs with links to Bevy People. + +commit e42c0988eba616902d2fa615adde6d5598b3712a +Author: 2ne1ugly <47616772+2ne1ugly@users.noreply.github.com> +Date: Sun Jan 15 05:56:14 2023 +0000 + + Add missing discord link in "the_bevy_organization.md" (#7203) + + # Objective + + - Add change that was suggested in https://github.com/bevyengine/bevy/pull/7185#pullrequestreview-1248746032 but missed + + ## Solution + + - Add the change + +commit 82b0e712cea379f8134b93d154efec616314f7a9 +Author: Carter Anderson +Date: Sat Jan 14 20:36:56 2023 +0000 + + Subject Matter Experts and new Bevy Org docs (#7185) + + We are in the process of rolling out a new Bevy Organization role! (Subject Matter Expert) + + This adds a new "The Bevy Organization" document and links to it from CONTRIBUTING.md. This doc describes how the Bevy Organization will work going forward. It outlines the functionality of each role, as well as the expectations we have for them. The previously existing roles (Project Lead, Maintainer) still work the same way, but their definition and scope have been made much clearer. + + Tomorrow we will be announcing this publicly in a blog post. This will describe the motivation and announce the first round of SMEs . But before that it makes sense to do a quick review round first. + + Given the quick turnaround on this PR, this isn't the best platform to discuss changes to the SME system (or its validity). After you have read the announcement tomorrow, feel free to start discussions wherever is preferable to you (this repo, discord, etc). So for now, please just review for clarity / typos / phrasing / missed info / etc. + + [Rendered](https://github.com/bevyengine/bevy/blob/08ceae43dbfacf630447e5f5f1cfa53397242687/docs/the_bevy_organization.md) + +commit 908c40dd88f88219ab8fc11650531bd194bab2e7 +Author: Sludge <96552222+SludgePhD@users.noreply.github.com> +Date: Sat Jan 14 18:33:38 2023 +0000 + + Implement `Clone` for all pipeline types (#6653) + + # Objective + + Pipelines can be customized by wrapping an existing pipeline in a newtype and adding custom logic to its implementation of `SpecializedMeshPipeline::specialize`. To make that easier, the wrapped pipeline type needs to implement `Clone`. + + For example, the current non-cloneable pipelines require wrapper pipelines to pull apart the wrapped pipeline like this: + + ```rust + impl FromWorld for Wireframe2dPipeline { + fn from_world(world: &mut World) -> Self { + let p = &world.resource::>(); + Self { + mesh2d_pipeline: p.mesh2d_pipeline.clone(), + material2d_layout: p.material2d_layout.clone(), + vertex_shader: p.vertex_shader.clone(), + fragment_shader: p.fragment_shader.clone(), + } + } + } + ``` + + ## Solution + + Derive or implement `Clone` on all built-in pipeline types. This is easy to do since they mostly just contain cheaply clonable reference-counted types. + + --- + + ## Changelog + + Implement `Clone` for all pipeline types. + +commit d9265db3447dfe8b74b40de297a3ad7d696f4ece +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Fri Jan 13 22:35:43 2023 +0000 + + Implement `ReadOnlySystemParam` for `Extract<>` (#7182) + + # Objective + + - `Extract` does not implement `ReadOnlySystemParam` even though it should. + - Noticed by @hymm on discord: https://discord.com/channels/691052431525675048/749335865876021248/1063535818267963543 + + ## Solution + + Implement the trait. + +commit 0af8e1c2117fa5b36e084848edf0a173207d6f4e +Author: robtfm <50659922+robtfm@users.noreply.github.com> +Date: Fri Jan 13 17:06:24 2023 +0000 + + fix spot dir nan again (#7176) + + # Objective + + fix error with shadow shader's spotlight direction calculation when direction.y ~= 0 + fixes #7152 + + ## Solution + + same as #6167: in shadows.wgsl, clamp 1-x^2-z^2 to >= 0 so that we can safely sqrt it + +commit 008c156991a52532fbab7061a1bee668c78fac91 +Author: Jakob Hellermann +Date: Fri Jan 13 16:50:26 2023 +0000 + + refactor: move internals from `entity_ref` to `World`, add `SAFETY` comments (#6402) + + # Objective + + There are some utility functions for actually working with `Storages` inside `entity_ref.rs` that are used both for `EntityRef/EntityMut` and `World`, with a `// TODO: move to Storages`. + This PR moves them to private methods on `World`, because that's the safest API boundary. On `Storages` you would need to ensure that you pass `Components` from the same world. + + ## Solution + + - move get_component[_with_type], get_ticks[_with_type], get_component_and_ticks[_with_type] to `World` (still pub(crate)) + - replace `pub use entity_ref::*;` with `pub use entity_ref::{EntityRef, EntityMut}` and qualified `entity_ref::get_mut[_by_id]` in `world.rs` + - add safety comments to a bunch of methods + +commit feac2c206c820934942e5228a1e77c723385e717 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Thu Jan 12 23:25:11 2023 +0000 + + Remove duplicate lookups from `Resource` initialization (#7174) + + # Objective + + * `World::init_resource` and `World::get_resource_or_insert_with` are implemented naively, and as such they perform duplicate `TypeId -> ComponentId` lookups. + * `World::get_resource_or_insert_with` contains an additional duplicate `ComponentId -> ResourceData` lookup. + * This function also contains an unnecessary panic branch, which we rely on the optimizer to be able to remove. + + ## Solution + + Implement the functions using engine-internal code, instead of combining high-level functions. This allows computed variables to persist across different branches, instead of being recomputed. + +commit b47c466880dd94b36e085e4e7fc7d271cf94353b +Author: James Liu +Date: Thu Jan 12 22:39:59 2023 +0000 + + Use Ref instead of &T and Changed (#7175) + + # Objective + Follow up #7097. Use `Ref` instead of `&T` and the change detection query params. + + ## Solution + Replace them. + +commit 689eab6fb7028e3da2d0e01b8e2d8b26f59c92cb +Author: Nicola Papale +Date: Thu Jan 12 18:46:11 2023 +0000 + + Add an extension trait to `EntityCommands` to update hierarchy while preserving `GlobalTransform` (#7024) + + # Objective + + It is often necessary to update an entity's parent + while keeping its GlobalTransform static. Currently + it is cumbersome and error-prone (two questions in + the discord `#help` channel in the past week) + + - Part 2, resolves #5475 + - Builds on: #7020. + + ## Solution + + - Added the `BuildChildrenTransformExt` trait, it is part + of `bevy::prelude` and adds the following methods to `EntityCommands`: + - `set_parent_in_place`: Change the parent of an entity and + update its `Transform` in order to preserve its `GlobalTransform` after the parent change + - `remove_parent_in_place`: Remove an entity from a hierarchy, + while preserving its `GlobalTransform`. + + --- + + ## Changelog + + + - Added the `BuildChildrenTransformExt` trait, it is part + of `bevy::prelude` and adds the following methods to `EntityCommands`: + - `set_parent_in_place`: Change the parent of an entity and + update its `Transform` in order to preserve its `GlobalTransform` after the parent change + - `remove_parent_in_place`: Remove an entity from a hierarchy, + while preserving its `GlobalTransform`. + + Co-authored-by: Nicola Papale + +commit ba3069f008c7384cbc3179991699ceb38a6f3a8f +Author: François +Date: Thu Jan 12 17:15:20 2023 +0000 + + Change default FocusPolicy to Pass (#7161) + + # Objective + + - While building UI, it makes more sense for most nodes to have a `FocusPolicy` of `Pass`, so that user interaction can correctly bubble + - Only `ButtonBundle` blocks by default + + This change means that for someone adding children to a button, it's not needed to change the focus policy of those children to `Pass` for the button to continue to work. + + --- + + ## Changelog + + - `FocusPolicy` default has changed from `FocusPolicy::Block` to `FocusPolicy::Pass` + + ## Migration Guide + + - `FocusPolicy` default has changed from `FocusPolicy::Block` to `FocusPolicy::Pass` + +commit 76de9f940786698ec7a33ecbfe916acbc9e2f33b +Author: Kurt Kühnert +Date: Thu Jan 12 15:11:58 2023 +0000 + + Improve render phase documentation (#7016) + + # Objective + + The documentation of the bevy_render crate is still pretty incomplete. + This PR follows up on #6885 and improves the documentation of the `render_phase` module. + This module contains one of our most important rendering abstractions and the current documentation is pretty confusing. This PR tries to clarify what all of these pieces are for and how they work together to form bevy`s modular rendering logic. + + ## Solution + + ### Code Reformating + - I have moved the `rangefinder` into the `render_phase` module since it is only used there. + - I have moved the `PhaseItem` (and the `BatchedPhaseItem`) from `render_phase::draw` over to `render_phase::mod`. This does not change the public-facing API since they are reexported anyway, but this change makes the relation between `RenderPhase` and `PhaseItem` clear and easier to discover. + + ### Documentation + - revised all documentation in the `render_phase` module + - added a module-level explanation of how `RenderPhase`s, `RenderPass`es, `PhaseItem`s, `Draw` functions, and `RenderCommands` relate to each other and how they are used + + --- + + ## Changelog + + - The `rangefinder` module has been moved into the `render_phase` module. + + ## Migration Guide + + - The `rangefinder` module has been moved into the `render_phase` module. + + ```rust + //old + use bevy::render::rangefinder::*; + + // new + use bevy::render::render_phase::rangefinder::*; + ``` + +commit f4920bbd6d2d31c1fb25a359c2aff71eefe2620a +Author: James Liu +Date: Wed Jan 11 23:31:22 2023 +0000 + + Mark TableRow and TableId as repr(transparent) (#7166) + + # Objective + Following #6681, both `TableRow` and `TableId` are now part of `EntityLocation`. However, the safety invariant on `EntityLocation` requires that all of the constituent fields are `repr(transprent)` or `repr(C)` and the bit pattern of all 1s must be valid. This is not true for `TableRow` and `TableId` currently. + + ## Solution + Mark `TableRow` and `TableId` to satisfy the safety requirement. Add safety comments on `ArchetypeId`, `ArchetypeRow`, `TableId` and `TableRow`. + +commit dfc4f05c87bba6c54ae8bc8d70c32f4dec4fefba +Author: James Liu +Date: Wed Jan 11 23:12:20 2023 +0000 + + Ensure Ptr/PtrMut/OwningPtr are aligned when casting in debug builds (#7117) + + # Objective + Improve safety testing when using `bevy_ptr` types. This is a follow-up to #7113. + + ## Solution + Add a debug-only assertion that pointers are aligned when casting to a concrete type. This should very quickly catch any unsoundness from unaligned pointers, even without miri. However, this can have a large negative perf impact on debug builds. + + --- + + ## Changelog + Added: `Ptr::deref` will now panic in debug builds if the pointer is not aligned. + Added: `PtrMut::deref_mut` will now panic in debug builds if the pointer is not aligned. + Added: `OwningPtr::read` will now panic in debug builds if the pointer is not aligned. + Added: `OwningPtr::drop_as` will now panic in debug builds if the pointer is not aligned. + +commit 60be8759e37e00131d01b649e288c599652aff0d +Author: François +Date: Wed Jan 11 21:12:02 2023 +0000 + + add helper for macro to get either bevy::x or bevy_x depending on how it was imported (#7164) + + # Objective + + - It can be useful for third party crates to work independently on how bevy is imported + + ## Solution + + - Expose an helper to get a subcrate path for macros + +commit 7783393c56f183bcd3b5506906b84d3014594b55 +Author: 张林伟 +Date: Wed Jan 11 21:12:01 2023 +0000 + + Expose transform propagate systems (#7145) + + # Objective + + - I tried to create a fork of bevy_rapier to track latest bevy main branch. But bevy_rapier depends on bevy internal `propagate_transforms` system (see https://github.com/dimforge/bevy_rapier/blob/master/src/plugin/plugin.rs#L64). + - `propagate_transforms` system was changed to private in https://github.com/bevyengine/bevy/pull/4775. + + I don't know if it's reasonable that making `propagate_transforms` public. I also created an issue to bevy_rapier https://github.com/dimforge/bevy_rapier/issues/307 to see how offical team will solve this issue. + + ## Solution + + - make `propagate_transforms` system public. + +commit aa3dd14badcb0e1f170614bce35040ef22a234d1 +Author: François +Date: Wed Jan 11 20:52:04 2023 +0000 + + gate an import used only for a debug assert (#7165) + + # Objective + + - There is a warning when building in release: + ``` + warning: unused import: `bevy_ecs::system::Local` + --> crates/bevy_render/src/extract_resource.rs:5:5 + | + 5 | use bevy_ecs::system::Local; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default + ``` + - It's used https://github.com/bevyengine/bevy/blob/59751d6e33d94eff6e1fc20c9ae155974b3860b1/crates/bevy_render/src/extract_resource.rs#L47 + - Fix it + + ## Solution + + - Gate the import + - repeat of #5320 + +commit 59751d6e33d94eff6e1fc20c9ae155974b3860b1 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Wed Jan 11 17:47:54 2023 +0000 + + Add a method for converting `MutUntyped` -> `Mut` (#7113) + + # Objective + + `MutUntyped` is a struct that stores a `PtrMut` alongside change tick metadata. Working with this type is cumbersome, and has few benefits over storing the pointer and change ticks separately. + + Related: #6430 (title is out of date) + + ## Solution + + Add a convenience method for transforming an untyped change detection pointer into its typed counterpart. + + --- + + ## Changelog + + - Added the method `MutUntyped::with_type`. + +commit 15ee98db8d1c6705111e0f11a8fc240ceaf9f2db +Author: Guillaume Gomez +Date: Wed Jan 11 17:01:11 2023 +0000 + + Add "transparent" doc alias for Color::NONE (#7160) + + As mentioned in https://github.com/bevyengine/bevy/pull/6530. It allows to not create a new constant and simply having it to show up in the documentation when someone is looking for "transparent" (case insensitive) in rustdoc search. + + cc @alice-i-cecile + +commit 6cc01c144947b54392a71a261651c6fe11916eea +Author: Gino Valente +Date: Wed Jan 11 16:46:27 2023 +0000 + + bevy_reflect: Add simple enum support to reflection paths (#6560) + + # Objective + + Enums are now reflectable, but are not accessible via reflection paths. + + This would allow us to do things like: + + ```rust + #[derive(Reflect)] + struct MyStruct { + data: MyEnum + } + + #[derive(Reflect)] + struct MyEnum { + Foo(u32, u32), + Bar(bool) + } + + let x = MyStruct { + data: MyEnum::Foo(123), + }; + + assert_eq!(*x.get_path::("data.1").unwrap(), 123); + ``` + + ## Solution + + Added support for enums in reflection paths. + + ##### Note + This uses a simple approach of just getting the field with the given accessor. It does not do matching or anything else to ensure the enum is the intended variant. This means that the variant must be known ahead of time or matched outside the reflection path (i.e. path to variant, perform manual match, and continue pathing). + + --- + + ## Changelog + + - Added support for enums in reflection paths + +commit 229d6c686fae19ff45b7bddfe9f853096b56f211 +Author: Gino Valente +Date: Wed Jan 11 16:25:37 2023 +0000 + + bevy_reflect: Simplify `take`-or-else-`from_reflect` operation (#6566) + + # Objective + + There are times where we want to simply take an owned `dyn Reflect` and cast it to a type `T`. + + Currently, this involves doing: + + ```rust + let value = value.take::().unwrap_or_else(|value| { + T::from_reflect(&*value).unwrap_or_else(|| { + panic!( + "expected value of type {} to convert to type {}.", + value.type_name(), + std::any::type_name::() + ) + }) + }); + ``` + + This is a common operation that could be easily be simplified. + + ## Solution + + Add the `FromReflect::take_from_reflect` method. This first tries to `take` the value, calling `from_reflect` iff that fails. + + ```rust + let value = T::take_from_reflect(value).unwrap_or_else(|value| { + panic!( + "expected value of type {} to convert to type {}.", + value.type_name(), + std::any::type_name::() + ) + }); + ``` + + Based on suggestion from @soqb on [Discord](https://discord.com/channels/691052431525675048/1002362493634629796/1041046880316043374). + + --- + + ## Changelog + + - Add `FromReflect::take_from_reflect` method + +commit 9dd8fbc570fb08eca9301ac4cd47844624eed22a +Author: Joshua Chapman +Date: Wed Jan 11 15:41:54 2023 +0000 + + Added Ref to allow immutable access with change detection (#7097) + + # Objective + + - Fixes #7066 + + ## Solution + + - Split the ChangeDetection trait into ChangeDetection and ChangeDetectionMut + - Added Ref as equivalent to &T with change detection + + --- + + ## Changelog + + - Support for Ref which allow inspecting change detection flags in an immutable way + + ## Migration Guide + + - While bevy prelude includes both ChangeDetection and ChangeDetectionMut any code explicitly referencing ChangeDetection might need to be updated to ChangeDetectionMut or both. Specifically any reading logic requires ChangeDetection while writes requires ChangeDetectionMut. + + use bevy_ecs::change_detection::DetectChanges -> use bevy_ecs::change_detection::{DetectChanges, DetectChangesMut} + + - Previously Res had methods to access change detection `is_changed` and `is_added` those methods have been moved to the `DetectChanges` trait. If you are including bevy prelude you will have access to these types otherwise you will need to `use bevy_ecs::change_detection::DetectChanges` to continue using them. + +commit 0d2cdb450d49bc8abea5e0b46275288efc453f3c +Author: 张林伟 +Date: Wed Jan 11 09:51:22 2023 +0000 + + Fix beta clippy lints (#7154) + + # Objective + + - When I run `cargo run -p ci` for my pr locally using latest beta toolchain, the ci failed due to [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) and [needless_lifetimes](https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes) lints + + ## Solution + + - Fix lints according to clippy suggestions. + +commit bb79903938691220641a9afcdb73b9bce7ca522b +Author: 张林伟 +Date: Wed Jan 11 09:32:07 2023 +0000 + + Fix clippy issue for benches crate (#6806) + + # Objective + + - https://github.com/bevyengine/bevy/pull/3505 marked `S-Adopt-Me` , this pr is to continue his work. + + ## Solution + + - run `cargo clippy --workspace --all-targets --all-features -- -Aclippy::type_complexity -Wclippy::doc_markdown -Wclippy::redundant_else -Wclippy::match_same_arms -Wclippy::semicolon_if_nothing_returned -Wclippy::explicit_iter_loop -Wclippy::map_flatten -Dwarnings` under benches dir. + - fix issue according to suggestion. + +commit 512f376fc1f88a696849cd06586bccc85441bb2e +Author: Boxy +Date: Tue Jan 10 23:12:52 2023 +0000 + + Document alignment requirements of `Ptr`, `PtrMut` and `OwningPtr` (#7151) + + # Objective + + The types in the `bevy_ptr` accidentally did not document anything relating to alignment. This is unsound as many methods rely on the pointer being correctly aligned. + + ## Solution + + This PR introduces new safety invariants on the `$ptr::new`, `$ptr::byte_offset` and `$ptr::byte_add` methods requiring them to keep the pointer aligned. This is consistent with the documentation of these pointer types which document them as being "type erased borrows". + + As it was pointed out (by @JoJoJet in #7117) that working with unaligned pointers can be useful (for example our commands abstraction which does not try to align anything properly, see #7039) this PR also introduces a default type parameter to all the pointer types that specifies whether it has alignment requirements or not. I could not find any code in `bevy_ecs` that would need unaligned pointers right now so this is going unused. + + --- + + ## Changelog + + - Correctly document alignment requirements on `bevy_ptr` types. + - Support variants of `bevy_ptr` types that do not require being correctly aligned for the pointee type. + + ## Migration Guide + + - Safety invariants on `bevy_ptr` types' `new` `byte_add` and `byte_offset` methods have been changed. All callers should re-audit for soundness. + +commit a13b6f8a054c0d6d21de5cb6dd2ed7705c9bea92 +Author: Mike +Date: Tue Jan 10 22:32:42 2023 +0000 + + Thread executor for running tasks on specific threads. (#7087) + + # Objective + + - Spawn tasks from other threads onto an async executor, but limit those tasks to run on a specific thread. + - This is a continuation of trying to break up some of the changes in pipelined rendering. + - Eventually this will be used to allow `NonSend` systems to run on the main thread in pipelined rendering #6503 and also to solve #6552. + - For this specific PR this allows for us to store a thread executor in a thread local, rather than recreating a scope executor for every scope which should save on a little work. + + ## Solution + + - We create a Executor that does a runtime check for what thread it's on before creating a !Send ticker. The ticker is the only way for the executor to make progress. + + --- + + ## Changelog + + - create a ThreadExecutor that can only be ticked on one thread. + +commit d4babafe81afb20f1d8d3665c1f04440dba90628 +Author: Boxy +Date: Tue Jan 10 18:55:23 2023 +0000 + + Make `Query` fields private (#7149) + + `Query`'s fields being `pub(crate)` means that the struct can be constructed via safe code from anywhere in `bevy_ecs` . This is Not Good since it is intended that all construction of this type goes through `Query::new` which is an `unsafe fn` letting various `Query` methods rely on those invariants holding even though they can be trivially bypassed. + + This has no user facing impact + +commit 3600c5a340bb4d3a7fae0c463e01d6c0028ccf97 +Author: Nicola Papale +Date: Tue Jan 10 18:55:22 2023 +0000 + + Remove the `GlobalTransform::translation_mut` method (#7134) + + # Objective + + It is possible to manually update `GlobalTransform`. + The engine actually assumes this is not possible. + For example, `propagate_transform` does not update children + of an `Entity` which **`GlobalTransform`** changed, + leading to unexpected behaviors. + + A `GlobalTransform` set by the user may also be blindly + overwritten by the propagation system. + + ## Solution + + - Remove `translation_mut` + - Explain to users that they shouldn't manually update the `GlobalTransform` + - Remove `global_vs_local.rs` example, since it misleads users + in believing that it is a valid use-case to manually update the + `GlobalTransform` + + --- + + ## Changelog + + - Remove `GlobalTransform::translation_mut` + + ## Migration Guide + + `GlobalTransform::translation_mut` has been removed without alternative, + if you were relying on this, update the `Transform` instead. If the given entity + had children or parent, you may need to remove its parent to make its transform + independent (in which case the new `Commands::set_parent_in_place` and + `Commands::remove_parent_in_place` may be of interest) + + Bevy may add in the future a way to toggle transform propagation on + an entity basis. + +commit fa40e2badb1dbd0ffa8a78ef9068e68abaf70493 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Tue Jan 10 18:41:50 2023 +0000 + + Fix a miscompilation with `#[derive(SystemParam)]` (#7105) + + # Objective + + - Fix #7103. + - The issue is caused because I forgot to add a where clause to a generated struct in #7056. + + ## Solution + + - Add the where clause. + +commit a2071783446e85db716db4bb0068b03444d3825a +Author: Tirth Patel +Date: Tue Jan 10 17:48:34 2023 +0000 + + Add wrapping_add to change_tick (#7146) + + # Objective + + Fixes #7140 + + + ## Solution + + As discussed in the issue, added wrapping_add + + --- + +commit d03c1a06874f95bba1127b9aa2fd7a4d0b3eb723 +Author: Boxy +Date: Tue Jan 10 17:25:45 2023 +0000 + + Ensure `Query` does not use the wrong `World` (#7150) + + `Query` relies on the `World` it stores being the same as the world used for creating the `QueryState` it stores. If they are not the same then everything is very unsound. This was not actually being checked anywhere, `Query::new` did not have a safety invariant or even an assertion that the `WorldId`'s are the same. + + This shouldn't have any user facing impact unless we have really messed up in bevy and have unsoundness elsewhere (in which case we would now get a panic instead of being unsound). + +commit aaaf357dbb352232810a02c7bbd0090109eaea53 +Author: zeroacez +Date: Tue Jan 10 17:25:44 2023 +0000 + + Added docs for ``.apply()``in basic usage of ``systemState`` (#7138) + + # Objective + + Fixes #5940 + + ## Solution + + Added the suggested comment. + + Co-authored-by: zeroacez <43633834+zeroacez@users.noreply.github.com> + +commit e4d54739e7539a45e9c47157ef3a6f27f0f32a5c +Author: Mike +Date: Tue Jan 10 17:07:27 2023 +0000 + + add link to tracy compatibility table (#7144) + + # Objective + + - Fixes https://github.com/bevyengine/bevy/issues/5200 + +commit 9adc8cdaf6d3ae9249654d80f44fc6b327f721ba +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Jan 9 22:20:10 2023 +0000 + + Add `Mut::reborrow` (#7114) + + # Objective + + - In some cases, you need a `Mut` pointer, but you only have a mutable reference to one. There is no easy way of converting `&'a mut Mut<'_, T>` -> `Mut<'a, T>` outside of the engine. + + ### Example (Before) + + ```rust + fn do_with_mut(val: Mut) { ... } + + for x: Mut in &mut query { + // The function expects a `Mut`, so `x` gets moved here. + do_with_mut(x); + // Error: use of moved value. + do_a_thing(&x); + } + ``` + + ## Solution + + - Add the function `reborrow`, which performs the mapping. This is analogous to `PtrMut::reborrow`. + + ### Example (After) + + ```rust + fn do_with_mut(val: Mut) { ... } + + for x: Mut in &mut query { + // We reborrow `x`, so the original does not get moved. + do_with_mut(x.reborrow()); + // Works fine. + do_a_thing(&x); + } + ``` + + --- + + ## Changelog + + - Added the method `reborrow` to `Mut`, `ResMut`, `NonSendMut`, and `MutUntyped`. + +commit 871c80c103f977425b28e3ae31e565785cffa4be +Author: Giacomo Stevanato +Date: Mon Jan 9 21:57:14 2023 +0000 + + Add `TypeRegistrationDeserializer` and remove `BorrowedStr` (#7094) + + # Objective + + This a follow-up to #6894, see https://github.com/bevyengine/bevy/pull/6894#discussion_r1045203113 + + The goal is to avoid cloning any string when getting a `&TypeRegistration` corresponding to a string which is being deserialized. As a bonus code duplication is also reduced. + + ## Solution + + The manual deserialization of a string and lookup into the type registry has been moved into a separate `TypeRegistrationDeserializer` type, which implements `DeserializeSeed` with a `Visitor` that accepts any string with `visit_str`, even ones that may not live longer than that function call. + `BorrowedStr` has been removed since it's no longer used. + + --- + + ## Changelog + + - The type `TypeRegistrationDeserializer` has been added, which simplifies getting a `&TypeRegistration` while deserializing a string. + +commit 9be47e3328b729e31b80ab9d23e5331fc7079bf8 +Author: François +Date: Mon Jan 9 21:43:30 2023 +0000 + + Fix overflow scaling for images (#7142) + + # Objective + + - Fixes #4057 + - Do not multiply position by scale factor + +commit 76a4695f334aed1504777686950452579363ebbb +Author: 2ne1ugly <47616772+2ne1ugly@users.noreply.github.com> +Date: Mon Jan 9 21:43:29 2023 +0000 + + Fix doc in `App::add_sub_app` (#7139) + + # Objective + + - Fix the name of function parameter name in docs + + ## Solution + + - Change `f` to `sub_app_runner` + + --- + + It confused me a bit when I was reading the docs in the autocomplete hint. + Hesitated about filing a PR since it's just a one single word change in the comment. + Is this the right process to change these docs? + +commit 0e9f80e00b513fd7cb17bf971a970d23f902bde4 +Author: 2ne1ugly <47616772+2ne1ugly@users.noreply.github.com> +Date: Mon Jan 9 21:43:27 2023 +0000 + + Implement `SparseSetIndex` for `WorldId` (#7125) + + # Objective + + - Fixes #7124 + + ## Solution + + - Add Hash Derive on `WorldId` + - Add `SparseSetIndex` impl + +commit 7df680bb0a2e3da35b27160b0e52b0e817c289a4 +Author: François +Date: Mon Jan 9 21:19:48 2023 +0000 + + add rust-version for MSRV and CI job to check (#6852) + + # Objective + + - Fixes #6777, fixes #2998, replaces #5518 + - Help avoid confusing error message when using an older version of Rust + + ## Solution + + - Add the `rust-version` field to `Cargo.toml` + - Add a CI job checking the MSRV + - Add the job to bors + +commit afe0a0650bdf907cf1826a9de20d4a728b9ef7f4 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Jan 9 20:56:06 2023 +0000 + + Relax `Sync` bound on `Local as ExclusiveSystemParam` (#7040) + + # Objective + + The type `Local` unnecessarily has the bound `T: Sync` when the local is used in an exclusive system. + + ## Solution + + Lift the bound. + + --- + + ## Changelog + + Removed the bound `T: Sync` from `Local` when used as an `ExclusiveSystemParam`. + +commit aaf384ae589a88ee2b842fd2050f68bf7e77c6df +Author: James Liu +Date: Mon Jan 9 20:40:34 2023 +0000 + + Panic on dropping NonSend in non-origin thread. (#6534) + + # Objective + + Fixes #3310. Fixes #6282. Fixes #6278. Fixes #3666. + + ## Solution + Split out `!Send` resources into `NonSendResources`. Add a `origin_thread_id` to all `!Send` Resources, check it on dropping `NonSendResourceData`, if there's a mismatch, panic. Moved all of the checks that `MainThreadValidator` would do into `NonSendResources` instead. + + All `!Send` resources now individually track which thread they were inserted from. This is validated against for every access, mutation, and drop that could be done against the value. + + A regression test using an altered version of the example from #3310 has been added. + + This is a stopgap solution for the current status quo. A full solution may involve fully removing `!Send` resources/components from `World`, which will likely require a much more thorough design on how to handle the existing in-engine and ecosystem use cases. + + This PR also introduces another breaking change: + + ```rust + use bevy_ecs::prelude::*; + + #[derive(Resource)] + struct Resource(u32); + + fn main() { + let mut world = World::new(); + world.insert_resource(Resource(1)); + world.insert_non_send_resource(Resource(2)); + let res = world.get_resource_mut::().unwrap(); + assert_eq!(res.0, 2); + } + ``` + + This code will run correctly on 0.9.1 but not with this PR, since NonSend resources and normal resources have become actual distinct concepts storage wise. + + ## Changelog + Changed: Fix soundness bug with `World: Send`. Dropping a `World` that contains a `!Send` resource on the wrong thread will now panic. + + ## Migration Guide + Normal resources and `NonSend` resources no longer share the same backing storage. If `R: Resource`, then `NonSend` and `Res` will return different instances from each other. If you are using both `Res` and `NonSend` (or their mutable variants), to fetch the same resources, it's strongly advised to use `Res`. + +commit 1b9c156479c60c2b791081f4b5d7db5edf38726b +Author: radiish +Date: Mon Jan 9 19:47:07 2023 +0000 + + reflect: add `insert` and `remove` methods to `List` (#7063) + + # Objective + + - Fixes #7061 + + ## Solution + + - Add and implement `insert` and `remove` methods for `List`. + + --- + + ## Changelog + + - Added `insert` and `remove` methods to `List`. + - Changed the `push` and `pop` methods on `List` to have default implementations. + + ## Migration Guide + + - Manual implementors of `List` need to implement the new methods `insert` and `remove` and + consider whether to use the new default implementation of `push` and `pop`. + + Co-authored-by: radiish + +commit bef9bc18449936a112b74d60395b46109cfefed9 +Author: James Liu +Date: Mon Jan 9 19:24:56 2023 +0000 + + Reduce branching in TrackedRenderPass (#7053) + + # Objective + Speed up the render phase for rendering. + + ## Solution + - Follow up #6988 and make the internals of atomic IDs `NonZeroU32`. This niches the `Option`s of the IDs in draw state, which reduces the size and branching behavior when evaluating for equality. + - Require `&RenderDevice` to get the device's `Limits` when initializing a `TrackedRenderPass` to preallocate the bind groups and vertex buffer state in `DrawState`, this removes the branch on needing to resize those `Vec`s. + + ## Performance + This produces a similar speed up akin to that of #6885. This shows an approximate 6% speed up in `main_opaque_pass_3d` on `many_foxes` (408.79 us -> 388us). This should be orthogonal to the gains seen there. + + ![image](https://user-images.githubusercontent.com/3137680/209906239-e430f026-63c2-4b95-957e-a2045b810d79.png) + + --- + + ## Changelog + Added: `RenderContext::begin_tracked_render_pass`. + Changed: `TrackedRenderPass` now requires a `&RenderDevice` on construction. + Removed: `bevy_render::render_phase::DrawState`. It was not usable in any form outside of `bevy_render`. + + ## Migration Guide + TODO + +commit d76b53bf4db552d505c4d319f5cf565579635002 +Author: Mike +Date: Mon Jan 9 19:24:54 2023 +0000 + + Separate Extract from Sub App Schedule (#7046) + + # Objective + + - This pulls out some of the changes to Plugin setup and sub apps from #6503 to make that PR easier to review. + - Separate the extract stage from running the sub app's schedule to allow for them to be run on separate threads in the future + - Fixes #6990 + + ## Solution + + - add a run method to `SubApp` that runs the schedule + - change the name of `sub_app_runner` to extract to make it clear that this function is only for extracting data between the main app and the sub app + - remove the extract stage from the sub app schedule so it can be run separately. This is done by adding a `setup` method to the `Plugin` trait that runs after all plugin build methods run. This is required to allow the extract stage to be removed from the schedule after all the plugins have added their systems to the stage. We will also need the setup method for pipelined rendering to setup the render thread. See https://github.com/bevyengine/bevy/blob/e3267965e15f14be18eec942dcaf16807144eb05/crates/bevy_render/src/pipelined_rendering.rs#L57-L98 + + ## Changelog + + - Separate SubApp Extract stage from running the sub app schedule. + + ## Migration Guide + + ### SubApp `runner` has conceptually been changed to an `extract` function. + + The `runner` no longer is in charge of running the sub app schedule. It's only concern is now moving data between the main world and the sub app. The `sub_app.app.schedule` is now run for you after the provided function is called. + + ```rust + // before + fn main() { + let sub_app = App::empty(); + sub_app.add_stage(MyStage, SystemStage::parallel()); + + App::new().add_sub_app(MySubApp, sub_app, move |main_world, sub_app| { + extract(app_world, render_app); + render_app.app.schedule.run(); + }); + } + + // after + fn main() { + let sub_app = App::empty(); + sub_app.add_stage(MyStage, SystemStage::parallel()); + + App::new().add_sub_app(MySubApp, sub_app, move |main_world, sub_app| { + extract(app_world, render_app); + // schedule is automatically called for you after extract is run + }); + } + ``` + +commit e94215c4c6d8d7fbd4632bf957d1abe1c2424999 +Author: DevinLeamy +Date: Mon Jan 9 19:24:52 2023 +0000 + + Gamepad events refactor (#6965) + + # Objective + + - Remove redundant gamepad events + - Simplify consuming gamepad events. + - Refactor: Separate handling of gamepad events into multiple systems. + + ## Solution + + - Removed `GamepadEventRaw`, and `GamepadEventType`. + - Added bespoke `GamepadConnectionEvent`, `GamepadAxisChangedEvent`, and `GamepadButtonChangedEvent`. + - Refactored `gamepad_event_system`. + - Added `gamepad_button_event_system`, `gamepad_axis_event_system`, and `gamepad_connection_system`, which update the `Input` and `Axis` resources using their corresponding event type. + + Gamepad events are now handled in their own systems and have their own types. + + This allows for querying for gamepad events without having to match on `GamepadEventType` and makes creating handlers for specific gamepad event types, like a `GamepadConnectionEvent` or `GamepadButtonChangedEvent` possible. + + We remove `GamepadEventRaw` by filtering the gamepad events, using `GamepadSettings`, _at the source_, in `bevy_gilrs`. This way we can create `GamepadEvent`s directly and avoid creating `GamepadEventRaw` which do not pass the user defined filters. + + We expose ordered `GamepadEvent`s and we can respond to individual gamepad event types. + + ## Migration Guide + + - Replace `GamepadEvent` and `GamepadEventRaw` types with their specific gamepad event type. + +commit fa15b319309c0e7fc66a8cf9394f34e7ae3f6cf9 +Author: Sebastian Meßmer +Date: Mon Jan 9 19:24:51 2023 +0000 + + Smooth Transition between Animations (#6922) + + # Objective + + - Fixes https://github.com/bevyengine/bevy/discussions/6338 + + This PR allows for smooth transitions between different animations. + + ## Solution + + - This PR uses very simple linear blending of animations. + - When starting a new animation, you can give it a duration, and throughout that duration, the previous and the new animation are being linearly blended, until only the new animation is running. + - I'm aware of https://github.com/bevyengine/rfcs/pull/49 and https://github.com/bevyengine/rfcs/pull/51, which are more complete solutions to this problem, but they seem still far from being implemented. Until they're ready, this PR allows for the most basic use case of blending, i.e. smoothly transitioning between different animations. + + ## Migration Guide + + - no bc breaking changes + +commit a41e869aa9e410b37d88d1c01a651b78c4ed3250 +Author: Yyee +Date: Mon Jan 9 19:05:30 2023 +0000 + + Expose symphonia features from rodio in bevy_audio and bevy (#6388) + + # Objective + Fix #6301 + + ## Solution + Add new features in `bevy_audio` to use `symphonia` sound format from `rodio` + Also add in `bevy` + +commit ee4e98f8a98e1f528065ddaa4a87394715a4c339 +Author: IceSentry +Date: Mon Jan 9 18:50:55 2023 +0000 + + Support storage buffers in derive `AsBindGroup` (#6129) + + # Objective + + - Storage buffers are useful and not currently supported by the `AsBindGroup` derive which means you need to expand the macro if you need a storage buffer + + ## Solution + + - Add a new `#[storage]` attribute to the derive `AsBindGroup` macro. + - Support and optional `read_only` parameter that defaults to false when not present. + - Support visibility parameters like the texture and sampler attributes. + + --- + + ## Changelog + + - Add a new `#[storage(index)]` attribute to the derive `AsBindGroup` macro. + + + Co-authored-by: IceSentry + +commit 16748b838793487b4251f4ab177ffda71ab128b5 +Author: Robert Swain +Date: Mon Jan 9 13:41:59 2023 +0000 + + bevy_render: Run calculate_bounds in the end-of-update exclusive systems (#7127) + + # Objective + + - Avoid slower than necessary first frame after spawning many entities due to them not having `Aabb`s and so being marked visible + - Avoids unnecessarily large system and VRAM allocations as a consequence + + ## Solution + + - I noticed when debugging the `many_cubes` stress test in Xcode that the `MeshUniform` binding was much larger than it needed to be. I realised that this was because initially, all mesh entities are marked as being visible because they don't have `Aabb`s because `calculate_bounds` is being run in `PostUpdate` and there are no system commands applications before executing the visibility check systems that need the `Aabb`s. The solution then is to run the `calculate_bounds` system just before the previous system commands are applied which is at the end of the `Update` stage. + +commit 1efdbb7e3ea2c7226385eb457123322430891b1d +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sat Jan 7 23:20:32 2023 +0000 + + Remove the `SystemParamState` trait and remove types like `ResState` (#6919) + + Spiritual successor to #5205. + Actual successor to #6865. + + # Objective + + Currently, system params are defined using three traits: `SystemParam`, `ReadOnlySystemParam`, `SystemParamState`. The behavior for each param is specified by the `SystemParamState` trait, while `SystemParam` simply defers to the state. + + Splitting the traits in this way makes it easier to implement within macros, but it increases the cognitive load. Worst of all, this approach requires each `MySystemParam` to have a public `MySystemParamState` type associated with it. + + ## Solution + + * Merge the trait `SystemParamState` into `SystemParam`. + * Remove all trivial `SystemParam` state types. + * `OptionNonSendMutState`: you will not be missed. + + --- + + - [x] Fix/resolve the remaining test failure. + + ## Changelog + + * Removed the trait `SystemParamState`, merging its functionality into `SystemParam`. + + ## Migration Guide + + **Note**: this should replace the migration guide for #6865. + This is relative to Bevy 0.9, not main. + + The traits `SystemParamState` and `SystemParamFetch` have been removed, and their functionality has been transferred to `SystemParam`. + + + ```rust + // Before (0.9) + impl SystemParam for MyParam<'_, '_> { + type State = MyParamState; + } + unsafe impl SystemParamState for MyParamState { + fn init(world: &mut World, system_meta: &mut SystemMeta) -> Self { ... } + } + unsafe impl<'w, 's> SystemParamFetch<'w, 's> for MyParamState { + type Item = MyParam<'w, 's>; + fn get_param(&mut self, ...) -> Self::Item; + } + unsafe impl ReadOnlySystemParamFetch for MyParamState { } + + // After (0.10) + unsafe impl SystemParam for MyParam<'_, '_> { + type State = MyParamState; + type Item<'w, 's> = MyParam<'w, 's>; + fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State { ... } + fn get_param<'w, 's>(state: &mut Self::State, ...) -> Self::Item<'w, 's>; + } + unsafe impl ReadOnlySystemParam for MyParam<'_, '_> { } + ``` + + The trait `ReadOnlySystemParamFetch` has been replaced with `ReadOnlySystemParam`. + + ```rust + // Before + unsafe impl ReadOnlySystemParamFetch for MyParamState {} + + // After + unsafe impl ReadOnlySystemParam for MyParam<'_, '_> {} + ``` + +commit 076e6f780cdc523d7b2e5bea03aa093227bceb1c +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Fri Jan 6 23:24:25 2023 +0000 + + Update an outdated example for `Mut::map_unchanged` (#7115) + + # Objective + + - The doctest for `Mut::map_unchanged` uses a fake function `set_if_not_equal` to demonstrate usage. + - Now that #6853 has been merged, we can use `Mut::set_if_neq` directly instead of mocking it. + +commit 41a5c30fb713a16c9b3f1a8eca10b0ff869a52ff +Author: 1e1001 +Date: Fri Jan 6 18:00:22 2023 +0000 + + add `Axis::devices` to get all the input devices (#5400) + + (github made me type out a message for the commit which looked like it was for the pr, sorry) + + # Objective + + - Add a way to get all of the input devices of an `Axis`, primarily useful for looping through them + + ## Solution + + - Adds `Axis::devices()` which returns a `FixedSizeIterator` + - Adds a (probably unneeded) `test_axis_devices` test because tests are cool. + + --- + + ## Changelog + + - Added `Axis::devices()` method + + ## Migration Guide + + Not a breaking change. + +commit ebc5cb352d781fd51f14e588ee8045c03f2d2f04 +Author: A-Walrus +Date: Fri Jan 6 17:46:44 2023 +0000 + + Fix doc comment "Turbo" -> "Extreme" (#7091) + + # Objective + Doc comment mentions turbo which is a sensitivity that doesn't exist. + + ## Solution + + Change the comment to "Extreme" which does exist + +commit 653c062ba325535c652f8e5bbe912052e5688ab4 +Author: iiYese +Date: Fri Jan 6 15:40:10 2023 +0000 + + Added missing details to SystemParam Local documentation. (#7106) + + # Objective + + `SystemParam` `Local`s documentation currently leaves out information that should be documented. + - What happens when multiple `SystemParam`s within the same system have the same `Local` type. + - What lifetime parameter is expected by `Local`. + + ## Solution + + - Added sentences to documentation to communicate this information. + - Renamed `Local` lifetimes in code to `'s` where they previously were not. Users can get complicated incorrect suggested fixes if they pass the wrong lifetime. Some instance of the code had `'w` indicating the expected lifetime might not have been known to those that wrote the code either. + + Co-authored-by: iiYese <83026177+iiYese@users.noreply.github.com> + +commit 3dd8b42f7287340913055db34db5606c1720b9d5 +Author: Rob Parrett +Date: Fri Jan 6 00:43:30 2023 +0000 + + Fix various typos (#7096) + + I stumbled across a typo in some docs. Fixed some more while I was in there. + +commit 329b71fa62c6fbe0211204e5726a5fb21637fa88 +Author: targrub +Date: Thu Jan 5 11:42:35 2023 +0000 + + Break `CorePlugin` into `TaskPoolPlugin`, `TypeRegistrationPlugin`, `FrameCountPlugin`. (#7083) + + # Objective + + - Fixes #7081. + + ## Solution + + - Moved functionality from kitchen sink plugin `CorePlugin` to separate plugins, `TaskPoolPlugin`, `TypeRegistrationPlugin`, `FrameCountPlugin`. `TaskPoolOptions` resource should now be used with `TaskPoolPlugin`. + + ## Changelog + + Minimal changes made (code kept in `bevy_core/lib.rs`). + + ## Migration Guide + + - `CorePlugin` broken into separate plugins. If not using `DefaultPlugins` or `MinimalPlugins` `PluginGroup`s, the replacement for `CorePlugin` is now to add `TaskPoolPlugin`, `TypeRegistrationPlugin`, and `FrameCountPlugin` to the app. + + ## Notes + + - Consistent with Bevy goal "modularity over deep integration" but the functionality of `TypeRegistrationPlugin` and `FrameCountPlugin` is weak (the code has to go somewhere, though!). + - No additional tests written. + +commit 85743ce49eda885854252bab59d57b0ddc9fe8a7 +Author: Matthias Schiffer +Date: Wed Jan 4 23:40:43 2023 +0000 + + asset: make HandleUntyped::id private (#7076) + + # Objective + + It is currently possible to break reference counting for assets by creating a strong `HandleUntyped` and then modifying the `id` field before dropping the handle. This should not be allowed. + + ## Solution + + Change the `id` field visibility to private and add a getter instead. The same change was previously done for `Handle` in #6176, but `HandleUntyped` was forgotten. + + --- + + ## Migration Guide + + - Instead of directly accessing the ID of a `HandleUntyped` as `handle.id`, use the new getter `handle.id()`. + +commit 4fff0ce8376317cd12307dd4dc622f996cb5df38 +Author: Anton Pushkarev +Date: Wed Jan 4 23:40:42 2023 +0000 + + Add a more familiar hex color entry (#7060) + + # Objective + + - When using `Color::hex` for the first time, I was confused by the fact that I can't specify colors using #, which is much more familiar. + - In the code editor (if there is support) there is a preview of the color, which is very convenient. + ![Снимок экрана от 2022-12-30 02-54-00](https://user-images.githubusercontent.com/69102503/209990973-f6fc3bc6-08f6-4e51-a9a9-1de8a675c82d.png) + + ## Solution + + - Allow you to enter colors like `#ff33f2` and use the `.strip_prefix` method to delete the `#` character. + +commit 8ca3d0462cbbde064933dc619e26d3a57485d14a +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Wed Jan 4 23:25:36 2023 +0000 + + Allow `SystemParam`s with private fields (#7056) + + # Objective + + - Fix #4200 + + Currently, `#[derive(SystemParam)]` publicly exposes each field type, which makes it impossible to encapsulate private fields. + + ## Solution + + Previously, the fields were leaked because they were used as an input generic type to the macro-generated `SystemParam::State` struct. That type has been changed to store its state in a field with a specific type, instead of a generic type. + + --- + + ## Changelog + + - Fixed a bug that caused `#[derive(SystemParam)]` to leak the types of private fields. + +commit 9ff111e24c4b5f8a0068d477e1e90963b963111a +Author: VitalyR +Date: Wed Jan 4 23:00:12 2023 +0000 + + fix cursor grab issue (#7010) + + # Objective + + - Set the cursor grab mode after the window is built, fix #7007, clean some conversion code. + + ## Solution + + - Set the cursor grab mode after the window is built. + +commit 717def2ccf140b767cb79f0bc7ec7ac2bfb8b884 +Author: Gino Valente +Date: Wed Jan 4 22:03:31 2023 +0000 + + bevy_reflect: Fix deserialization with readers (#6894) + + # Objective + + Fixes #6891 + + ## Solution + + Replaces deserializing map keys as `&str` with deserializing them as `String`. + + This bug seems to occur when using something like `File` or `BufReader` rather than bytes or a string directly (I only tested `File` and `BufReader` for `rmp-serde` and `serde_json`). This might be an issue with other `Read` impls as well (except `&[u8]` it seems). + + We already had passing tests for Message Pack but none that use a `File` or `BufReader`. This PR also adds or modifies tests to check for this in the future. + + This change was also based on [feedback](https://github.com/bevyengine/bevy/pull/4561#discussion_r957385136) I received in a previous PR. + + --- + + ## Changelog + + - Fix bug where scene deserialization using certain readers could fail (e.g. `BufReader`, `File`, etc.) + +commit 8d19045d2f8d12e51cf04a5254cdd47557bfa69d +Author: James Liu +Date: Wed Jan 4 20:43:39 2023 +0000 + + Parallelize forward kinematics animation systems (#6785) + + # Objective + Speed up animation by leveraging all threads in `ComputeTaskPool`. + + ## Solution + This PR parallelizes animation sampling across all threads. + + To ensure that this is safely done, all animation is predicated with an ancestor query to ensure that there is no conflicting `AnimationPlayer` above each animated hierarchy that may cause this to alias. + + Unlike the RFC, this does not add support for reflect based "animate anything", but only extends the existing `AnimationPlayer` to support high numbers of animated characters on screen at once. + + ## Performance + This cuts `many_foxes`'s frame time on my machine by a full millisecond, from 7.49ms to 6.5ms. (yellow is this PR, red is main). + ![image](https://user-images.githubusercontent.com/3137680/204219698-ffe0136c-5e9b-436f-b8d9-b23f0b8d7d36.png) + + --- + + ## Changelog + Changed: Animation sampling now runs fully multi-threaded using threads from `ComputeTaskPool`. + Changed: `AnimationPlayer` that are on a child or descendant of another entity with another player will no longer be run. + +commit df3673f679258598ba3e558f4c4400c769ee65a4 +Author: James O'Brien +Date: Wed Jan 4 19:58:09 2023 +0000 + + Add const to methods and const defaults to bevy_ui (#5542) + + # Objective + - Fixes #5529 + + ## Solution + - Add assosciated constants named DEFAULT to as many types as possible + - Add const to as many methods in bevy_ui as possible + + I have not applied the same treatment to the bundles in bevy_ui as it would require going into other bevy crates to implement const defaults for structs in bevy_text or relies on UiImage which calls HandleUntyped.typed() which isn't const safe. + + Alternatively the defaults could relatively easily be turned into a macro to regain some of the readability and conciseness at the cost of explicitness. + Such a macro that partially implements this exists as a crate here: [const-default](https://docs.rs/const-default/latest/const_default/derive.ConstDefault.html) but does not support enums. + + Let me know if there's anything I've missed or if I should push further into other crates. + + Co-authored-by: Carter Anderson + +commit 2d727afaf74fb653facfb9233d79b5516690a146 +Author: James Liu +Date: Wed Jan 4 01:13:30 2023 +0000 + + Flatten render commands (#6885) + + # Objective + Speed up the render phase of rendering. Simplify the trait structure for render commands. + + ## Solution + + - Merge `EntityPhaseItem` into `PhaseItem` (`EntityPhaseItem::entity` -> `PhaseItem::entity`) + - Merge `EntityRenderCommand` into `RenderCommand`. + - Add two associated types to `RenderCommand`: `RenderCommand::ViewWorldQuery` and `RenderCommand::WorldQuery`. + - Use the new associated types to construct two `QueryStates`s for `RenderCommandState`. + - Hoist any `SQuery` fetches in `EntityRenderCommand`s into the aformentioned two queries. Batch fetch them all at once. + + ## Performance + `main_opaque_pass_3d` is slightly faster on `many_foxes` (427.52us -> 401.15us) + + ![image](https://user-images.githubusercontent.com/3137680/206359804-9928b20a-7d92-41f8-bf7d-6e8c5cc802f0.png) + + The shadow pass node is also slightly faster (344.52 -> 338.24us) + + ![image](https://user-images.githubusercontent.com/3137680/206359977-1212198d-f933-49a0-80f1-62ff88eb5727.png) + + ## Future Work + + - Can we hoist the view level queries out of the core loop? + + --- + + ## Changelog + Added: `PhaseItem::entity` + Added: `RenderCommand::ViewWorldQuery` associated type. + Added: `RenderCommand::ItemorldQuery` associated type. + Added: `Draw::prepare` optional trait function. + Removed: `EntityPhaseItem` trait + + ## Migration Guide + TODO + +commit f866d72f150fccb6d4aa5b96688d664cc401517c +Author: Gino Valente +Date: Tue Jan 3 22:18:21 2023 +0000 + + Fix: CI `bench-check` command (#7077) + + # Objective + + I noticed that running the following command didn't actually do anything: + + ``` + cargo run -p ci -- bench-check + ``` + + ## Solution + + Made it so that running `cargo run -p ci -- bench-check` actually runs a compile check on the `benches` directory. + +commit b44b606d29f7bea22e725452af41944f6fc8d630 +Author: Robert Swain +Date: Mon Jan 2 22:07:33 2023 +0000 + + bevy_pbr: Avoid copying structs and using registers in shaders (#7069) + + # Objective + + - The #7064 PR had poor performance on an M1 Max in MacOS due to significant overuse of registers resulting in 'register spilling' where data that would normally be stored in registers on the GPU is instead stored in VRAM. The latency to read from/write to VRAM instead of registers incurs a significant performance penalty. + - Use of registers is a limiting factor in shader performance. Assignment of a struct from memory to a local variable can incur copies. Passing a variable that has struct type as an argument to a function can also incur copies. As such, these two cases can incur increased register usage and decreased performance. + + ## Solution + + - Remove/avoid a number of assignments of light struct type data to local variables. + - Remove/avoid a number of passing light struct type variables/data as value arguments to shader functions. + +commit b833bdab17a74d68c74862564d31fa986efd1ec5 +Author: Kurt Kühnert +Date: Mon Jan 2 21:39:54 2023 +0000 + + Allow to reuse the same RenderPass for multiple RenderPhases (#7043) + + # Objective + + - The recently merged PR #7013 does not allow multiple `RenderPhase`s to share the same `RenderPass`. + - Due to the introduced overhead we want to minimize the number of `RenderPass`es recorded during each frame. + + ## Solution + + - Take a constructed `TrackedRenderPass` instead of a `RenderPassDiscriptor` as a parameter to the `RenderPhase::render` method. + + --- + + ## Changelog + + To enable multiple `RenderPhases` to share the same `TrackedRenderPass`, + the `RenderPhase::render` signature has changed. + + ```rust + pub fn render<'w>( + &self, + render_pass: &mut TrackedRenderPass<'w>, + world: &'w World, + view: Entity) + ``` + + + Co-authored-by: Kurt Kühnert <51823519+kurtkuehnert@users.noreply.github.com> + +commit a5b1c46d5bfb64113ba273c6cc803a2abecdafb4 +Author: James Liu +Date: Mon Jan 2 21:25:04 2023 +0000 + + Extend EntityLocation with TableId and TableRow (#6681) + + # Objective + `Query::get` and other random access methods require looking up `EntityLocation` for every provided entity, then always looking up the `Archetype` to get the table ID and table row. This requires 4 total random fetches from memory: the `Entities` lookup, the `Archetype` lookup, the table row lookup, and the final fetch from table/sparse sets. If `EntityLocation` contains the table ID and table row, only the `Entities` lookup and the final storage fetch are required. + + ## Solution + Add `TableId` and table row to `EntityLocation`. Ensure it's updated whenever entities are moved around. To ensure `EntityMeta` does not grow bigger, both `TableId` and `ArchetypeId` have been shrunk to u32, and the archetype index and table row are stored as u32s instead of as usizes. This should shrink `EntityMeta` by 4 bytes, from 24 to 20 bytes, as there is no padding anymore due to the change in alignment. + + This idea was partially concocted by @BoxyUwU. + + ## Performance + This should restore the `Query::get` "gains" lost to #6625 that were introduced in #4800 without being unsound, and also incorporates some of the memory usage reductions seen in #3678. + + This also removes the same lookups during add/remove/spawn commands, so there may be a bit of a speedup in commands and `Entity{Ref,Mut}`. + + --- + + ## Changelog + Added: `EntityLocation::table_id` + Added: `EntityLocation::table_row`. + Changed: `World`s can now only hold a maximum of 232- 1 archetypes. + Changed: `World`s can now only hold a maximum of 232 - 1 tables. + + ## Migration Guide + + A `World` can only hold a maximum of 232 - 1 archetypes and tables now. If your use case requires more than this, please file an issue explaining your use case. + +commit f8a229b0c9522505bac48f036447ab6675acc4a4 +Author: Gino Valente +Date: Mon Jan 2 21:07:33 2023 +0000 + + bevy_reflect: Add compile fail tests for bevy_reflect (#7041) + + # Objective + + There isn't really a way to test that code using bevy_reflect compiles or doesn't compile for certain scenarios. This would be especially useful for macro-centric PRs like #6511 and #6042. + + ## Solution + + Using `bevy_ecs_compile_fail_tests` as reference, added the `bevy_reflect_compile_fail_tests` crate. + + Currently, this crate contains a very simple test case. This is so that we can get the basic foundation of this crate agreed upon and merged so that more tests can be added by other PRs. + + ### Open Questions + + - [x] Should this be added to CI? (Answer: Yes) + + --- + + ## Changelog + + - Added the `bevy_reflect_compile_fail_tests` crate for testing compilation errors + +commit 290d6363b8efd226c92ab5c03ac3a0953b5cda14 +Author: l1npengtul +Date: Mon Jan 2 20:49:43 2023 +0000 + + add system information plugin and update relevant examples (#5911) + + # Objective + Solve #5464 + + ## Solution + Adds a `SystemInformationDiagnosticsPlugin` to add diagnostics. + + Adds `Cargo.toml` flags to fix building on different platforms. + + --- + + ## Changelog + + Adds `sysinfo` crate to `bevy-diagnostics`. + + Changes in import order are due to clippy. + + Co-authored-by: l1npengtul <35755164+l1npengtul@users.noreply.github.com> + Co-authored-by: IceSentry + +commit b027d402e29d7d4f26062051161bc2187f168e80 +Author: ZoOL +Date: Thu Dec 29 23:45:07 2022 +0000 + + Update Box vertices comment (#7055) + + Old comment is Z-up , Fix comment for bevy Y-up + + # Objective + + - Update Box vertices comment for bevy Y-up + + ## Solution + + - Update comment for Y-up + + --- + + ## Changelog + + None + + ## Migration Guide + + None + +commit d2963267ba632a1b845aa843370f170f85633b13 +Author: figsoda +Date: Thu Dec 29 21:37:27 2022 +0000 + + improve nix docs (#7044) + + # Objective + + `xlibsWrapper` is being deprecated: https://github.com/NixOS/nixpkgs/issues/194054, this pr removes the deprecated xlibsWrapper and makes a couple more improvements + + ## Solution + + - rename NixOS to Nix since this is not specific to NixOS + - remove usage of `xlibsWrapper` + - add instructions for nix flakes with `nix develop` + - add example of a packaged bevy program in nixpkgs + - minor cosmetic/grammatical changes + +commit 61e027e8a8e43098085322f89fc46bdcaf602992 +Author: François +Date: Wed Dec 28 20:07:35 2022 +0000 + + Shadow render phase - pass the correct view entity (#7048) + + # Objective + + - Fixes #7047 + + ## Solution + + - Pass the correct view entity + +commit 2665299d1c50bb0411b61a8c524579bd7b4243ad +Author: Predko Silvestr +Date: Wed Dec 28 17:09:35 2022 +0000 + + Use ```bevy``` with default features in iOS example (#7042) + + # Objective + + I am new to Bevy. And during my development, I noticed that the `iOS` example doesn't work. + Example panics with next message: ```panicked at 'Resource requested by bevy_ui::widget::text::text_system does not exist: bevy_asset::assets::Assets```. + + I have asked for help in a `discord` iOS chat and there I receive a recommendation that it is possible that some bevy features missing. + + ## Solution + + So, I used ```bevy``` with default features. + +commit 09c64ffe9fd8d52d097d84a349c5d4e67eb994f0 +Author: Jinlei Li +Date: Tue Dec 27 16:27:55 2022 +0000 + + Remove redundant bitwise OR `TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` (#7033) + + # Objective + + `TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` was already included in `adapter.features()` on non-wasm target, and since it is the default value for `WgpuSettings.features`, the subsequent code will also combine into this feature: + https://github.com/bevyengine/bevy/blob/b6066c30b6cfa7bffa598d45706dbe6e46ad24fc/crates/bevy_render/src/renderer/mod.rs#L155-L156 + +commit 0ddaa7e83ad0f8de7f011319d50114cb8011e5d2 +Author: Nile +Date: Tue Dec 27 16:05:16 2022 +0000 + + Round out the untyped api s (#7009) + + # Objective + + Bevy uses custom `Ptr` types so the rust borrow checker can help ensure lifetimes are correct, even when types aren't known. However, these types don't benefit from the automatic lifetime coercion regular rust references enjoy + + ## Solution + + Add a couple methods to Ptr, PtrMut, and MutUntyped to allow for easy usage of these types in more complex scenarios. + + ## Changelog + + - Added `as_mut` and `as_ref` methods to `MutUntyped`. + - Added `shrink` and `as_ref` methods to `PtrMut`. + + ## Migration Guide + + - `MutUntyped::into_inner` now marks things as changed. + +commit ca85f6c9030157fa70488466f4880e6659a070aa +Author: Kurt Kühnert +Date: Tue Dec 27 03:29:59 2022 +0000 + + Extract common RenderPhase code into render method (#7013) + + # Objective + + All `RenderPhases` follow the same render procedure. + The same code is duplicated multiple times across the codebase. + + ## Solution + + I simply extracted this code into a method on the `RenderPhase`. + This avoids code duplication and makes setting up new `RenderPhases` easier. + + --- + + ## Changelog + + ### Changed + + You can now set up the rendering code of a `RenderPhase` directly using the `RenderPhase::render` method, instead of implementing it manually in your render graph node. + +commit 5566d73d9e49be09f8e85b546b8102b0841ae1c0 +Author: Aceeri +Date: Tue Dec 27 00:34:06 2022 +0000 + + Nicer usage for scene viewer (#7035) + + # Objective + Scene viewer mouse sensitivity/cursor usage isn't the best it could be atm, so just adding some quick, maybe opinionated, tweaks to make it feel more at home in usage. + + ## Solution + - Mouse delta shouldn't be affected by delta time, it should be more expected that if I move my mouse 1 inch to the right that it should move the in game camera/whatever is controlled the same regardless of FPS. + - Uses a magic number of 180.0 for a nice default sensitivity, modeled after Valorant's default sensitivity. + - Cursor now gets locked/hidden when rotating the camera to give it more of the effect that you are grabbing the camera. + +commit 741a91ed461d0193c37c13c00c1e86fa78580d3f +Author: Jinlei Li +Date: Mon Dec 26 19:47:01 2022 +0000 + + Replace `WgpuAdapterInfo` with `RenderAdapterInfo` in the documentation. (#7036) + + # Objective + + Fixes #6598 + In addition, macOS can also support GL backends through ANGLE. + +commit 4ca19ac4d32bc74ab67ae0f3545c005b398cad23 +Author: aktaboot <120214979+aktaboot@users.noreply.github.com> +Date: Mon Dec 26 16:52:17 2022 +0000 + + Update linux_dependencies.md (#7021) + + fixes alsalib dependency for NixOS + +commit f1a21db250bf6923d949cc74e47d209290851ebf +Author: François +Date: Mon Dec 26 16:39:17 2022 +0000 + + don't error when sending HierarchyEvents when Event type not registered (#7031) + + # Objective + + - Loading a gltf files prints many errors + ``` + ERROR bevy_ecs::world: Unable to send event `bevy_hierarchy::events::HierarchyEvent` + Event must be added to the app with `add_event()` + https://docs.rs/bevy/*/bevy/app/struct.App.html#method.add_event + ``` + - Loading a gltf file create a world for a scene where events are not registered. Executing hierarchy commands on that world should not print error + + ## Solution + + - Revert part of #6921 + - don't use `world.send_event` / `world.send_event_batch` from commands + +commit 7763b5ec7410def0539b95b5176f897eb6aac8c0 +Author: IceSentry +Date: Mon Dec 26 15:16:46 2022 +0000 + + log system info on startup (#5454) + + # Objective + + - We already log the adapter info on startup when bevy_render is present. It would be nice to have more info about the system to be able to ask users to submit it in bug reports + + ## Solution + + - Use the `sysinfo` crate to get all the information + - I made sure it _only_ gets the required informations to avoid unnecessary system request + - Add a system that logs this on startup + - This system is currently in `bevy_diagnostics` because I didn't really know where to put it. + + Here's an example log from my system: + ```log + INFO bevy_diagnostic: SystemInformation { os: "Windows 10 Pro", kernel: "19044", cpu: "AMD Ryzen 7 5800X 8-Core Processor", core_count: "8", memory: "34282242 KB" } + ``` + --- + + ## Changelog + + - Added a new default log when starting a bevy app that logs the system information + +commit b6066c30b6cfa7bffa598d45706dbe6e46ad24fc +Author: Jinlei Li +Date: Sun Dec 25 05:06:03 2022 +0000 + + Fix ndk-macro link (#7027) + + # Objective + + [ndk-glue](https://github.com/rust-mobile/ndk-glue) has been split from `android-ndk-rs` into a separate repository. + +commit b8a9933d463ae6a6dd1deb80097d718f74328c87 +Author: Nicola Papale +Date: Sun Dec 25 00:51:20 2022 +0000 + + Add a reparented_to method to `GlobalTransform` (#7020) + + # Objective + + It is often necessary to update an entity's parent while keeping its GlobalTransform static. Currently it is cumbersome and error-prone (two questions in the discord `#help` channel in the past week) + + - Part 1 of #5475 + - Part 2: #7024. + + ## Solution + + - Add a `reparented_to` method to `GlobalTransform` + + --- + + ## Changelog + + - Add a `reparented_to` method to `GlobalTransform` + +commit 48b4a45d82dfb0e4bf31575c0f6282b596ca11ad +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sun Dec 25 00:51:19 2022 +0000 + + Add a const `PipeSystem` constructor (#7019) + + # Objective + + Fix #5914. + + `PipeSystem` cannot be constructed in `const` contexts. + + ## Solution + + Add a const `PipeSystem::new` function. + +commit a91f89db733ae75dc9d48ea29c5c54cefe0a5893 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sun Dec 25 00:51:17 2022 +0000 + + Add a basic example for system ordering (#7017) + + # Objective + + Fix #5653. + + ## Solution + + - Add an example of how systems can be ordered from within a stage. + - Update some docs from before #4224 + +commit 65d390163f9850c53e934e94aa9d6aedfbd10687 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sun Dec 25 00:51:16 2022 +0000 + + Add a trait for commands that run for a given `Entity` (#7015) + + # Objective + + Resolve #6156. + + The most common type of command is one that runs for a single entity. Built-in commands like this can be ergonomically added to the command queue using the `EntityCommands` struct. However, adding custom entity commands to the queue is quite cumbersome. You must first spawn an entity, store its ID in a local, then construct a command using that ID and add it to the queue. This prevents method chaining, which is the main benefit of using `EntityCommands`. + + ### Example (before) + + ```rust + struct MyCustomCommand(Entity); + + impl Command for MyCustomCommand { ... } + + let id = commands.spawn((...)).id(); + commmands.add(MyCustomCommand(id)); + ``` + + ## Solution + + Add the `EntityCommand` trait, which allows directly adding per-entity commands to the `EntityCommands` struct. + + ### Example (after) + + ```rust + struct MyCustomCommand; + + impl EntityCommand for MyCustomCommand { ... } + + commands.spawn((...)).add(MyCustomCommand); + ``` + --- + + ## Changelog + + - Added the trait `EntityCommand`. This is a counterpart of `Command` for types that execute code for a single entity. + + ## Future Work + + If we feel its necessary, we can simplify built-in commands (such as `Despawn`) to use this trait. + +commit 83b602a77c10f9212984cdd00fc1cc7d7955a677 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sun Dec 25 00:51:14 2022 +0000 + + Relax `Sync` bound on anonymous `Command`s (#7014) + + # Objective + + Any closure with the signature `FnOnce(&mut World)` implicitly implements the trait `Command` due to a blanket implementation. However, this implementation unnecessarily has the `Sync` bound, which limits the types that can be used. + + ## Solution + + Remove the bound. + + --- + + ## Changelog + + - `Command` closures no longer need to implement the marker trait `std::marker::Sync`. + +commit b3d59060db6bbe7c63b227510fd58460e1790dd9 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sun Dec 25 00:39:31 2022 +0000 + + Fix unsoundness for `propagate_recursive` (#7003) + + # Objective + + Fix #6983. + + ## Solution + + Mark the function `propagate_recursive` as unsafe, and specify the safety invariants through doc comments. + +commit 8ad9a7c7c43f4863ddf41d538855f9e35fccc690 +Author: Aceeri +Date: Sun Dec 25 00:39:30 2022 +0000 + + Rename camera "priority" to "order" (#6908) + + # Objective + The documentation for camera priority is very confusing at the moment, it requires a bit of "double negative" kind of thinking. + + # Solution + Flipping the wording on the documentation to reflect more common usecases like having an overlay camera and also renaming it to "order", since priority implies that it will override the other camera rather than have both run. + +commit a0448eca2f10867a8f31a7395b70b6076cef2aa9 +Author: ickk +Date: Sun Dec 25 00:39:29 2022 +0000 + + enum `Visibility` component (#6320) + + Consolidation of all the feedback about #6271 as well as the addition of an "unconditionally visible" mode. + + # Objective + + The current implementation of the `Visibility` struct simply wraps a boolean.. which seems like an odd pattern when rust has such nice enums that allow for more expression using pattern-matching. + + Additionally as it stands Bevy only has two settings for visibility of an entity: + - "unconditionally hidden" `Visibility { is_visible: false }`, + - "inherit visibility from parent" `Visibility { is_visible: true }` + where a root level entity set to "inherit" is visible. + + Note that given the behaviour, the current naming of the inner field is a little deceptive or unclear. + + Using an enum for `Visibility` opens the door for adding an extra behaviour mode. This PR adds a new "unconditionally visible" mode, which causes an entity to be visible even if its Parent entity is hidden. There should not really be any performance cost to the addition of this new mode. + + -- + The recently added `toggle` method is removed in this PR, as its semantics could be confusing with 3 variants. + + ## Solution + + Change the Visibility component into + ```rust + enum Visibility { + Hidden, // unconditionally hidden + Visible, // unconditionally visible + Inherited, // inherit visibility from parent + } + ``` + + --- + + ## Changelog + + ### Changed + + `Visibility` is now an enum + + ## Migration Guide + + - evaluation of the `visibility.is_visible` field should now check for `visibility == Visibility::Inherited`. + - setting the `visibility.is_visible` field should now directly set the value: `*visibility = Visibility::Inherited`. + - usage of `Visibility::VISIBLE` or `Visibility::INVISIBLE` should now use `Visibility::Inherited` or `Visibility::Hidden` respectively. + - `ComputedVisibility::INVISIBLE` and `SpatialBundle::VISIBLE_IDENTITY` have been renamed to `ComputedVisibility::HIDDEN` and `SpatialBundle::INHERITED_IDENTITY` respectively. + + + + + + + Co-authored-by: Carter Anderson + +commit 9717204aefa5d3a6e8dcbeb3a9d9c251d3b467f2 +Author: Aceeri +Date: Sun Dec 25 00:39:27 2022 +0000 + + Rework manual event iterator so we can actually name the type (#5735) + + # Objective + - Be able to name the type that `ManualEventReader::iter/iter_with_id` returns and `EventReader::iter/iter_with_id` by proxy. + Currently for the purpose of https://github.com/bevyengine/bevy/pull/5719 + + ## Solution + - Create a custom `Iterator` type. + +commit 965ebeff598f2a9fdb9479aefa8abbab76f6d767 +Author: Kurt Kühnert +Date: Sun Dec 25 00:23:15 2022 +0000 + + Replace UUID based IDs with a atomic-counted ones (#6988) + + # Objective + + - alternative to #2895 + - as mentioned in #2535 the uuid based ids in the render module should be replaced with atomic-counted ones + + ## Solution + - instead of generating a random UUID for each render resource, this implementation increases an atomic counter + - this might be replaced by the ids of wgpu if they expose them directly in the future + + - I have not benchmarked this solution yet, but this should be slightly faster in theory. + - Bevymark does not seem to be affected much by this change, which is to be expected. + + - Nothing of our API has changed, other than that the IDs have lost their IMO rather insignificant documentation. + - Maybe the documentation could be added back into the macro, but this would complicate the code. + +commit d3d635b64fe7042ffda0152c44a526aabb1ee2a5 +Author: AxiomaticSemantics +Date: Sun Dec 25 00:23:14 2022 +0000 + + Constify SpritePipelineKey implementation. (#6976) + + # Objective + + - Describe the objective or issue this PR addresses. + SpritePipelineKey could use more constification. + + ## Solution + Constify SpritePipelineKey implementation. + + ## Changelog + + + Co-authored-by: AxiomaticSemantics <117950168+AxiomaticSemantics@users.noreply.github.com> + +commit c7791ad9b376c5d5ae276ca5d2e8b52d91fd2ffe +Author: Taras Palczynski III +Date: Sun Dec 25 00:23:13 2022 +0000 + + Organized scene_viewer into plugins for reuse and organization (#6936) + + # Objective + + This PR reorganizes majority of the scene viewer example into a module of plugins which then allows reuse of functionality among new or existing examples. In addition, this enables the scene viewer to be more succinct and showcase the distinct cases of camera control and scene control. + + This work is to support future work in organization and future examples. A more complicated 3D scene example has been requested by the community (#6551) which requests functionality currently included in scene_viewer, but previously inaccessible. The future example can now just utilize the two plugins created here. The existing example [animated_fox example] can utilize the scene creation and animation control functionality of `SceneViewerPlugin`. + + ## Solution + + - Created a `scene_viewer` module inside the `tools` example folder. + - Created two plugins: `SceneViewerPlugin` (gltf scene loading, animation control, camera tracking control, light control) and `CameraControllerPlugin` (controllable camera). + - Original `scene_viewer.rs` moved to `scene_viewer/main.rs` and now utilizes the two plugins. + +commit b39817a27c0ac39bdc718a87f324f60799810c6d +Author: ira +Date: Sun Dec 25 00:23:12 2022 +0000 + + Add `add_child`, `set_parent` and `remove_parent` to `EntityMut` (#6926) + + # Objective + Align the hierarchy API between `EntityCommands` and `EntityMut`. + + Added missing methods to `EntityMut`. + Replaced the duplicate `Command` implementations with the ones on `EntityMut` (e.g. The `AddChild` command is now just `world.entity_mut(..).add_child(..)`) + + Fixed `update_old_parents` not sending `ChildAdded` events. + + This PR does not add `add_children` to `EntityMut` as I would like to remove it from `EntityCommands` instead in #6942. + + ## Changelog + * Added `add_child`, `set_parent` and `remove_parent` to `EntityMut` + * Fixed missing `ChildAdded` events + + + Co-authored-by: devil-ira + +commit 0d98327ce76f2658e64e50762da8ef027fcc1074 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sun Dec 25 00:06:23 2022 +0000 + + Support `SystemParam` types with const generics (#7001) + + # Objective + + * Currently, the `SystemParam` derive does not support types with const generic parameters. + * If you try to use const generics, the error message is cryptic and unhelpful. + * Continuation of the work started in #6867 and #6957. + + ## Solution + + Allow const generic parameters to be used with `#[derive(SystemParam)]`. + +commit fa2b5f2b360fb832e98eb84150a9b95860f2ecc5 +Author: JoJoJet +Date: Sun Dec 25 00:06:22 2022 +0000 + + Add documentation to `ParamSet` (#6998) + + # Objective + + Fixes #4729. + Continuation of #4854. + + ## Solution + + Add documentation to `ParamSet` and its methods. Includes examples suggested by community members in the original PR. + + + Co-authored-by: Nanox19435 <50684926+Nanox19435@users.noreply.github.com> + Co-authored-by: JoJoJet <21144246+JoJoJet@users.noreply.github.com> + +commit ca878304507b790cedf4301b879c47f2047788bf +Author: Thierry Berger +Date: Sat Dec 24 23:43:41 2022 +0000 + + #4231: panic when App::run() is called from Plugin::build() (#4241) + + # Objective + + Fixes #4231. + + ## Solution + + This PR implements the solution suggested by @bjorn3 : Use an internal property within `App` to detect `App::run()` calls from `Plugin::build()`. + + --- + + ## Changelog + + - panic when App::run() is called from Plugin::build() + +commit 1aeaafa7c455163d1f2ef59d9404a24a00c5b138 +Author: Caio César Oliveira <54439337+oCaioOliveira@users.noreply.github.com> +Date: Thu Dec 22 19:49:55 2022 +0000 + + Add "how to adopt pull requests" section (#6895) + + # Objective + + - Add "how to adopt pull requests" section. + - Fixes #5539 + + ## Solution + + - Add "how to adopt pull requests" section in [Contributing.md](https://github.com/bevyengine/bevy/blob/main/CONTRIBUTING.md). + + Co-authored-by: Erick + +commit 2938792c7d77ef2777909ac485b0042eb9fe634b +Author: Rob Parrett +Date: Wed Dec 21 02:15:53 2022 +0000 + + Upgrade to Taffy 0.2 (#6743) + + # Objective + + Upgrade to Taffy 0.2 + + ## Solution + + Do it + + ## Changelog + + Upgraded to Taffy 0.2, improving UI layout performance significantly and adding the flexbox `gap` property and `AlignContent::SpaceEvenly`. + + ## Notes + + `many_buttons` is 8% faster! speed improvements for more highly nested UIs will be much more dramatic. Great work, Team Taffy. + +commit 025996b18c741e81db708c62b89cf5505d2a27dc +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Wed Dec 21 01:54:10 2022 +0000 + + Lift the 16-field limit from the `SystemParam` derive (#6867) + + # Objective + + * The `SystemParam` derive internally uses tuples, which means it is constrained by the 16-field limit on `all_tuples`. + * The error message if you exceed this limit is abysmal. + * Supercedes #5965 -- this does the same thing, but is simpler. + + ## Solution + + If any tuples have more than 16 fields, they are folded into tuples of tuples until they are under the 16-field limit. + +commit 0363e0b32a066590dabc55900bf0bed44d2d1ae2 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Tue Dec 20 23:45:44 2022 +0000 + + Support tuple structs with `#[derive(SystemParam)]` (#6957) + + # Objective + + Currently, only named structs can be used with the `SystemParam` derive macro. + + ## Solution + + Remove the restriction. Tuple structs and unit structs are now supported. + + --- + + ## Changelog + + + Added support for tuple structs and unit structs to the `SystemParam` derive macro. + +commit cf480d939a50102cf3b12e03621b2135da01e2bc +Author: Nick Fagerlund +Date: Tue Dec 20 23:45:43 2022 +0000 + + Fix suppression of all console logs when `trace_tracy` is enabled (#6955) + + # Objective + + Fixes #6862 (oh hey good catch @alice-i-cecile) + + Bevy was failing to print events from `info!()` and friends to the console if the `trace_tracy` feature was enabled. It shouldn't be doing that. + + ## Solution + + The problem was this per-layer filter that was added in #4320 to suppress a noisy per-frame event (which Tracy requires in order to properly close out a frame): + + - The problem event's target was `"bevy_render::renderer"`, not `"tracy"`. - So, the filter wasn't specifically targeting the noisy event. + - Without a default, `tracing_subscriber::filter::Targets` will remove _everything_ that doesn't match an explicit target rule. - So, the filter _was_ silencing the noisy event, along with everything else. + + This PR changes that filter to do what was probably intended in #4320: suppress ~any events more verbose than `ERROR` from `bevy_render::renderer`~ the one problematically noisy event, but allow anything else that already made it through the top-level filter_layer. + + Also, adds a comment to clarify the intent of that filter, since it's otherwise a bit opaque and required some research. + + --- + + ## Changelog + + Fixed a bug that hid console log messages when the `trace_tracy` feature was enabled. + +commit 150a3572bd4cc80f7c0efe5a83949d16676af9a2 +Author: Benoît Vermont +Date: Tue Dec 20 23:32:04 2022 +0000 + + Fix UiCameraConfig doc (link to the Camera page) (#6969) + + The Camera link in the UiCameraConfig was not rendered properly by the documentation. + + # Objective + + - In the UiCameraConfig page (https://docs.rs/bevy/latest/bevy/prelude/struct.UiCameraConfig.html), a link to the Camera page (https://docs.rs/bevy/latest/bevy/render/camera/struct.Camera.html) is broken. + + ## Solution + + - It seems that when using URL fragment specifiers, backtick should not be used. It might be an issue of rust itself. Replacing the URL fragment specifier `[`Camera`]: bevy_render::camera::Camera` with `[Camera]: bevy_render::camera::Camera` solves this. + +commit c38659ddea832dabf65691cdb64f01279acdc411 +Author: 0xc0001a2040 +Date: Tue Dec 20 23:18:13 2022 +0000 + + Add fmt::Pointer impl for bevy_ptr::{Ptr, PtrMut, OwnedPtr} (#6980) + + # Objective + + - `bevy_ptr::{Ptr, PtrMut, OwnedPtr}` wrap raw pointers and should be printable using pointer formatting. + + ## Solution + + - Add a `core::fmt::Pointer` impl for `Ptr`, `PtrMut` and `OwnedPtr` based on the wrapped `NonNull` pointer. + + --- + + ## Changelog + + - Added a `core::fmt::Pointer` impl to `Ptr`, `PtrMut` and `OwnedPtr`. + + Co-authored-by: MrGunflame + +commit 85455802144232726f7e58746865d4838afaf91b +Author: ickshonpe +Date: Tue Dec 20 16:44:12 2022 +0000 + + text aspect ratio bug fix (#6825) + + ## Objective + + Bevy UI uses a `MeasureFunc` that preserves the aspect ratio of text, not just images. This means that the extent of flex-items containing text may be calculated incorrectly depending on the ratio of the text size compared to the size of its containing node. + + Fixes #6748 + Related to #6724 + + with Bevy 0.9: + + ![Capture_cols_0 9](https://user-images.githubusercontent.com/27962798/205435999-386d3400-fe9b-475a-aab1-18e61c4c074f.PNG) + + with this PR (accurately matching the behavior of Flexbox): + + ![Capture_fixed](https://user-images.githubusercontent.com/27962798/205436005-6bafbcc2-cd87-4eb7-b5c6-9dbcb30fc795.PNG) + + ## Solution + Only perform the aspect ratio calculations if the uinode contains an image. + + ## Changelog + * Added a field `preserve_aspect_ratio` to `CalculatedSize` + * The `MeasureFunc` only preserves the aspect ratio when `preserve_aspect_ratio` is true. + * `update_image_calculated_size_system` sets `preserve_aspect_ratio` to true for nodes with images. + +commit a5106c841fdfd922841507ed815eb6fc21dfca72 +Author: Nicola Papale +Date: Tue Dec 20 16:17:14 2022 +0000 + + Remove needless manual default impl of ButtonBundle (#6970) + + # Objective + + - Remove a manual impl block for something that can be derived + - Correct a misleading doc comment. + +commit 15b19b930cc6d5f5a479e165264bc5e1393bd4cc +Author: ira +Date: Tue Dec 20 16:17:11 2022 +0000 + + Move 'startup' Resource `WgpuSettings` into the `RenderPlugin` (#6946) + + # Objective + The `WgpuSettings` resource is only used during plugin build. Move it into the `RenderPlugin` struct. + + Changing these settings requires re-initializing the render context, which is currently not supported. + If it is supported in the future it should probably be more explicit than changing a field on a resource, maybe something similar to the `CreateWindow` event. + + ## Migration Guide + ```rust + // Before (0.9) + App::new() + .insert_resource(WgpuSettings { .. }) + .add_plugins(DefaultPlugins) + // After (0.10) + App::new() + .add_plugins(DefaultPlugins.set(RenderPlugin { + wgpu_settings: WgpuSettings { .. }, + })) + ``` + + Co-authored-by: devil-ira + +commit 0761594dd859ee21877a3b74fe04c345fca9decf +Author: ira +Date: Tue Dec 20 16:17:07 2022 +0000 + + Use `World` helper methods for sending `HierarchyEvent`s (#6921) + + A code-quality PR + + Also cleans up the helper methods by just importing the `Event` type + + Co-authored-by: devil-ira + +commit 1523c38ce831ae952c28cbd774cc21d919119170 +Author: James Liu +Date: Tue Dec 20 16:17:05 2022 +0000 + + Directly extract joints into SkinnedMeshJoints (#6833) + + # Objective + Following #4402, extract systems run on the render world instead of the main world, and allow retained state operations on it's resources. We're currently extracting to `ExtractedJoints` and then copying it twice during Prepare. Once into `SkinnedMeshJoints` and again into the actual GPU buffer. + + This makes #4902 obsolete. + + ## Solution + Cut out the middle copy and directly extract joints into `SkinnedMeshJoints` and remove `ExtractedJoints` entirely. + + This also removes the per-frame allocation that is being made to send `ExtractedJoints` into the render world. + + ## Performance + On my local machine, this halves the time for `prepare_skinned _meshes` on `many_foxes` (195.75us -> 93.93us on average). + + ![image](https://user-images.githubusercontent.com/3137680/205427455-ab91a8a3-a6b0-4f0a-bd48-e54482c563b2.png) + + --- + + ## Changelog + Added: `BufferVec::truncate` + Added: `BufferVec::extend` + Changed: `SkinnedMeshJoints::build` now takes a `&mut BufferVec` instead of a `&mut Vec` as a parameter. + Removed: `ExtractedJoints`. + + ## Migration Guide + `ExtractedJoints` has been removed. Read the bound bones from `SkinnedMeshJoints` instead. + +commit 53a5bbe2d56b5d3f11d93ad383b160289851bab2 +Author: James Liu +Date: Tue Dec 20 16:17:02 2022 +0000 + + Add thread create/destroy callbacks to TaskPool (#6561) + + # Objective + Fix #1991. Allow users to have a bit more control over the creation and finalization of the threads in `TaskPool`. + + ## Solution + Add new methods to `TaskPoolBuilder` that expose callbacks that are called to initialize and finalize each thread in the `TaskPool`. + + Unlike the proposed solution in #1991, the callback is argument-less. If an an identifier is needed, `std::thread::current` should provide that information easily. + + Added a unit test to ensure that they're being called correctly. + +commit e8b28547bf27153e323a5f9406a9840c3cedcd7c +Author: François +Date: Tue Dec 20 16:16:58 2022 +0000 + + Cleanup dynamic scene before building (#6254) + + # Objective + + - Dynamic scene builder can build scenes without components, if they didn't have any matching the type registry + - Those entities are not really useful in the final `DynamicScene` + + ## Solution + + - Add a method `remove_empty_entities` that will remove empty entities. It's not called by default when calling `build`, I'm not sure if that's a good idea or not. + +commit 5b8b7dc08fbacc2fdd868b9d1f138585547562e8 +Author: James Liu +Date: Tue Dec 20 15:59:41 2022 +0000 + + Add a stress test profile (#6901) + + # Objective + This adds a custom profile for testing against stress tests. Bevy seemingly gets notably faster with LTO turned on. To more accurately depict production level performance, LTO and other rustc-level optimizations should be enabled when performance testing on stress tests. + + Also updated the stress test docs to reflect that users should be using it. + +commit bd615cbf8c42fb9880317b20d40ec861587143b7 +Author: James Liu +Date: Tue Dec 20 15:40:42 2022 +0000 + + Shrink DrawFunctionId (#6944) + + # Objective + This includes one part of #4899. The aim is to improve CPU-side rendering performance by reducing the memory footprint and bandwidth required. + + ## Solution + Shrink `DrawFunctionId` to `u32`. Enforce that `u32 as usize` conversions are always safe by forbidding compilation on 16-bit platforms. This shouldn't be a breaking change since #4736 disabled compilation of `bevy_ecs` on those platforms. + + Shrinking `DrawFunctionId` shrinks all of the `PhaseItem` types, which is integral to sort and render phase performance. + + Testing against `many_cubes`, the sort phase improved by 22% (174.21us -> 141.76us per frame). + + ![image](https://user-images.githubusercontent.com/3137680/207345422-a512b4cf-1680-46e0-9973-ea72494ebdfe.png) + + The main opaque pass also imrproved by 9% (5.49ms -> 5.03ms) + + ![image](https://user-images.githubusercontent.com/3137680/207346436-cbee7209-6450-4964-b566-0b64cfa4b4ea.png) + + Overall frame time improved by 5% (14.85ms -> 14.09ms) + + ![image](https://user-images.githubusercontent.com/3137680/207346895-9de8676b-ef37-4cb9-8445-8493f5f90003.png) + + There will be a followup PR that likewise shrinks `CachedRenderPipelineId` which should yield similar results on top of these improvements. + +commit f8e4b755ffde634a4f2c27f904a3a78a68d4eaa6 +Author: Zeenobit +Date: Fri Dec 16 20:14:13 2022 +0000 + + Add `EntityMap::iter()` (#6935) + + # Objective + + There is currently no way to iterate over key/value pairs inside an `EntityMap`, which makes the usage of this struct very awkward. I couldn't think of a good reason why the `iter()` function should not be exposed, considering the interface already exposes `keys()` and `values()`, so I made this PR. + + ## Solution + + Implement `iter()` for `EntityMap` in terms of its inner map type. + +commit 00fa0d8cf2fdb09675b6abbb75a5469ca8d49303 +Author: ira +Date: Fri Dec 16 20:14:11 2022 +0000 + + Apply `WindowDescriptor` settings in all modes (#6934) + + # Objective + Some settings were only applied in windowed mode. + Fix the issue in #6933 + + # Solution + Always apply the settings. + + + Co-authored-by: devil-ira + +commit 0d606030a23683faa1d3ca8158da2a33465affa2 +Author: ira +Date: Fri Dec 16 19:53:23 2022 +0000 + + Remove `EntityCommands::add_children` (#6942) + + # Objective + Remove a method with an unfortunate name and questionable usefulness. + Added in #4708 + + It doesn't make sense to me for us to provide a method to work around a limitation of closures when we can simply, *not* use a closure. + The limitation in this case is not being able to initialize a variable from inside a closure: + + ```rust + let child_id; + commands.spawn_empty().with_children(|parent| { + // Error: passing uninitalized variable to a closure. + child_id = parent.spawn_empty().id(); + }); + + // Do something with child_id + ``` + The docs for `add_children` suggest the following: + ```rust + let child_id = commands + .spawn_empty() + .add_children(|parent| parent.spawn_empty().id()); + ``` + I would instead suggest using the following snippet. + ```rust + let parent_id = commands.spawn_empty().id(); + let child_id = commands.spawn_empty().set_parent(parent_id).id(); + + // To be fair, at the time of #4708 this would have been a bit more cumbersome since `set_parent` did not exist. + ``` + + Using `add_children` gets more unwieldy when you also want the `parent_id`. + ```rust + let parent_commands = commands.spawn_empty(); + let parent_id = parent_commands.id(); + let child_id = parent_commands.add_children(|parent| parent.spawn_empty().id()); + ``` + ### The name + I see why `add_children` is named that way, it's the non-builder variant of `with_children` so it kinda makes sense, + but now the method name situation for `add_child`, `add_children` and `push_children` is *rather* unfortunate. + + Removing `add_children` and renaming `push_children` to `add_children` in one go is kinda bleh, but that way we end up with the matching methods `add_child` and `add_children`. + + Another reason to rename `push_children` is that it's trying to mimick the `Vec` api naming but fails because `push` is for single elements. I guess it should have been `extend_children_from_slice`, but lets not name it that :) + + ### Questions + ~~Should `push_children` be renamed in this PR? This would make the migration guide easier to deal with.~~ + Let's do that later. + + Does anyone know of a way to do a simple text/regex search through all the github repos for usage of `add_children`? + That way we can have a better idea of how this will affect users. My guess is that usage of `add_children` is quite rare. + + ## Migration Guide + The method `add_children` on `EntityCommands` was removed. + If you were using `add_children` over `with_children` to return data out of the closure you can use `set_parent` or `add_child` to avoid the closure instead. + + Co-authored-by: devil-ira + +commit bd3e95562102ba7607ab3ef7339c9418dae79106 (msaa/main) +Author: Nate Casey +Date: Fri Dec 16 10:52:53 2022 -0500 + + Msaa::samples() now inline + +commit 79b0d02e0ab317134066e0875cebe69e380134cf +Author: Nate Casey +Date: Thu Dec 15 23:12:06 2022 -0500 + + check doc + +commit 37416518bc5d2390b3c199217cde5b7cef484397 +Author: Nate Casey +Date: Thu Dec 15 22:59:26 2022 -0500 + + Changed some code to use .samples() + +commit 5f1f5be560307f3110f7bc503d1cd1d212fb52d0 +Author: Nate Casey +Date: Thu Dec 15 22:49:47 2022 -0500 + + Moved non-exhaustive attribute to MultiSampleLevel + +commit 38d567d2c5d9e5eaf232be8e878bdb78aa819847 +Author: Jonah Henriksson <33059163+JonahPlusPlus@users.noreply.github.com> +Date: Fri Dec 16 01:40:15 2022 +0000 + + Make `AsBindGroup` unsized (#6937) + + # Objective + + `AsBindGroup` can't be used as a trait object because of the constraint `Sized` and because of the associated function. + + This is a problem for [`bevy_atmosphere`](https://github.com/JonahPlusPlus/bevy_atmosphere) because it needs to use a trait that depends on `AsBindGroup` as a trait object, for switching out different shaders at runtime. The current solution it employs is reimplementing the trait and derive macro into that trait, instead of constraining to `AsBindGroup`. + + ## Solution + + Remove the `Sized` constraint from `AsBindGroup` and add the constraint `where Self: Sized` to the associated function `bind_group_layout`. Also change `PreparedBindGroup` to `PreparedBindGroup` and use it as `PreparedBindGroup` instead of `PreparedBindGroup`. + + This weakens the constraints, but increases the flexibility of `AsBindGroup`. + I'm not entirely sure why the `Sized` constraint was there, because it worked fine without it (maybe @cart wasn't aware of use cases for `AsBindGroup` as a trait object or this was just leftover from legacy code?). + + --- + + ## Changelog + + - `AsBindGroup` can be used as a trait object. + +commit ec0478d100d286007a83fe00e3d2fe0d3410b74b +Author: Rob Parrett +Date: Thu Dec 15 18:05:15 2022 +0000 + + Fix clippy lints and failed test with Rust 1.66 (#6945) + + # Objective + + [Rust 1.66](https://blog.rust-lang.org/inside-rust/2022/12/12/1.66.0-prerelease.html) is coming in a few days, and bevy doesn't build with it. + + Fix that. + + ## Solution + + Replace output from a trybuild test, and fix a few new instances of `needless_borrow` and `unnecessary_cast` that are now caught. + + ## Note + + Due to the trybuild test, this can't be merged until 1.66 is released. + +commit c02613b77b8012847c50abc0ddc4438c0e8334bf +Author: Nate Casey +Date: Tue Dec 13 23:26:26 2022 -0500 + + Changed Msaa to take level rather than int + +commit bad3d57d0c679510013083bfeaef7b73b8852acc +Author: François +Date: Tue Dec 13 22:54:27 2022 +0000 + + update cargo deny config with latest list of duplicate crates in dependencies (#6947) + + # Objective + + - Get dependency check to succeed + + ## Solution + + - Update the list + +commit b7d6ee8c6835bbf66127e24a6f81229ef7eb92bf +Author: ira +Date: Tue Dec 13 21:00:43 2022 +0000 + + Update concurrent-queue to 2.0 (#6538) + + + + Co-authored-by: devil-ira + +commit 79b9231b749150ffead1571e8c19911fe9a9e8be +Author: James Liu +Date: Sun Dec 11 23:04:04 2022 +0000 + + Move system_commands spans into apply_buffers (#6900) + + # Objective + A separate `tracing` span for running a system's commands is created, even if the system doesn't have commands. This is adding extra measuring overhead (see #4892) where it's not needed. + + ## Solution + Move the span into `ParallelCommandState` and `CommandQueue`'s `SystemParamState::apply`. To get the right metadata for the span, a additional `&SystemMeta` parameter was added to `SystemParamState::apply`. + + --- + + ## Changelog + Added: `SystemMeta::name` + Changed: Systems without `Commands` and `ParallelCommands` will no longer show a "system_commands" span when profiling. + Changed: `SystemParamState::apply` now takes a `&SystemMeta` parameter in addition to the provided `&mut World`. + +commit 4820917af6be06866f10d4bd17191802d6640efb +Author: Zoey +Date: Sun Dec 11 19:24:19 2022 +0000 + + Add `set_if_neq` method to `DetectChanges` trait (Rebased) (#6853) + + # Objective + + Change detection can be spuriously triggered by setting a field to the same value as before. As a result, a common pattern is to write: + + ```rust + if *foo != value { + *foo = value; + } + ``` + + This is confusing to read, and heavy on boilerplate. + + Adopted from #5373, but untangled and rebased to current `bevy/main`. + + ## Solution + + 1. Add a method to the `DetectChanges` trait that implements this boilerplate when the appropriate trait bounds are met. + + 2. Document this minor footgun, and point users to it. + + + ## Changelog + + * added the `set_if_neq` method to avoid triggering change detection when the new and previous values are equal. This will work on both components and resources. + + + ## Migration Guide + + If you are manually checking if a component or resource's value is equal to its new value before setting it to avoid triggering change detection, migrate to the clearer and more convenient `set_if_neq` method. + ## Context + + Related to #2363 as it avoids triggering change detection, but not a complete solution (as it still requires triggering it when real changes are made). + + + + Co-authored-by: Zoey + +commit aeb2c4b9173a5dde7123f2d18e601caf2a3b063e +Author: Lixou <82600264+DasLixou@users.noreply.github.com> +Date: Sun Dec 11 19:24:18 2022 +0000 + + Update linux_dependencies.md for Arch - Vulkan API not only for Intel GPUs (#6729) + + fix note in arch's linux deps. + +commit 68a7127a27e4ceabbf254cccf74459e719825999 +Author: zxygentoo +Date: Sun Dec 11 18:46:48 2022 +0000 + + Update linux_dependencies.md (#6915) + + Add a section about install `vulkan-loader` on Gentoo. + + # Objective + + - Clarify the dependency about install on Gentoo with NVIDIA GPU and using a proprietary driver. + + ## Solution + + - Emerge `vulkan-loader` to help Bevy to find the correct ICD. + +commit b1a634cade314e80af614e84b11323636c49ba90 +Author: Tianlan Zhou +Date: Sun Dec 11 18:46:47 2022 +0000 + + Fix alpha channel in RGB32F image texture format conversion (#6914) + + # Objective + + The following code: + + ```rs + use bevy::prelude::Image; + use image::{ DynamicImage, GenericImage, Rgba }; + + fn main() { + let mut dynamic_image = DynamicImage::new_rgb32f(1, 1); + dynamic_image.put_pixel(0, 0, Rgba([1, 1, 1, 1])); + + let image = Image::from_dynamic(dynamic_image, false); // Panic! + println!("{image:?}"); + } + ``` + + Can cause an assertion failed: + + ``` + thread 'main' panicked at 'assertion failed: `(left == right)` + left: `16`, + right: `14`: Pixel data, size and format have to match', .../bevy_render-0.9.1/src/texture/image.rs:209:9 + stack backtrace: + ... + 4: core::panicking::assert_failed + at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:181 + 5: bevy_render::texture::image::Image::new + at .../bevy_render-0.9.1/src/texture/image.rs:209 + 6: bevy_render::texture::image::Image::from_dynamic + at .../bevy_render-0.9.1/src/texture/image_texture_conversion.rs:159 + 7: bevy_test::main + at ./src/main.rs:8 + ... + ``` + + It seems to be cause by a copypasta in `crates/bevy_render/src/texture/image_texture_conversion.rs`. Let's fix it. + + ## Solution + + ```diff + // DynamicImage::ImageRgb32F(image) => { + - let a = u16::max_value(); + + let a = 1f32; + ``` + + This will fix the conversion. + + --- + + ## Changelog + + - Fixed the alpha channel of the `image::DynamicImage::ImageRgb32F` to `bevy_render::texture::Image` conversion in `bevy_render::texture::Image::from_dynamic()`. + +commit 544776831d1d8305b135d1520078ee17ba2276ae +Author: Hennadii Chernyshchyk +Date: Sun Dec 11 18:46:46 2022 +0000 + + Remove `render` feature group (#6912) + + # Objective + + The feature doesn't have any use case in libraries or applications and many users use this feature incorrectly. See the issue for details. + Closes #5753. + + ## Solution + + Remove it. + + --- + + ## Changelog + + ### Removed + + - `render` feature group. + + ## Migration Guide + + Instead of using `render` feature group use dependencies directly. This group consisted of `bevy_core_pipeline`, `bevy_pbr`, `bevy_gltf`, `bevy_render`, `bevy_sprite`, `bevy_text` and `bevy_ui`. You probably want to check if you need all of them. + +commit 36691769bae00ba04590d5e2e04e012f480e7f09 +Author: IceSentry +Date: Sun Dec 11 18:46:45 2022 +0000 + + Document undocumented features of AsBindGroup derive (#6910) + + # Objective + + - https://github.com/bevyengine/bevy/pull/5364 Added a few features to the AsBindGroup derive, but if you don't know they exist they aren't documented anywhere. + + + ## Solution + + - Document the new arguments in the doc block for the derive. + +commit 87bf0e26643f4d599e2f77690dcff71204fa325f +Author: James Liu +Date: Sun Dec 11 18:46:43 2022 +0000 + + Remove unnecessary branching from bundle insertion (#6902) + + # Objective + Speed up bundle insertion and spawning from a bundle. + + ## Solution + Use the same technique used in #6800 to remove the branch on storage type when writing components from a `Bundle` into storage. + + - Add a `StorageType` argument to the closure on `Bundle::get_components`. + - Pass `C::Storage::STORAGE_TYPE` into that argument. + - Match on that argument instead of reading from a `Vec` in `BundleInfo`. + - Marked all implementations of `Bundle::get_components` as inline to encourage dead code elimination. + + The `Vec` in `BundleInfo` was also removed as it's no longer needed. If users were reliant on this, they can either use the compile time constants or fetch the information from `Components`. Should save a rather negligible amount of memory. + + ## Performance + Microbenchmarks show a slight improvement to inserting components into existing entities, as well as spawning from a bundle. Ranging about 8-16% faster depending on the benchmark. + + ``` + group main soft-constant-write-components + ----- ---- ------------------------------ + add_remove/sparse_set 1.08 1019.0±80.10µs ? ?/sec 1.00 944.6±66.86µs ? ?/sec + add_remove/table 1.07 1343.3±20.37µs ? ?/sec 1.00 1257.3±18.13µs ? ?/sec + add_remove_big/sparse_set 1.08 1132.4±263.10µs ? ?/sec 1.00 1050.8±240.74µs ? ?/sec + add_remove_big/table 1.02 2.6±0.05ms ? ?/sec 1.00 2.5±0.08ms ? ?/sec + get_or_spawn/batched 1.15 401.4±17.76µs ? ?/sec 1.00 349.3±11.26µs ? ?/sec + get_or_spawn/individual 1.13 732.1±43.35µs ? ?/sec 1.00 645.6±41.44µs ? ?/sec + insert_commands/insert 1.12 623.9±37.48µs ? ?/sec 1.00 557.4±34.99µs ? ?/sec + insert_commands/insert_batch 1.16 401.4±17.00µs ? ?/sec 1.00 347.4±12.87µs ? ?/sec + insert_simple/base 1.08 416.9±5.60µs ? ?/sec 1.00 385.2±4.14µs ? ?/sec + insert_simple/unbatched 1.06 934.5±44.58µs ? ?/sec 1.00 881.3±47.86µs ? ?/sec + spawn_commands/2000_entities 1.09 190.7±11.41µs ? ?/sec 1.00 174.7±9.15µs ? ?/sec + spawn_commands/4000_entities 1.10 386.5±25.33µs ? ?/sec 1.00 352.3±18.81µs ? ?/sec + spawn_commands/6000_entities 1.10 586.2±34.42µs ? ?/sec 1.00 535.3±27.25µs ? ?/sec + spawn_commands/8000_entities 1.08 778.5±45.15µs ? ?/sec 1.00 718.0±33.66µs ? ?/sec + spawn_world/10000_entities 1.04 1026.4±195.46µs ? ?/sec 1.00 985.8±253.37µs ? ?/sec + spawn_world/1000_entities 1.06 103.8±20.23µs ? ?/sec 1.00 97.6±18.22µs ? ?/sec + spawn_world/100_entities 1.15 11.4±4.25µs ? ?/sec 1.00 9.9±1.87µs ? ?/sec + spawn_world/10_entities 1.05 1030.8±229.78ns ? ?/sec 1.00 986.2±231.12ns ? ?/sec + spawn_world/1_entities 1.01 105.1±23.33ns ? ?/sec 1.00 104.6±31.84ns ? ?/sec + ``` + + --- + + ## Changelog + Changed: `Bundle::get_components` now takes a `FnMut(StorageType, OwningPtr)`. The provided storage type must be correct for the component being fetched. + +commit 26d614591523acdb58682378041b93cc3158d455 +Author: James Liu +Date: Sun Dec 11 18:46:42 2022 +0000 + + Document remaining members of bevy_utils (#6897) + + # Objective + Partially address #3492. + + ## Solution + Document the remaining undocumented members of `bevy_utils` and set `warn(missing_docs)` on the crate level. Also enabled `clippy::undocumented_unsafe_blocks` as a warning on the crate to keep it in sync with `bevy_ecs`'s warnings. + +commit f4818bcd69ec2153201d44e0f072ef16d9acc751 +Author: François +Date: Sun Dec 11 18:46:41 2022 +0000 + + scene viewer: can select a scene from the asset path (#6859) + + # Objective + + - Fixes #6630, fixes #6679 + - Improve scene viewer in cases where there are more than one scene in a gltf file + + ## Solution + + - Can select which scene to display using `#SceneN`, defaults to scene 0 if not present + - Display the number of scenes available if there are more than one + +commit ea8f74692ff8aae5ed1f6b81425a5e953068ca40 +Author: ira +Date: Sun Dec 11 18:34:16 2022 +0000 + + Add `with_a` and friends to `Color` (#6899) + + # Objective + ```rust + // makes clippy complain about 'taking a mutable reference to a `const` item' + let color = *Color::RED.set_a(0.5); + + // Now you can do + let color = Color::RED.with_a(0.5); + ``` + + ## Changelog + Added `with_r`, `with_g`, `with_b`, and `with_a` to `Color`. + + Co-authored-by: devil-ira + +commit 75880a0b176e7f55baf8ed07765ef9a2f243e2df +Author: Mike +Date: Sun Dec 11 18:34:15 2022 +0000 + + run clear trackers on render world (#6878) + + # Objective + + - Fixes https://github.com/bevyengine/bevy/issues/6417 + + ## Solution + + - clear_trackers was not being called on the render world. This causes the removed components vecs to continuously grow. This PR adds clear trackers to the end of RenderStage::Cleanup + + ## Migration Guide + + The call to `clear_trackers` in `App` has been moved from the schedule to App::update for the main world and calls to `clear_trackers` have been added for sub_apps in the same function. This was due to needing stronger guarantees. If clear_trackers isn't called on a world it can lead to memory leaks in `RemovedComponents`. + +commit 1af73624fa3ab936384b342212a4c54505491d64 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sun Dec 11 18:34:14 2022 +0000 + + Simplify trait hierarchy for `SystemParam` (#6865) + + # Objective + + * Implementing a custom `SystemParam` by hand requires implementing three traits -- four if it is read-only. + * The trait `SystemParamFetch<'w, 's>` is a workaround from before we had generic associated types, and is no longer necessary. + + ## Solution + + * Combine the trait `SystemParamFetch` with `SystemParamState`. + * I decided to remove the `Fetch` name and keep the `State` name, since the former was consistently conflated with the latter. + * Replace the trait `ReadOnlySystemParamFetch` with `ReadOnlySystemParam`, which simplifies trait bounds in generic code. + + --- + + ## Changelog + + - Removed the trait `SystemParamFetch`, moving its functionality to `SystemParamState`. + - Replaced the trait `ReadOnlySystemParamFetch` with `ReadOnlySystemParam`. + + ## Migration Guide + + The trait `SystemParamFetch` has been removed, and its functionality has been transferred to `SystemParamState`. + + ```rust + // Before + impl SystemParamState for MyParamState { + fn init(world: &mut World, system_meta: &mut SystemMeta) -> Self { ... } + } + impl<'w, 's> SystemParamFetch<'w, 's> for MyParamState { + type Item = MyParam<'w, 's>; + fn get_param(...) -> Self::Item; + } + + // After + impl SystemParamState for MyParamState { + type Item<'w, 's> = MyParam<'w, 's>; // Generic associated types! + fn init(world: &mut World, system_meta: &mut SystemMeta) -> Self { ... } + fn get_param<'w, 's>(...) -> Self::Item<'w, 's>; + } + ``` + + The trait `ReadOnlySystemParamFetch` has been replaced with `ReadOnlySystemParam`. + + ```rust + // Before + unsafe impl ReadOnlySystemParamFetch for MyParamState {} + + // After + unsafe impl<'w, 's> ReadOnlySystemParam for MyParam<'w, 's> {} + ``` + +commit c16791ce6712854f031e79ebc303fb6bb540912b +Author: James Liu +Date: Sun Dec 11 18:34:13 2022 +0000 + + Document options for !Sync types for Component and Resources (#6864) + + # Objective + It's not clear to users how to handle `!Sync` types as components and resources in the absence of engine level support for them. + + ## Solution + Added a section to `Component`'s and `Resource`'s type level docs on available options for making a type `Sync` when it holds `!Sync` fields, linking `bevy_utils::synccell::SyncCell` and the currently unstable `std::sync::Exclusive`. + + Also added a compile_fail doctest that illustrates how to apply `SyncCell`. These will break when/if #6572 gets merged, at which point these docs should be updated. + +commit ea80aca7ca7ddefe8e2e9795a941bd6bb4c7f4e6 +Author: Mike +Date: Sun Dec 11 18:22:11 2022 +0000 + + unpin miri (#6863) + + # Objective + + - https://github.com/rust-lang/miri/pull/2713 was merged into miri. See if this fixes miri for bevy. + +commit 95c0d99e45c0fecbd6d15bc334cf561bbffc0430 +Author: Alejandro Pascual +Date: Sun Dec 11 18:22:10 2022 +0000 + + Sprite sheet example: specify animation indices (#6861) + + # Objective + + - Make running animation fluid skipping 'idle' frame. + + ## Solution + + - Loop through the specified indices instead of through the whole sprite sheet. + + The example is correct, is just the feeling that the animation loop is not seamless. + + Based on the solution suggested by @mockersf in #5429. + +commit 0d67c32153d0a81f0fc0d4413e75aafe4906493c +Author: James Liu +Date: Sun Dec 11 18:22:09 2022 +0000 + + Avoid triggering change detection for inputs (#6847) + + # Objective + Fix #5292. + + ## Solution + Avoid derefencing when clearing to ensure that change detection is not triggered when there is nothing to clear. + +commit b37a6ca9a2cb0434800df62dad7b9472f8e2131a +Author: James Liu +Date: Sun Dec 11 18:22:08 2022 +0000 + + Add reflection support for VecDeque (#6831) + + # Objective + This is an adoption of #5792. Fixes #5791. + + ## Solution + Implemented all the required reflection traits for `VecDeque`, taking from `Vec`'s impls. + + --- + + ## Changelog + Added: `std::collections::VecDeque` now implements `Reflect` and all relevant traits. + + Co-authored-by: james7132 + +commit 6903a9411b0d7e4dec759deecf7cc7986a9f6092 +Author: Mike +Date: Sun Dec 11 18:22:07 2022 +0000 + + get pixel size from wgpu (#6820) + + # Objective + + - Get rid of giant match statement to get PixelInfo. + - This will allow for supporting any texture that is uncompressed, instead of people needing to PR in any textures that are supported in wgpu, but not bevy. + + ## Solution + + - More conservative alternative to https://github.com/bevyengine/bevy/pull/6788, where we don't try to make some of the calculations correct for compressed types. + - Delete `PixelInfo` and get the pixel_size directly from wgpu. Data from wgpu is here: https://docs.rs/wgpu-types/0.14.0/src/wgpu_types/lib.rs.html#2359 + - Panic if the texture is a compressed type. An integer byte size of a pixel is no longer a valid concept when talking about compressed textures. + - All internal usages use `pixel_size` and not `pixel_info` and are on uncompressed formats. Most of these usages are on either explicit texture formats or slightly indirectly through `TextureFormat::bevy_default()`. The other uses are in `TextureAtlas` and have other calculations that assumes the texture is uncompressed. + + ## Changelog + + - remove `PixelInfo` and get `pixel_size` from wgpu + + ## Migration Guide + + `PixelInfo` has been removed. `PixelInfo::components` is equivalent to `texture_format.describe().components`. `PixelInfo::type_size` can be gotten from `texture_format.describe().block_size/ texture_format.describe().components`. But note this can yield incorrect results for some texture types like Rg11b10Float. + +commit 2e7925d8d01469b5835a36f159ae068668ded511 +Author: Jay Pavlina +Date: Sun Dec 11 18:22:05 2022 +0000 + + Add cylinder shape (#6809) + + # Objective + + Adds a cylinder shape. Fixes #2282. + + ## Solution + + - I added a custom cylinder shape, taken from [here](https://github.com/rparrett/typey_birb/blob/main/src/cylinder.rs) with permission from @rparrett. + - I also added the cylinder shape to the `3d_shapes` example scene. + + --- + + ## Changelog + + - Added cylinder shape + + Co-Authored-By: Rob Parrett + Co-Authored-By: davidhof <7483215+davidhof@users.noreply.github.com> + +commit aea4c5b1a42f613932a00440aa4c917808e059a5 +Author: Edvin Kjell +Date: Sun Dec 11 18:10:03 2022 +0000 + + [Fixes #6224] Add logging variants of system piping (#6751) + + # Objective + + Fixes #6224, add ``dbg``, ``info``, ``warn`` and ``error`` system piping adapter variants to expand #5776, which call the corresponding re-exported [bevy_log macros](https://docs.rs/bevy/latest/bevy/log/macro.info.html) when the result is an error. + + ## Solution + + * Added ``dbg``, ``info``, ``warn`` and ``error`` system piping adapter variants to ``system_piping.rs``. + * Modified and added tests for these under examples in ``system_piping.rs``. + +commit 81153a8b0c75381b9f8359549c341938d3401f76 +Author: dis-da-moe +Date: Sun Dec 11 18:10:02 2022 +0000 + + document file formats for `bytes` field of `AudioSource` (#6619) + + # Objective + + Fixes #6299 + + ## Solution + + Change one line of documentation. + + Co-authored-by: dis-da-moe <84386186+dis-da-moe@users.noreply.github.com> + +commit 07e7fa5a4d1e29d50afbdcf0eb97c7e705bc3477 +Author: Jerome Humbert +Date: Sun Dec 11 18:10:01 2022 +0000 + + Document `World::clear_trackers()` (#6520) + + # Objective + + Document `World::clear_trackers()`. + + ## Solution + + Document the `World::clear_trackers()` method, and briefly how it's related to change detection and `RemovedComponents`. + + This is a follow-up from [this discussion](https://discord.com/channels/691052431525675048/749335865876021248/1039628807025479700) on Discord. + +commit 344a65313f21ea6748ae37a6d7cd407ae45f3045 +Author: harudagondi +Date: Sun Dec 11 18:10:00 2022 +0000 + + Make `AudioOutput` a Resource (#6436) + + # Objective + + - Make `AudioOutput` a `Resource`. + + ## Solution + + - Do not store `OutputStream` in the struct. + - `mem::forget` `OutputStream`. + + --- + + ## Changelog + + ### Added + + - `AudioOutput` is now a `Resource`. + + ## Migration Guide + + - Use `Res>` instead of `NonSend>`. Same for `Mut` variants. + +commit 63f1a9dec822b71e21b55cf5b02e8d7b57435537 +Author: Gino Valente +Date: Sun Dec 11 17:52:48 2022 +0000 + + bevy_reflect: Add `ReflectFromReflect` (v2) (#6245) + + # Objective + + Resolves #4597 (based on the work from #6056 and a refresh of #4147) + + When using reflection, we may often end up in a scenario where we have a Dynamic representing a certain type. Unfortunately, we can't just call `MyType::from_reflect` as we do not have knowledge of the concrete type (`MyType`) at runtime. + + Such scenarios happen when we call `Reflect::clone_value`, use the reflection deserializers, or create the Dynamic type ourselves. + + ## Solution + + Add a `ReflectFromReflect` type data struct. + + This struct allows us to easily convert Dynamic representations of our types into their respective concrete instances. + + ```rust + #[derive(Reflect, FromReflect)] + #[reflect(FromReflect)] // <- Register `ReflectFromReflect` + struct MyStruct(String); + + let type_id = TypeId::of::(); + + // Register our type + let mut registry = TypeRegistry::default(); + registry.register::(); + + // Create a concrete instance + let my_struct = MyStruct("Hello world".to_string()); + + // `Reflect::clone_value` will generate a `DynamicTupleStruct` for tuple struct types + let dynamic_value: Box = my_struct.clone_value(); + assert!(!dynamic_value.is::()); + + // Get the `ReflectFromReflect` type data from the registry + let rfr: &ReflectFromReflect = registry + .get_type_data::(type_id) + .unwrap(); + + // Call `FromReflect::from_reflect` on our Dynamic value + let concrete_value: Box = rfr.from_reflect(&dynamic_value); + assert!(concrete_value.is::()); + ``` + + ### Why this PR? + + ###### Why now? + + The three main reasons I closed #4147 were that: + + 1. Registering `ReflectFromReflect` is clunky (deriving `FromReflect` *and* registering `ReflectFromReflect`) + 2. The ecosystem and Bevy itself didn't seem to pay much attention to deriving `FromReflect` + 3. I didn't see a lot of desire from the community for such a feature + + However, as time has passed it seems 2 and 3 are not really true anymore. Bevy is internally adding lots more `FromReflect` derives, which should make this feature all the more useful. Additionally, I have seen a growing number of people look for something like `ReflectFromReflect`. + + I think 1 is still an issue, but not a horrible one. Plus it could be made much, much better using #6056. And I think splitting this feature out of #6056 could lead to #6056 being adopted sooner (or at least make the need more clear to users). + + ###### Why not just re-open #4147? + + The main reason is so that this PR can garner more attention than simply re-opening the old one. This helps bring fresh eyes to the PR for potentially more perspectives/reviews. + + --- + + ## Changelog + + * Added `ReflectFromReflect` + + Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com> + +commit 6308041772fec9ef8273f040f392de3532a661a4 +Author: James Liu +Date: Sat Dec 10 09:25:53 2022 +0000 + + Fix Sparse Change Detection (#6896) + + # Objective + #6547 accidentally broke change detection for SparseSet components by using `Ticks::from_tick_cells` with the wrong argument order. + + ## Solution + Use the right argument order. Add a regression test. + +commit a5d70b8952aed3616ffb5a58026ea6cb5375fc82 +Author: TehPers +Date: Fri Dec 9 01:20:44 2022 +0000 + + Derive `Reflect` + `FromReflect` for window event types (#6235) + + # Objective + + The window event types currently don't support reflection. This PR adds support to them (as requested [here](https://github.com/bevyengine/bevy/issues/6223#issuecomment-1273852329)). + + ## Solution + + Implement `Reflect` + `FromReflect` for window event types. Relevant traits are also being reflected with `#[reflect(...)]` attributes. + + Additionally, this PR derives `Reflect` + `FromReflect` for `WindowDescriptor` and the types it depends on so that `CreateWindow` events can be fully manipulated through reflection. + + Finally, this PR adds `FromReflect` for `PathBuf` as a value type, which is needed for `FileDragAndDrop`. + + This adds the "glam" feature to the `bevy_reflect` dependency for package `bevy_window`. Since `bevy_window` transitively depends on `glam` already, all this brings in are the reflection `impl`s. + + ## Open questions + + Should `app.register_type::();` be moved to `CorePlugin`? I added it to `WindowPlugin` because that's where it's used and `CorePlugin` doesn't seem to register all the missing std types, but it would also make sense in `CorePlugin` I believe since it's a commonly used type. + + --- + + ## Changelog + + Added: + - Implemented `Reflect` + `FromReflect` for window events and related types. These types are automatically registered when adding the `WindowPlugin`. + +commit b58ca8721a0c9d48dfb8b1d4c5e5af612aec4d16 +Author: Olivia Crain +Date: Thu Dec 8 20:05:27 2022 +0000 + + ci: Use Ubuntu 22.04 runner for run-examples, run-examples-on-wasm jobs (#6875) + + # Objective + + - The `run-examples-on-wasm` job fails on Ubuntu 22.04, when it was previously working on Ubuntu 20.04. Playwright 1.22.1 (the version currently pinned by us) fails trying to install system dependencies that were renamed between Ubuntu 20.04 and 22.04. + - The `run-examples` job previously failed on Ubuntu 22.04 with errors consistent with those listed in [this upstream mesa bug](https://gitlab.freedesktop.org/mesa/mesa/-/issues/7819). + - Fixes #6832 + + ## Solution + + - Upgrade `playwright` to the latest [v1.28.1](https://github.com/microsoft/playwright/releases/tag/v1.28.1) release. Ubuntu 22.04 support was [added](https://github.com/microsoft/playwright/pull/14588) in [v1.23.0](https://github.com/microsoft/playwright/releases/tag/v1.23.0). The [test now passes on 22.04](https://github.com/oliviacrain/bevy/actions/runs/3633583112/jobs/6130757397), and the output screenshots are unchanged from previous job outputs. + - Use `ubuntu-latest` for the `run-examples` job. No other modifications necessary. The [PPA we pull mesa from](https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers) rebuilt the package for 22.04 with the [upstream fix](https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20145/diffs?commit_id=b3d1ae19f2f4d93cf0a5f45a598149ac4e8e05aa). + +commit 8eedc8f69d9a09ba125f7f7fcb1d827d39bfc346 +Author: François +Date: Wed Dec 7 23:10:27 2022 +0000 + + ShaderDefVal: add an `UInt` option (#6881) + + # Objective + + - Fixes #6841 + - In some case, the number of maximum storage buffers is `u32::MAX` which doesn't fit in a `i32` + + ## Solution + + - Add an option to have a `u32` in a `ShaderDefVal` + +commit bac0d89059c7be8afa4faf3da8a23f32a8275878 +Author: Boxy +Date: Wed Dec 7 23:10:26 2022 +0000 + + remove a `doc(hidden)` on read only version of `derive(WorldQuery)` (#6877) + + having `doc(hidden)` on the read only version of a generated mutable world query leads to docs on the readonly item having a dead link. It also makes it annoying to have nice docs for libraries attempting to expose derived `WorldQuery` structs as re-exporting the read only item does not cause it to appear in docs even though it would be intended for users to know about the read only world query and use it. + +commit e08701307b9d5a4beb1e1d908543577e448a23ec +Author: Zhell +Date: Wed Dec 7 23:10:25 2022 +0000 + + Updated docs for ``List`` Trait in ``bevy_reflect`` (#6872) + + # Objective + + Fixes #6866. + + ## Solution + + Docs now should describe what the _front_, _first_, _back_, and _last_ elements are for an implementor of the `bevy::reflect::list::List` Trait. Further, the docs should describe how `bevy::reflect::list::List::push` and `bevy::reflect::list::List::pop` should act on these elements. + + + Co-authored-by: Linus Käll + +commit 10898d1dc9aac4f351eae4f846e8c93d93b531a5 +Author: James Liu +Date: Wed Dec 7 22:57:27 2022 +0000 + + Docs: Show how to compare two different traces in Tracy (#6869) + + # Objective + Fixes #5199. + + ## Solution + Mention how to compare two different saved tracy traces in the profiling section. + +commit 176d7df5db65b78bb8c84bdb880c2f4619f17ec8 +Author: Olivia Crain +Date: Wed Dec 7 21:23:20 2022 +0000 + + docs: Use correct cargo-flamegraph upstream repo URL (#6873) + + # Objective + + Links to `cargo-flamegraph`'s repo point to a [fork](https://github.com/killercup/cargo-flamegraph), not the actual upstream repo. We should point to the source of truth instead of a fork that hasn't been updated since 2019. + + ## Solution + + Change links to point to the upstream repo at [flamegraph-rs/flamegraph](https://github.com/flamegraph-rs/flamegraph). + +commit 530be10e72aa2b8191fe680e9ffef5c4576ce961 +Author: James Liu +Date: Tue Dec 6 01:38:21 2022 +0000 + + Newtype ArchetypeRow and TableRow (#4878) + + # Objective + Prevent future unsoundness that was seen in #6623. + + ## Solution + Newtype both indexes in `Archetype` and `Table` as `ArchetypeRow` and `TableRow`. This avoids weird numerical manipulation on the indices, and can be stored and treated opaquely. Also enforces the source and destination of where these indices at a type level. + + --- + + ## Changelog + Changed: `Archetype` indices and `Table` rows have been newtyped as `ArchetypeRow` and `TableRow`. + +commit a3f203b504507e1b518e4cc1a0a6a6596c439bee +Author: James Liu +Date: Mon Dec 5 23:56:33 2022 +0000 + + Use T::Storage::STORAGE_TYPE to optimize out unused branches (#6800) + + # Objective + `EntityRef::get` and friends all type erase calls to fetch the target components by using passing in the `TypeId` instead of using generics. This is forcing a lookup to `Components` to fetch the storage type. This adds an extra memory lookup and forces a runtime branch instead of allowing the compiler to optimize out the unused branch. + + ## Solution + Leverage `Component::Storage::STORAGE_TYPE` as a constant instead of fetching the metadata from `Components`. + + ## Performance + This has a near 2x speedup for all calls to `World::get`. Microbenchmark results from my local machine. `Query::get_component`, which uses `EntityRef::get` internally also show a slight speed up. This has closed the gap between `World::get` and `Query::get` for the same use case. + + ``` + group entity-ref-generics main + ----- ------------------- ---- + query_get_component/50000_entities_sparse 1.00 890.6±40.42µs ? ?/sec 1.10 980.6±28.22µs ? ?/sec + query_get_component/50000_entities_table 1.00 968.5±73.73µs ? ?/sec 1.08 1048.8±31.76µs ? ?/sec + query_get_component_simple/system 1.00 703.2±4.37µs ? ?/sec 1.00 702.1±6.13µs ? ?/sec + query_get_component_simple/unchecked 1.02 855.8±8.98µs ? ?/sec 1.00 843.1±8.19µs ? ?/sec + world_get/50000_entities_sparse 1.00 202.3±3.15µs ? ?/sec 1.85 374.0±20.96µs ? ?/sec + world_get/50000_entities_table 1.00 193.0±1.78µs ? ?/sec 2.02 389.2±26.55µs ? ?/sec + world_query_get/50000_entities_sparse 1.01 162.4±2.23µs ? ?/sec 1.00 161.3±0.95µs ? ?/sec + world_query_get/50000_entities_table 1.00 199.9±0.63µs ? ?/sec 1.00 200.2±0.74µs ? ?/sec + ``` + + This should also, by proxy, speed up the `ReflectComponent` APIs as most of those use `World::get` variants internally. + +commit f9c52f98b9858a685ac08871eade1ab704137a51 +Author: Elbert Ronnie +Date: Mon Dec 5 23:39:44 2022 +0000 + + Make proc macros hygienic in bevy_reflect_derive (#6752) + + # Objective + + - Fixes #3004 + + ## Solution + + - Replaced all the types with their fully quallified names + - Replaced all trait methods and inherent methods on dyn traits with their fully qualified names + - Made a new file `fq_std.rs` that contains structs corresponding to commonly used Structs and Traits from `std`. These structs are replaced by their respective fully qualified names when used inside `quote!` + +commit 9f0c41f26d9d254b8aa8fa6ecf6c10a70afa7dd9 +Author: polygon +Date: Mon Dec 5 23:39:43 2022 +0000 + + Adapt path type of dynamically_load_plugin (#6734) + + # Objective + + - Fixes #6711 + + ## Solution + + - Change the `path` function parameter of `dynamically_load_plugin` and `DynamicPluginExt::load_plugin` to a generic with `AsRef` bound + +commit f9ad051e6128873761f33898f136f06b47c571d1 +Author: Griffin +Date: Mon Dec 5 23:39:42 2022 +0000 + + Remove unnecessary alternate create_texture path in prepare_asset for Image (#6671) + + # Objective + + `prepare_asset` for Image has an alternate path for texture creation that is used when the image is not compressed and does not contain mipmaps. This additional code path is unnecessary as `render_device.create_texture_with_data()` will handle both cases correctly. + + ## Solution + + Use `render_device.create_texture_with_data()` in all cases. + + Tested successfully with the following examples: + - load_gltf + - render_to_texture + - texture + - 3d_shapes + - sprite + - sprite_sheet + - array_texture + - shader_material_screenspace_texture + - skybox (though this already would use the `create_texture_with_data()` branch anyway) + +commit e621acd7f2830b6e144db3280d928f63a267e890 +Author: Jay Pavlina +Date: Mon Dec 5 23:23:16 2022 +0000 + + Remove `TextError::ExceedMaxTextAtlases(usize)` variant (#6796) + + # Objective + + Fixes #6756 + + ## Solution + + Removes the variant wherever it's used + + Co-authored-by: Jay Pavlina + +commit 83e8224694702d1e9aab85811de21bbf4b054f07 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Dec 5 23:23:14 2022 +0000 + + Add missing docs to `World::change_tick` and `World::read_change_tick` (#6765) + + # Objective + + The methods `World::change_tick` and `World::read_change_tick` lack documentation and have confusingly similar behavior. + + ## Solution + + Add documentation and clarify the distinction between the two functions. + +commit b337ed63adf815748f0fdb2e40106ca42cbaa800 +Author: Vladyslav Batyrenko +Date: Mon Dec 5 23:07:20 2022 +0000 + + Borrow instead of consuming in `EventReader::clear` (#6851) + + The PR fixes the interface of `EventReader::clear`. Currently, the method consumes the reader, which makes it unusable. + + ## Changelog + + - `EventReader::clear` now takes a mutable reference instead of consuming the event reader. + + ## Migration Guide + + `EventReader::clear` now takes a mutable reference instead of consuming the event reader. This means that `clear` now needs explicit mutable access to the reader variable, which previously could have been omitted in some cases: + + ```rust + // Old (0.9) + fn clear_events(reader: EventReader) { + reader.clear(); + } + + // New (0.10) + fn clear_events(mut reader: EventReader) { + reader.clear(); + } + ``` + + Co-authored-by: Carter Anderson + +commit 77c59c22abf6a1f93d254e18684d347d3c53d651 +Author: ira +Date: Mon Dec 5 22:49:06 2022 +0000 + + Improve code/comments for `Ray::intersect_plane` and its tests (#6823) + + + + Co-authored-by: devil-ira + +commit eff632dac818a61c13ac8d543f07568dc7b1f238 +Author: Martín Maita <47983254+mnmaita@users.noreply.github.com> +Date: Mon Dec 5 22:49:05 2022 +0000 + + Replace `World::read_change_ticks` with `World::change_ticks` within `bevy_ecs` crate (#6816) + + # Objective + + - Fixes #6812. + + ## Solution + + - Replaced `World::read_change_ticks` with `World::change_ticks` within `bevy_ecs` crate in places where `World` references were mutable. + + --- + +commit 17480b2d8905fef51b73966b7e671f7be6a5ff76 +Author: James Liu +Date: Mon Dec 5 22:49:04 2022 +0000 + + Remove APIs deprecated in 0.9 (#6801) + + # Objective + These functions were deprecated in 0.9. They should be removed in 0.10. + + ## Solution + Remove them. + +commit e8c0df9e1e5248b9a52e85cf2def9c4a73635bf1 +Author: James Liu +Date: Mon Dec 5 22:35:02 2022 +0000 + + Allow iterating over with EntityRef over the entire World (#6843) + + # Objective + Partially addresses #5504. Allow users to get an `Iterator>` over all entities in the `World`. + + ## Solution + Change `World::iter_entities` to return an iterator of `EntityRef` instead of `Entity`. + + Not sure how to tackle making an `Iterator>` without being horribly unsound. Might need to wait for `LendingIterator` to stabilize so we can ensure only one of them is valid at a given time. + + --- + + ## Changelog + Changed: `World::iter_entities` now returns an iterator of `EntityRef` instead of `Entity`. + +commit 05b498a2245261c42d931ecac4f07bffca1d6d9d +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Dec 5 20:15:03 2022 +0000 + + Make the `SystemParam` derive macro more flexible (#6694) + + # Objective + + Currently, the `SystemParam` derive forces you to declare the lifetime parameters `<'w, 's>`, even if you don't use them. + If you don't follow this structure, the error message is quite nasty. + + ### Example (before): + + ```rust + #[derive(SystemParam)] + pub struct EventWriter<'w, 's, E: Event> { + events: ResMut<'w, Events>, + // The derive forces us to declare the `'s` lifetime even though we don't use it, + // so we have to add this `PhantomData` to please rustc. + #[system_param(ignore)] + _marker: PhantomData<&'s ()>, + } + ``` + + + ## Solution + + * Allow the user to omit either lifetime. + * Emit a descriptive error if any lifetimes used are invalid. + + ### Example (after): + + ```rust + #[derive(SystemParam)] + pub struct EventWriter<'w, E: Event> { + events: ResMut<'w, Events>, + } + ``` + + --- + + ## Changelog + + * The `SystemParam` derive is now more flexible, allowing you to omit unused lifetime parameters. + +commit c55d553606f04a8b9d6b734763e02a4cc18b6caf +Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> +Date: Sun Dec 4 22:30:09 2022 +0000 + + Update tracing-chrome requirement from 0.6.0 to 0.7.0 (#6709) + + Updates the requirements on [tracing-chrome](https://github.com/thoren-d/tracing-chrome) to permit the latest version. +
+ Release notes +

Sourced from tracing-chrome's releases.

+
+

Release v0.7.0

+
    +
  • Add start_new to FlushGuard. You can now generate multiple traces in one run!
  • +
  • Clean up dependencies
  • +
  • Make events thread-scoped
  • +
+
+
+
+ Commits + +
+
+ + + Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. + + [//]: # (dependabot-automerge-start) + [//]: # (dependabot-automerge-end) + + --- + +
+ Dependabot commands and options +
+ + You can trigger Dependabot actions by commenting on this PR: + - `@dependabot rebase` will rebase this PR + - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it + - `@dependabot merge` will merge this PR after your CI passes on it + - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it + - `@dependabot cancel merge` will cancel a previously requested merge and block automerging + - `@dependabot reopen` will reopen this PR if it is closed + - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually + - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) + - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) + - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) + + +
+ +commit 89451226de439c2aaa91eff3f46f152757f20323 +Author: Pixelstorm +Date: Sun Dec 4 19:35:13 2022 +0000 + + Intepret glTF colors as linear instead of sRGB (#6828) + + # Objective + + Fixes #6827 + + ## Solution + + Use the `Color::rgba_linear` function instead of the `Color::rgba` function to correctly interpret colors from glTF files in the linear color space rather than the incorrect sRGB color space + +commit 6ada3566aca363414cb4a117dabbb6727acae4d5 +Author: Gino Valente +Date: Sat Dec 3 03:35:45 2022 +0000 + + bevy_reflect: Fix misplaced impls (#6829) + + # Objective + + > Followup to [this](https://github.com/bevyengine/bevy/pull/6755#discussion_r1032671178) comment + + Rearrange the impls in the `impls/std.rs` file. + + The issue was that I had accidentally misplaced the impl for `Option` and put it between the `Cow<'static, str>` impls. This is just a slight annoyance and readability issue. + + ## Solution + + Move the `Option` and `&'static Path` impls around to be more readable. + +commit 919188074c9d0009ae84bfa1a69ff04ae8e80774 +Author: Ptipiak +Date: Fri Dec 2 18:22:25 2022 +0000 + + Mention search filters in CONTRIBUTING.md (#6804) + + * Adding a new section concerning the maintainers of the repo + + # Objective + + - Adding a few helpful links in the CONTRIBUTING.md files + - Fixes #6221 + + ## Solution + + - Modifying CONTRIBUTING.md + - Adding a new section dedicated to maintainers in CONTRIBUTING.md + + --- + + + Co-authored-by: Ptipiak + +commit c7d2cb14d0d33d4c38f49432066dd40df6f862e7 +Author: ira +Date: Fri Dec 2 02:36:44 2022 +0000 + + Add methods `intersect_plane` and `get_point` to `Ray` (#6179) + + + + Co-authored-by: devil-ira + +commit 9b72780b82bc6be1ee916712de34dbe4fd761a81 +Author: Aleksandr Belkin +Date: Fri Dec 2 02:21:22 2022 +0000 + + Provide public `EntityRef::get_change_ticks_by_id` that takes `ComponentId` (#6683) + + # Objective + + Fixes #6682 + + ## Solution + + Add `EntityRef::get_change_ticks_by_id` + Add `EntityMut::get_change_ticks_by_id` + + + Co-authored-by: Aleksandr Belkin + +commit e89b0432106afce78585715f95c6f15c52e3da67 +Author: 罗智芃 +Date: Thu Dec 1 15:19:54 2022 +0000 + + Fix material alpha_mode in example global_vs_local_translation (#6658) + + # Objective + + The global_vs_local_translation example tries to use transparency to identify static cubes, but the materials of those cubes aren't transparent. + + ## Solution + + Change material alpha_mode to `AlphaMode::Blend` for those cubes. + +commit 8faa12c5d6a2f43dabb061234cb9c85cf785665e +Author: Mike +Date: Thu Dec 1 01:30:55 2022 +0000 + + pin nightly to 2022-11-28 to fix miri (#6808) + + # Objective + + - pin nightly to 2022-11-28 to fix miri + +commit 0e9c6dddb21d9cab0f0a42e006e4de8de0db6796 +Author: Mike +Date: Thu Dec 1 00:27:54 2022 +0000 + + try to fix run-examples (#6810) + + # Objective + + - run examples is failing with `xvfb-run: error: Xvfb failed to start` + + ## Solution + + - rollback ubuntu version for run-examples to 20.04. latest is 22.04 + + ## Notes + + - this is just a quick fix and someone should probably get it working on 22.04. I'll make an issue for that if this gets merged. + +commit b91356bd63adbc8a1ea236f557e39d121a780612 +Author: Marco Buono +Date: Wed Nov 30 02:44:05 2022 +0000 + + Add note about global `.gitignore` to `CONTRIBUTING.md` — Instead of ignoring `.DS_Store` files created by macOS Finder (#6499) + + # Objective + + Finder in macOS creates hidden `.DS_Store` files containing metadata (for icon positioning, view mode, etc) whenever you browse a directory. There's no point in committing these to git, and they're a common git + macOS nuisance. + + ## Solution + + - ~~This PR adds `.DS_Store` files to `.gitignore`, improving the developer experience on macOS.~~ + - This PR adds a note to the `CONTRIBUTING.md` file teaching how to use global git ignore. + +commit e954b8573c085a01c62007c4c6232870e0b5c891 +Author: James Liu +Date: Mon Nov 28 20:39:02 2022 +0000 + + Lock down access to Entities (#6740) + + # Objective + The soundness of the ECS `World` partially relies on the correctness of the state of `Entities` stored within it. We're currently allowing users to (unsafely) mutate it, as well as readily construct it without using a `World`. While this is not strictly unsound so long as users (including `bevy_render`) safely use the APIs, it's a fairly easy path to unsoundness without much of a guard rail. + + Addresses #3362 for `bevy_ecs::entity`. Incorporates the changes from #3985. + + ## Solution + Remove `Entities`'s `Default` implementation and force access to the type to only be through a properly constructed `World`. + + Additional cleanup for other parts of `bevy_ecs::entity`: + + - `Entity::index` and `Entity::generation` are no longer `pub(crate)`, opting to force the rest of bevy_ecs to use the public interface to access these values. + - `EntityMeta` is no longer `pub` and also not `pub(crate)` to attempt to cut down on updating `generation` without going through an `Entities` API. It's currently inaccessible except via the `pub(crate)` Vec on `Entities`, there was no way for an outside user to use it. + - Added `Entities::set`, an unsafe `pub(crate)` API for setting the location of an Entity (parallel to `Entities::get`) that replaces the internal case where we need to set the location of an entity when it's been spawned, moved, or despawned. + - `Entities::alloc_at_without_replacement` is only used in `World::get_or_spawn` within the first party crates, and I cannot find a public use of this API in any ecosystem crate that I've checked (via GitHub search). + - Attempted to document the few remaining undocumented public APIs in the module. + + --- + + ## Changelog + Removed: `Entities`'s `Default` implementation. + Removed: `EntityMeta` + Removed: `Entities::alloc_at_without_replacement` and `AllocAtWithoutReplacement`. + + Co-authored-by: james7132 + Co-authored-by: James Liu + +commit 9c79b39d736b2398d759e5ba0900032cf118480b +Author: François +Date: Mon Nov 28 19:27:04 2022 +0000 + + set AVAILABLE_STORAGE_BUFFER_BINDINGS to the actual number of buffers available (#6787) + + # Objective + + - Since #5900 3d examples fail in wasm + ``` + ERROR crates/bevy_render/src/render_resource/pipeline_cache.rs:660 failed to process shader: Unknown shader def: 'AVAILABLE_STORAGE_BUFFER_BINDINGS' + ``` + + ## Solution + + - Fix it by always adding the shaderdef `AVAILABLE_STORAGE_BUFFER_BINDINGS` with the actual value, instead of 3 when 3 or more were available + +commit 0d833a3ebcb777c9bafb292ed9cf0fe2a3cec07d +Author: 张林伟 +Date: Mon Nov 28 14:55:26 2022 +0000 + + Register Hash for glam types (#6786) + + # Objective + + - fixes https://github.com/bevyengine/bevy/issues/6736 + + ## Solution + + - Register `Hash` on all of glam's reflected integer vector types. + +commit 295faa02fc7f8b5e208344bd73caa29119ddeabe +Author: Griffin +Date: Mon Nov 28 14:14:08 2022 +0000 + + Add support for Rgb9e5Ufloat textures (#6781) + + # Objective + + - Support textures in `Rgb9e5Ufloat` format. + + ## Solution + + - Add `TextureFormatPixelInfo` for `Rgb9e5Ufloat`. + + Tested this with a `Rgb9e5Ufloat` encoded KTX2 texture. + +commit 7963bb9ab3ad3d385e29add351198e49b3537008 +Author: KazaniAvali <39241153+R2Boyo25@users.noreply.github.com> +Date: Mon Nov 28 13:54:15 2022 +0000 + + Docs: amdgpu-pro-vulkan on Gentoo. (#6749) + + When running Bevy on Gentoo using an AMD Radeon GPU, it panics unless `amdgpu-pro-vulkan` has been installed (and it took quite a bit of experimentation to find this information). This PR adds a mention of this to the linux dependencies documentation. + +commit f119d9df8e23b5074cc153df85b4edbdc5eb0129 +Author: IceSentry +Date: Mon Nov 28 13:54:13 2022 +0000 + + Add DrawFunctionsInternals::id() (#6745) + + # Objective + + - Every usage of `DrawFunctionsInternals::get_id()` was followed by a `.unwrap()`. which just adds boilerplate. + + ## Solution + + - Introduce a fallible version of `DrawFunctionsInternals::get_id()` and use it where possible. + - I also took the opportunity to improve the error message a little in the case where it fails. + + --- + + ## Changelog + + - Added `DrawFunctionsInternals::id()` + +commit d79888bdaec5394b0813db608e12fa35748fd04e +Author: James Liu +Date: Mon Nov 28 13:54:12 2022 +0000 + + Document and lock down types in bevy_ecs::archetype (#6742) + + # Objective + Document `bevy_ecs::archetype` and and declutter the public documentation for the module by making types non-`pub`. + + Addresses #3362 for `bevy_ecs::archetype`. + + ## Solution + - Add module level documentation. + - Add type and API level documentation for all public facing types. + - Make `ArchetypeId`, `ArchetypeGeneration`, and `ArchetypeComponentId` truly opaque IDs that are not publicly constructable. + - Make `AddBundle` non-pub, make `Edges::get_add_bundle` return a `Option` and fork the existing function into `Edges::get_add_bundle_internal`. + - Remove `pub(crate)` on fields that have a corresponding pub accessor function. + - Removed the `Archetypes: Default` impl, opting for a `pub(crate) fn new` alternative instead. + + --- + + ## Changelog + Added: `ArchetypeGeneration` now implements `Ord` and `PartialOrd`. + Removed: `Archetypes`'s `Default` implementation. + Removed: `Archetype::new` and `Archetype::is_empty`. + Removed: `ArchetypeId::new` and `ArchetypeId::value`. + Removed: `ArchetypeGeneration::value` + Removed: `ArchetypeIdentity`. + Removed: `ArchetypeComponentId::new` and `ArchetypeComponentId::value`. + Removed: `AddBundle`. `Edges::get_add_bundle` now returns `Option` + +commit bbb652a438b8696e3636fa184f8f1170ebb876b6 +Author: mareq +Date: Mon Nov 28 13:40:31 2022 +0000 + + Fix documentation on spawining an entity (#6775) + + # Objective + + - The documentation describing different ways to spawn an Entity is missing reference to "method" for "Spawn an entity with components". + + ## Solution + + - Update the documentation to add the reference to `World::spawn`. + +commit 161583453675c2651b0445df5d3ced639f5903f1 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Nov 28 13:40:26 2022 +0000 + + Fix an incorrect safety comment in `World::get_resource` (#6764) + + # Objective + + * Fix #6307 + + ## Solution + + * Rewrite the safety comment to reflect the actual invariants being asserted. + +commit 70d7f8056404efe76feed12b6e64dfa75fad4a72 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Nov 28 13:40:14 2022 +0000 + + Make adding children idempotent (#6763) + + # Objective + + * Fix #6668 + * There is no need to panic when a parenting operation is redundant, as no invalid state is entered. + + ## Solution + + Make `push_children` idempotent. + +commit 416a33e6133064a557b88e75652584da260ad292 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Nov 28 13:40:10 2022 +0000 + + Add const `Entity::PLACEHOLDER` (#6761) + + # Objective + + One of the use-cases for the function `Entity::from_raw` is creating placeholder entity ids, which are meant to be overwritten later. If we use a constant for this instead of `from_raw`, it is more ergonomic and self-documenting. + + ## Solution + + Add a constant that returns an entity ID with an index of `u32::MAX` and a generation of zero. Users are instructed to overwrite this value before using it. + +commit 2364a305c06cd5b77c9ff3f595d0cbcdea52c13a +Author: SpecificProtagonist +Date: Mon Nov 28 13:39:47 2022 +0000 + + Clarify duplicate logger error (#6757) + + # Objective + + When a global tracing subscriber has already been set, `LogPlugin` panics with an error message explaining this. However, if a global logger has already been set, it simply panics on an unwrap. + + #6426 mentiones the panic and has been fixed by unique plugins, but the panic can still occur if a logger has been set through different means or multiple apps are created, as in #4934. The solution to that specific case isn't clear; this PR only fixes the missing error message. + + ## Solution + + - ~add error message to panic~ + - turn into warning + +commit 64642fbd3cd196ee64280cbba2ba5e8f0bb01202 +Author: IceSentry +Date: Mon Nov 28 13:15:03 2022 +0000 + + Remove unnecessary struct in Material AsBindGroup example (#6701) + + # Objective + + - Reduce confusion around uniform bindings in materials. I've seen multiple people on discord get confused by it because it uses a struct that is named the same in the rust code and the wgsl code, but doesn't contain the same data. Also, the only reason this works is mostly by chance because the memory happens to align correctly. + + ## Solution + + - Remove the confusing parts of the doc + + ## Notes + + It's not super clear in the diff why this causes confusion, but essentially, the rust code defines a `CustomMaterial` struct with a color and a texture, but in the wgsl code the struct with the same name only contains the color. People are confused by it because the struct in wgsl doesn't need to be there. + + You _can_ have complex structs on each side and the macro will even combine it for you if you reuse a binding index, but as it is now, this example seems to confuse more than help people. + +commit 523072902cecad440b5d2109077e437fcb7580b6 +Author: Hennadii Chernyshchyk +Date: Sun Nov 27 17:28:06 2022 +0000 + + Fix reflection for PathBuf and OsString (#6776) + + # Objective + + - `PathBuf` and `OsString` not reflected correctly. + + ## Solution + + - Add missing registrations. + - Add FromReflect impls. + - Always implement `Reflect` for `OsString` just skip `Serialize` and `Deserialize` for unsupported platforms. + + --- + + ## Changelog + + ## Fixed + + - Fix reflection for `PathBuf` and `OsString`. + +commit ca74271d07f5dae1f26bb6e96df93d3728940205 +Author: Mitchell Henry +Date: Sun Nov 27 01:28:17 2022 +0000 + + Fix docs typo (#6771) + + # Objective + + - Fix a small typo + + ## Solution + + - Type them correctly :D + +commit 17b7025a78fe7a6867167707da7633a1af3322e5 +Author: IceSentry +Date: Sat Nov 26 13:10:11 2022 +0000 + + Fix set_cursor_grab_mode to try an alternative mode before giving an error (#6599) + + # Objective + + - Closes https://github.com/bevyengine/bevy/issues/6590 + - The grab mode is platform dependent, this is problematic for bevy users since we can't easily use the recommended way to detect if the feature works like the winit docs recommend https://docs.rs/winit/0.27.5/winit/window/struct.Window.html#method.set_cursor_grab + + ## Solution + + Try to use the grab mode that was requested, if it fails use the other one. Only then log an error if it fails after this step. + +commit 03bde74766307d881838095e257c0ef38d947142 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Fri Nov 25 23:49:26 2022 +0000 + + impl `Reflect` for `&'static Path` (#6755) + + # Objective + + Fixes #6739 + + ## Solution + + Implement the required traits. They cannot be implemented for `Path` directly, since it is a dynamically-sized type. + +commit d1528dfbf80ec1cff29f8a8ce2004808156031a4 +Author: Rob Parrett +Date: Fri Nov 25 23:49:25 2022 +0000 + + Warn instead of erroring when max_font_atlases is exceeded (#6673) + + # Objective + + Fixes #6642 + + In a way that doesn't create any breaking changes, as a possible way to fix the above in a patch release. + + ## Solution + + Don't actually remove font atlases when `max_font_atlases` is exceeded. Add a warning instead. + + Keep `TextError::ExceedMaxTextAtlases` and `TextSettings` as-is so we don't break anything. + + This is a bit of a cop-out, but the problems revealed by #6642 seem very challenging to fix properly. + + Maybe follow up later with something more like https://github.com/rparrett/bevy/commits/remove-max-font-atlases later, if this is the direction we want to go. + + ## Note + + See previous attempt at a "simple fix" that only solved some of the issues: #6666 + +commit c8c6aba80e31d799f104e70e24d1e6490d559a24 +Author: Gino Valente +Date: Fri Nov 25 23:30:21 2022 +0000 + + bevy_reflect: Remove `ReflectSerialize` and `ReflectDeserialize` registrations from most glam types (#6580) + + # Objective + + > Part of #6573 + + When serializing a `DynamicScene` we end up treating almost all non-value types as though their type data doesn't exist. This is because when creating the `DynamicScene` we call `Reflect::clone_value` on the components, which generates a Dynamic type for all non-value types. + + What this means is that the `glam` types are treated as though their `ReflectSerialize` registrations don't exist. However, the deserializer _does_ pick up the registration and attempts to use that instead. This results in the deserializer trying to operate on "malformed" data, causing this error: + + ``` + WARN bevy_asset::asset_server: encountered an error while loading an asset: Expected float + ``` + + ## Solution + + Ideally, we should better handle the serialization of possibly-Dynamic types. However, this runs into issues where the `ReflectSerialize` expects the concrete type and not a Dynamic representation, resulting in a panic: + + https://github.com/bevyengine/bevy/blob/0aa4147af6d583c707863484d6a8ad50ed0ed984/crates/bevy_reflect/src/type_registry.rs#L402-L413 + + Since glam types are so heavily used in Bevy (specifically in `Transform` and `GlobalTransform`), it makes sense to just a quick fix in that enables them to be used properly in scenes while a proper solution is found. + + This PR simply removes all `ReflectSerialize` and `ReflectDeserialize` registrations from the glam types that are reflected as structs. + + --- + + ## Changelog + + - Remove `ReflectSerialize` and `ReflectDeserialize` registrations from most glam types + + ## Migration Guide + + This PR removes `ReflectSerialize` and `ReflectDeserialize` registrations from most glam types. This means any code relying on either of those type data existing for those glam types will need to not do that. + + This also means that some serialized glam types will need to be updated. For example, here is `Affine3A`: + + ```rust + // BEFORE + ( + "glam::f32::affine3a::Affine3A": (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0), + + // AFTER + "glam::f32::affine3a::Affine3A": ( + matrix3: ( + x_axis: ( + x: 1.0, + y: 0.0, + z: 0.0, + ), + y_axis: ( + x: 0.0, + y: 1.0, + z: 0.0, + ), + z_axis: ( + x: 0.0, + y: 0.0, + z: 1.0, + ), + ), + translation: ( + x: 0.0, + y: 0.0, + z: 0.0, + ), + ) + ) + ``` + +commit 056272413f0ab33c71343d8a9d5c7a714027b939 +Author: François +Date: Fri Nov 25 23:02:56 2022 +0000 + + Move Android example to its own package (#6759) + + # Objective + + - Fix CI issue with updated `cargo-app` + + ## Solution + + - Move the Android example to its own package. It's not necessary for the CI fix, but it's cleaner, mimic the iOS example, and easier to reuse for someone wanting to setup android support in their project + - Build the package in CI instead of the example + + + The Android example is still working on my android device with this change 👍 + +commit 3827316100845a00eba90c3623709f06c8de27ad +Author: Gino Valente +Date: Wed Nov 23 00:41:21 2022 +0000 + + bevy_reflect: Register missing reflected types for `bevy_render` (#6725) + + # Objective + + Many types in `bevy_render` implemented `Reflect` but were not registered. + + ## Solution + + Register all types in `bevy_render` that impl `Reflect`. + + This also registers additional dependent types (i.e. field types). + + > Note: Adding these dependent types would not be needed using something like #5781 😉 + + --- + + ## Changelog + + - Register missing `bevy_render` types in the `TypeRegistry`: + - `camera::RenderTarget` + - `globals::GlobalsUniform` + - `texture::Image` + - `view::ComputedVisibility` + - `view::Visibility` + - `view::VisibleEntities` + - Register additional dependent types: + - `view::ComputedVisibilityFlags` + - `Vec` + +commit 8eb8ad5c4a85aeaca3a2022a1b11a4a4b6a4d19c +Author: Mike +Date: Wed Nov 23 00:41:19 2022 +0000 + + await tasks to cancel (#6696) + + # Objective + + - Fixes https://github.com/bevyengine/bevy/issues/6603 + + ## Solution + + - `Task`s will cancel when dropped, but wait until they return Pending before they actually get canceled. That means that if a task panics, it's possible for that error to get propagated to the scope and the scope gets dropped, while scoped tasks in other threads are still running. This is a big problem since scoped task can hold life-timed values that are dropped as the scope is dropped leading to UB. + + --- + + ## Changelog + + - changed `Scope` to use `FallibleTask` and await the cancellation of all remaining tasks when it's dropped. + +commit 3433a7bd68f8f59ce194430d10e66792997a2a95 +Author: Alice Cecile +Date: Wed Nov 23 00:27:29 2022 +0000 + + Remove warning about missed events due to false positives (#6730) + + # Objective + + - Reverts #5730. + - Fixes #6173, fixes #6596. + + ## Solution + + Remove the warning entirely. + + ## Changelog + + You will no longer be spammed about + + > Missed 31 `bevy_input::mouse::MouseMotion` events. Consider + reading from the `EventReader` more often (generally the best + solution) or calling Events::update() less frequently + (normally this is called once per frame). This problem is most + likely due to run criteria/fixed timesteps or consuming events + conditionally. See the Events documentation for + more information. + + when you miss events. These warnings were often (but not always) a false positive. You can still check this manually by using `ManualEventReader::missed_events` + +commit 7d57d7ac0c967a4ee6a11eb984fe06f09391f554 +Author: ira +Date: Wed Nov 23 00:27:28 2022 +0000 + + Remove `BuildWorldChildren` impl from `WorldChildBuilder` (#6727) + + # Objective + Remove an obscure and inconsistent bit of API. + Simplify the `WorldChildBuilder` code. + + No idea why this even exists. + + An example of the removed API: + ```rust + world.spawn_empty().with_children(|parent| { + parent.spawn_empty(); + parent.push_children(&[some_entity]); // Does *not* add children to the parent. + // It's actually identical to: + parent.spawn_empty().push_children(&[some_entity]); + }); + + world.spawn_empty().with_children(|parent| { + // This just panics. + parent.push_children(&[some_entity]); + }); + ``` + This exists only on `WorldChildBuilder`; `ChildBuilder` does not have this API. + + Yeet. + + ## Migration Guide + Hierarchy editing methods such as `with_children` and `push_children` have been removed from `WorldChildBuilder`. + You can edit the hierarchy via `EntityMut` instead. + + Co-authored-by: devil-ira + +commit 4e2374334fe68e57834a7069b3f098e175736155 +Author: Gino Valente +Date: Wed Nov 23 00:01:36 2022 +0000 + + bevy_reflect: Fix binary deserialization not working for unit structs (#6722) + + # Objective + + Fixes #6713 + + Binary deserialization is failing for unit structs as well as structs with all ignored/skipped fields. + + ## Solution + + Add a check for the number of possible fields in a struct before deserializing. If empty, don't attempt to deserialize any fields (as there will be none). + + Note: ~~This does not apply to enums as they do not properly handle skipped fields (see #6721).~~ Enums still do not properly handle skipped fields, but I decided to include the logic for it anyways to account for `#[reflect(ignore)]`'d fields in the meantime. + + --- + + ## Changelog + + - Fix bug where deserializing unit structs would fail for non-self-describing formats + +commit a1607b8065f4c8a97f763093d2204d5e9dde9e93 +Author: ira +Date: Tue Nov 22 20:38:35 2022 +0000 + + Rename `EntityId` to `EntityIndex` (#6732) + + Continuation of #6107 + + Co-authored-by: devil-ira + +commit c069c544a769a5e983b027de06b4810c57650271 +Author: Aevyrie +Date: Tue Nov 22 15:55:50 2022 +0000 + + Fix missing sRGB conversion for dithering non-HDR pipelines (#6707) + + # Objective + + - Fixes #6706 + + Zoom in on the shadow in the following images: + + ## Current bevy/main + + ### HDR On - correct + ![current-hdron](https://user-images.githubusercontent.com/2632925/202943151-ecad3cbe-a76e-46df-bac9-9e590a31a9f3.png) + + ### HDR Off - incorrect + ![current-hdroff](https://user-images.githubusercontent.com/2632925/202943154-34e3f527-a00e-4546-931d-0691204cc6a4.png) + + ## This PR + + ### HDR On - correct + ![new-hdron](https://user-images.githubusercontent.com/2632925/202943383-081990de-9a14-45bd-ac52-febcc4289079.png) + + ### HDR Off - corrected + ![new-hdroff](https://user-images.githubusercontent.com/2632925/202943388-a3b05d79-a0f3-4b1e-b114-0a9f03efe351.png) + + ## Close-up comparison + + ### New + ![Screenshot from 2022-11-20 17-46-46](https://user-images.githubusercontent.com/2632925/202943552-d45c3a48-841e-47a6-981f-776c5a9563f6.png) + + ### Old + ![Screenshot from 2022-11-20 17-46-41](https://user-images.githubusercontent.com/2632925/202943562-555cb5a2-2b20-45f9-b250-89f2bc87af5f.png) + + ## Solution + + - It turns out there was an outright missing sRGB conversion for dithering non-HDR cameras. + - I also tried using a precise sRGB conversion, but it had no apparent effect on the final image. + + --- + + ## Changelog + + - Fix deband dithering intensity for non-HDR pipelines. + +commit cf46dd2e7ed2085bbd60d25cafca8219d62ef2ec +Author: Jakob Hellermann +Date: Tue Nov 22 15:31:18 2022 +0000 + + fix mutable aliases for a very short time if `WorldCell` is already borrowed (#6639) + + # Objective + + Consider the test + ```rust + let cell = world.cell(); + let _value_a = cell.resource_mut::(); + let _value_b = cell.resource_mut::(); + ``` + + Currently, this will roughly execute + + ```rust + // first call + let value = unsafe { + self.world + .get_non_send_unchecked_mut_with_id(component_id)? + }; + return Some(WorldBorrowMut::new(value, archetype_component_id, self.access))) + + // second call + let value = unsafe { + self.world + .get_non_send_unchecked_mut_with_id(component_id)? + }; + return Some(WorldBorrowMut::new(value, archetype_component_id, self.access))) + ``` + where `WorldBorrowMut::new` will panic if the resource is already borrowed. + + This means, that `_value_a` will be created, the access checked (OK), then `value_b` will be created, and the access checked (`panic`). + For a moment, both `_value_a` and `_value_b` existed as `&mut T` to the same location, which is insta-UB as far as I understand it. + + ## Solution + Flip the order so that `WorldBorrowMut::new` first checks the access, _then_ fetches creates the value. To do that, we pass a `impl FnOnce() -> Mut` instead of the `Mut` directly: + + ```rust + let get_value = || unsafe { + self.world + .get_non_send_unchecked_mut_with_id(component_id)? + }; + return Some(WorldBorrowMut::new(get_value, archetype_component_id, self.access))) + ``` + +commit d44e86507f66d2cbe2472557d2a2abb9c4f80a83 +Author: François +Date: Mon Nov 21 22:38:29 2022 +0000 + + Shader defs can now have a value (#5900) + + # Objective + + - shaders defs can now have a `bool` or `int` value + - `#if SHADER_DEF 3` + - ok if `SHADER_DEF` is defined, has the correct type and pass the comparison + - `==`, `!=`, `>=`, `>`, `<`, `<=` supported + - `#SHADER_DEF` or `#{SHADER_DEF}` + - will be replaced by the value in the shader code + --- + + ## Migration Guide + + - replace `shader_defs.push(String::from("NAME"));` by `shader_defs.push("NAME".into());` + - if you used shader def `NO_STORAGE_BUFFERS_SUPPORT`, check how `AVAILABLE_STORAGE_BUFFER_BINDINGS` is now used in Bevy default shaders + +commit daa57fe489fe708b18c7805531903d0681e3c957 +Author: Torstein Grindvik +Date: Mon Nov 21 21:58:39 2022 +0000 + + Add try_* to add_slot_edge, add_node_edge (#6720) + + # Objective + + `add_node_edge` and `add_slot_edge` are fallible methods, but are always used with `.unwrap()`. + `input_node` is often unwrapped as well. + This points to having an infallible behaviour as default, with an alternative fallible variant if needed. + + Improves readability and ergonomics. + + ## Solution + + - Change `add_node_edge` and `add_slot_edge` to panic on error. + - Change `input_node` to panic on `None`. + - Add `try_add_node_edge` and `try_add_slot_edge` in case fallible methods are needed. + - Add `get_input_node` to still be able to get an `Option`. + --- + + ## Changelog + + ### Added + + - `try_add_node_edge` + - `try_add_slot_edge` + - `get_input_node` + + ### Changed + + - `add_node_edge` is now infallible (panics on error) + - `add_slot_edge` is now infallible (panics on error) + - `input_node` now panics on `None` + + ## Migration Guide + + Remove `.unwrap()` from `add_node_edge` and `add_slot_edge`. + For cases where the error was handled, use `try_add_node_edge` and `try_add_slot_edge` instead. + + Remove `.unwrap()` from `input_node`. + For cases where the option was handled, use `get_input_node` instead. + + + Co-authored-by: Torstein Grindvik <52322338+torsteingrindvik@users.noreply.github.com> + +commit e2d1d9dff84455f650a591e39d603ce36cfafd83 +Author: Chris Juchem +Date: Mon Nov 21 20:12:31 2022 +0000 + + Update dead links in DefaultPlugins docs (#6695) + + # Objective + + - Fix dead links on this docs page: https://docs.rs/bevy/0.9.0/bevy/struct.DefaultPlugins.html + + ## Solution + + - Point links to the imported versions instead of the versions in external crates. + +commit eaeba0866db25fd10eb3bbc2718eab8256e1f19f +Author: James Liu +Date: Mon Nov 21 18:18:38 2022 +0000 + + Parallelized transform propagation (#4775) + + # Objective + Fixes #4697. Hierarchical propagation of properties, currently only Transform -> GlobalTransform, can be a very expensive operation. Transform propagation is a strict dependency for anything positioned in world-space. In large worlds, this can take quite a bit of time, so limiting it to a single thread can result in poor CPU utilization as it bottlenecks the rest of the frame's systems. + + ## Solution + + - Move transforms without a parent or a child (free-floating (Global)Transform) entities into a separate parallel system. + - Chunk the hierarchy based on the root entities and process it in parallel with `Query::par_for_each_mut`. + - Utilize the hierarchy's specific properties introduced in #4717 to allow for safe use of `Query::get_unchecked` on multiple threads. Assuming each child is unique in the hierarchy, it is impossible to have an aliased `&mut GlobalTransform` so long as we verify that the parent for a child is the same one propagated from. + + --- + + ## Changelog + Removed: `transform_propagate_system` is no longer `pub`. + +commit 585dac058226b205d586873965c8dcb747ba53e1 +Author: Chia-Hsiang Cheng +Date: Mon Nov 21 14:38:35 2022 +0000 + + Remove auto-margin properties from the examples (#6535) + + # Objective + + Fixes #6498. + + ## Solution + + Adding a parent node with properties AlignItems::Center and JustifyContent::Center to centered child nodes and removing their auto-margin properties. + +commit 96e09f004b24d257781ba0aa715c2904def5d56a +Author: Ida Iyes +Date: Mon Nov 21 14:23:21 2022 +0000 + + Fix PipeSystem panicking with exclusive systems (#6698) + + Without this fix, piped systems containing exclusive systems fail to run, giving a runtime panic. + With this PR, running piped systems that contain exclusive systems now works. + + ## Explanation of the bug + + This is because, unless overridden, the default implementation of `run` from the `System` trait simply calls `run_unsafe`. That is not valid for exclusive systems. They must always be called via `run`, as `run_unsafe` takes `&World` instead of `&mut World`. + + Trivial reproduction example: + ```rust + fn main() { + App::new() + .add_plugins(DefaultPlugins) + .add_system(exclusive.pipe(another)) + .run(); + } + + fn exclusive(_world: &mut World) {} + fn another() {} + ``` + If you run this, you will get a panic 'Cannot run exclusive systems with a shared World reference' and the backtrace shows how bevy (correctly) tries to call the `run` method (because the system is exclusive), but it is the implementation from the `System` trait (because `PipeSystem` does not have its own), which calls `run_unsafe` (incorrect): + - 3: as bevy_ecs::system::system::System>::run_unsafe + - 4: bevy_ecs::system::system::System::run + +commit 174819be83611bc1b238b5bf2b131db2da16d8cf +Author: Torstein Grindvik +Date: Mon Nov 21 13:19:44 2022 +0000 + + ExtractComponent output optional associated type (#6699) + + # Objective + + Allow more use cases where the user may benefit from both `ExtractComponentPlugin` _and_ `UniformComponentPlugin`. + + ## Solution + + Add an associated type to `ExtractComponent` in order to allow specifying the output component (or bundle). + + Make `extract_component` return an `Option<_>` such that components can be extracted only when needed. + + What problem does this solve? + + `ExtractComponentPlugin` allows extracting components, but currently the output type is the same as the input. + This means that use cases such as having a settings struct which turns into a uniform is awkward. + + For example we might have: + + ```rust + struct MyStruct { + enabled: bool, + val: f32 + } + + struct MyStructUniform { + val: f32 + } + ``` + + With the new approach, we can extract `MyStruct` only when it is enabled, and turn it into its related uniform. + + This chains well with `UniformComponentPlugin`. + + The user may then: + + ```rust + app.add_plugin(ExtractComponentPlugin::::default()); + app.add_plugin(UniformComponentPlugin::::default()); + ``` + + This then saves the user a fair amount of boilerplate. + + + ## Changelog + + ### Changed + + - `ExtractComponent` can specify output type, and outputting is optional. + + + + Co-authored-by: Torstein Grindvik <52322338+torsteingrindvik@users.noreply.github.com> + +commit 30070a926ff70d6576a403e20c24447e5b4996fa +Author: ira +Date: Mon Nov 21 13:19:43 2022 +0000 + + Add `Transform::look_to` (#6692) + + Add a method to rotate a transform to point towards a direction. + + Also updated the docs to link to `forward` and `up` instead of mentioning local negative `Z` and local `Y`. + + Unfortunately, links to methods don't work in rust-analyzer :( + + Co-authored-by: Devil Ira + +commit ed2ea0d417d3e3e7c3a486869f069385f0604579 +Author: phuocthanhdo +Date: Mon Nov 21 13:19:41 2022 +0000 + + The `update_frame_count` system should be placed in CorePlugin (#6676) + + # Objective + + Latest Release, "bevy 0.9" move the FrameCount updater into RenderPlugin, it leads to user who only run app with Core/Minimal Plugin cannot get the right number of FrameCount, it always return 0. + + As for use cases like a server app, we don't want to add render dependencies to the app. + + More detail in #6656 + + ## Solution + + - Move the `update_frame_count` into CorePlugin + +commit bdd5cee92a3ad3968f4fd7dfcf04a59fbb6e1b12 +Author: Robin KAY +Date: Mon Nov 21 13:19:40 2022 +0000 + + Add Box::from_corners method (#6672) + + # Objective + + This add a ctor to `Box` to aid the creation of non-centred boxes. The PR adopts @rezural's work on PR #3322, taking into account the feedback on that PR from @james7132. + + ## Solution + + `Box::from_corners()` creates a `Box` from two opposing corners and automatically determines the min and max extents to ensure that the `Box` is well-formed. + + Co-authored-by: rezural + +commit b3e45b75d67602a464108a14297a7ace91a1bd89 +Author: Jer +Date: Mon Nov 21 12:59:10 2022 +0000 + + Expose set_cursor_hittest() from winit (#6664) + + # Objective + + - Bevy should be usable to create 'overlay' type apps, where the input is not captured by Bevy, but passed down/into a target app, or to allow passive displays/widgets etc. + + ## Solution + + - the `winit::window::Window` already has a `set_cursor_hittest()` which basically does this for mouse input events, so I've exposed it (trying to copy the style laid out in the existing wrappings, and added a simple demo. + + --- + + ## Changelog + + - Added `hittest` to `WindowAttributes` + - Added the `hittest`'s setters/getters + - Modified the `WindowBuilder` + - Modifed the `WindowDescriptor`'s `Default` impl. + - Added an example `cargo run --example fallthrough` + +commit 55ca7fc88ebec86f6112174aaaa2b77f235b83a0 +Author: James Liu +Date: Mon Nov 21 12:59:09 2022 +0000 + + Split Component Ticks (#6547) + + # Objective + Fixes #4884. `ComponentTicks` stores both added and changed ticks contiguously in the same 8 bytes. This is convenient when passing around both together, but causes half the bytes fetched from memory for the purposes of change detection to effectively go unused. This is inefficient when most queries (no filter, mutating *something*) only write out to the changed ticks. + + ## Solution + Split the storage for change detection ticks into two separate `Vec`s inside `Column`. Fetch only what is needed during iteration. + + This also potentially also removes one blocker from autovectorization of dense queries. + + EDIT: This is confirmed to enable autovectorization of dense queries in `for_each` and `par_for_each` where possible. Unfortunately `iter` has other blockers that prevent it. + + ### TODO + + - [x] Microbenchmark + - [x] Check if this allows query iteration to autovectorize simple loops. + - [x] Clean up all of the spurious tuples now littered throughout the API + + ### Open Questions + + - ~~Is `Mut::is_added` absolutely necessary? Can we not just use `Added` or `ChangeTrackers`?~~ It's optimized out if unused. + - ~~Does the fetch of the added ticks get optimized out if not used?~~ Yes it is. + + --- + + ## Changelog + Added: `Tick`, a wrapper around a single change detection tick. + Added: `Column::get_added_ticks` + Added: `Column::get_column_ticks` + Added: `SparseSet::get_added_ticks` + Added: `SparseSet::get_column_ticks` + Changed: `Column` now stores added and changed ticks separately internally. + Changed: Most APIs returning `&UnsafeCell` now returns `TickCells` instead, which contains two separate `&UnsafeCell` for either component ticks. + Changed: `Query::for_each(_mut)`, `Query::par_for_each(_mut)` will now leverage autovectorization to speed up query iteration where possible. + + ## Migration Guide + TODO + +commit 210979f6315388dbc2b6e67217311e6056aecb36 +Author: James Liu +Date: Mon Nov 21 12:59:08 2022 +0000 + + Fix panicking on another scope (#6524) + + # Objective + Fix #6453. + + ## Solution + Use the solution mentioned in the issue by catching the unwind and dropping the error. Wrap the `executor.try_tick` calls with `std::catch::unwind`. + + Ideally this would be moved outside of the hot loop, but the mut ref to the `spawned` future is not `UnwindSafe`. + + This PR only addresses the bug, we can address the perf issues (should there be any) later. + +commit 15ea93a348a42a264c42be578fd2e2ee3b9b8738 +Author: Nicola Papale +Date: Mon Nov 21 12:37:31 2022 +0000 + + Fix size_hint for partially consumed QueryIter and QueryCombinationIter (#5214) + + # Objective + + Fix #5149 + + ## Solution + + Instead of returning the **total count** of elements in the `QueryIter` in + `size_hint`, we return the **count of remaining elements**. This + Fixes #5149 even when #5148 gets merged. + + - https://github.com/bevyengine/bevy/issues/5149 + - https://github.com/bevyengine/bevy/pull/5148 + + --- + + ## Changelog + + - Fix partially consumed `QueryIter` and `QueryCombinationIter` having invalid `size_hint` + + + Co-authored-by: Nicola Papale + +commit e0c3c6d16693c86843159007b4688f1408064275 +Author: 研究社交 +Date: Fri Nov 18 22:16:55 2022 +0000 + + Make Core Pipeline Graph Nodes Public (#6605) + + # Objective + + Make core pipeline graphic nodes, including `BloomNode`, `FxaaNode`, `TonemappingNode` and `UpscalingNode` public. + This will allow users to construct their own render graphs with these build-in nodes. + + ## Solution + + Make them public. + Also put node names into bevy's core namespace (`core_2d::graph::node`, `core_3d::graph::node`) which makes them consistent. + +commit cb8fe5b7fd31e02d077e0cefa660c4e9ed7e84cd +Author: Patrick Towles +Date: Fri Nov 18 22:16:54 2022 +0000 + + Removed Mobile Touch event y-axis flip (#6597) + + # Objective + + Fix android touch events being flipped. Only removed test for android, don't have ios device to test with. Tested with emulator and physical device. + + ## Solution + + Remove check, no longer needed with coordinate change in 0.9 + +commit 2cd0bd757594083e5ebb78fed22078e51c9bcc8b +Author: robtfm <50659922+robtfm@users.noreply.github.com> +Date: Fri Nov 18 22:04:23 2022 +0000 + + improve compile time by type-erasing wgpu structs (#5950) + + # Objective + + structs containing wgpu types take a long time to compile. this is particularly bad for generics containing the wgpu structs (like the depth pipeline builder with `#[derive(SystemParam)]` i've been working on). + + we can avoid that by boxing and type-erasing in the bevy `render_resource` wrappers. + + type system magic is not a strength of mine so i guess there will be a cleaner way to achieve this, happy to take feedback or for it to be taken as a proof of concept if someone else wants to do a better job. + + ## Solution + + - add macros to box and type-erase in debug mode + - leave current impl for release mode + + timings: + + + + + + + + + + + + + + + + + + current |   |   |   + -- | -- | -- | -- +   | Total time: | 64.9s |   +   | bevy_pbr v0.9.0-dev | 19.2s |   +   | bevy_render v0.9.0-dev | 17.0s |   +   | bevy_sprite v0.9.0-dev | 15.1s |   +   | DepthPipelineBuilder | 18.7s |   +   |   |   |   + with type-erasing |   |   | diff +   | Total time: | 49.0s | -24% +   | bevy_render v0.9.0-dev | 12.0s | -38% +   | bevy_pbr v0.9.0-dev | 8.7s | -49% +   | bevy_sprite v0.9.0-dev | 6.1s | -60% +   | DepthPipelineBuilder | 1.2s | -94% + + + + + + + + the depth pipeline builder is a binary with body: + ```rust + use std::{marker::PhantomData, hash::Hash}; + use bevy::{prelude::*, ecs::system::SystemParam, pbr::{RenderMaterials, MaterialPipeline, ShadowPipeline}, render::{renderer::RenderDevice, render_resource::{SpecializedMeshPipelines, PipelineCache}, render_asset::RenderAssets}}; + + fn main() { + println!("Hello, world p!\n"); + } + + #[derive(SystemParam)] + pub struct DepthPipelineBuilder<'w, 's, M: Material> + where M::Data: Eq + Hash + Clone, + { + render_device: Res<'w, RenderDevice>, + material_pipeline: Res<'w, MaterialPipeline>, + material_pipelines: ResMut<'w, SpecializedMeshPipelines>>, + shadow_pipeline: Res<'w, ShadowPipeline>, + pipeline_cache: ResMut<'w, PipelineCache>, + render_meshes: Res<'w, RenderAssets>, + render_materials: Res<'w, RenderMaterials>, + msaa: Res<'w, Msaa>, + #[system_param(ignore)] + _p: PhantomData<&'s M>, + } + ``` + +commit 5972879deceb297a720a8da1217d37c7675f1638 +Author: ickshonpe +Date: Fri Nov 18 21:16:32 2022 +0000 + + Remove ImageMode (#6674) + + # Objective + + Delete `ImageMode`. It doesn't do anything except mislead people into thinking it controls the aspect ratio of images somehow. + + Fixes #3933 and #6637 + + ## Solution + + Delete `ImageMode` + + ## Changelog + + Removes the `ImageMode` enum. + Removes the `image_mode` field from `ImageBundle` + Removes the `With` query filter from `image_node_system` + Renames `image_node_system` to` update_image_calculated_size_system` + +commit 4209fcaeda382624950d8704a9046b052b6daca9 +Author: Lixou +Date: Fri Nov 18 21:16:31 2022 +0000 + + Make spawn_dynamic return InstanceId (#6663) + + # Objective + + Fixes #6661 + + ## Solution + + Make `SceneSpawner::spawn_dynamic` return `InstanceId` like other functions there. + + --- + + ## Changelog + + Make `SceneSpawner::spawn_dynamic` return `InstanceId` instead of `()`. + +commit 0a853f1ca64371ed734eb98f7f84c46273c6076d +Author: François +Date: Fri Nov 18 21:02:56 2022 +0000 + + wasm: pad globals uniform also in 2d (#6643) + + # Objective + + - Fix a panic in wasm when using globals in a shader + + ## Solution + + - Similar to #6460 + +commit 63c0cca0d77fabf7a9891aadada24fb9b6621235 +Author: Edgar Soares da Silva <70528288+edgarssilva@users.noreply.github.com> +Date: Fri Nov 18 20:42:33 2022 +0000 + + Update old docs from Timer (#6646) + + When I was upgrading to 0.9 noticed there were some changes to the timer, mainly the `TimerMode`. When switching from the old `is_repeating()` and `set_repeating()` to the new `mode()` and `set_mode()` noticed the docs still had the old description. + +commit a02e44c0dbea5d343a27eef614c803a3daf2c2f5 +Author: Doru +Date: Fri Nov 18 11:24:07 2022 +0000 + + Don't kill contributors on window squish (#6675) + + # Objective + + - The `contributors` example panics when attempting to generate an empty range if the window height is smaller than the sprites + - Don't do that + + ## Solution + + - Clamp the bounce height to be 0 minimum, and generate an inclusive range when passing it to `rng.gen_range` + +commit 9f51651eacddc2267f88a3b1a44af1ef58ec5d73 +Author: James Liu +Date: Wed Nov 16 20:57:43 2022 +0000 + + Replace BlobVec's swap_scratch with a swap_nonoverlapping (#4853) + + # Objective + BlobVec currently relies on a scratch piece of memory allocated at initialization to make a temporary copy of a component when using `swap_remove_and_{forget/drop}`. This is potentially suboptimal as it writes to a, well-known, but random part of memory instead of using the stack. + + ## Solution + As the `FIXME` in the file states, replace `swap_scratch` with a call to `swap_nonoverlapping::`. The swapped last entry is returned as a `OwnedPtr`. + + In theory, this should be faster as the temporary swap is allocated on the stack, `swap_nonoverlapping` allows for easier vectorization for bigger types, and the same memory is used between the swap and the returned `OwnedPtr`. + +commit 00684d95f7a58eb282f29ce0416aaad889552956 +Author: Nicola Papale +Date: Wed Nov 16 11:05:48 2022 +0000 + + Fix FilteredAccessSet get_conflicts inconsistency (#5105) + + # Objective + + * Enable `Res` and `Query` parameter mutual exclusion + * Required for https://github.com/bevyengine/bevy/pull/5080 + + The `FilteredAccessSet::get_conflicts` methods didn't work properly with + `Res` and `ResMut` parameters. Because those added their access by using + the `combined_access_mut` method and directly modifying the global + access state of the FilteredAccessSet. This caused an inconsistency, + because get_conflicts assumes that ALL added access have a corresponding + `FilteredAccess` added to the `filtered_accesses` field. + + In practice, that means that SystemParam that adds their access through + the `Access` returned by `combined_access_mut` and the ones that add + their access using the `add` method lived in two different universes. As + a result, they could never be mutually exclusive. + + ## Solution + + This commit fixes it by removing the `combined_access_mut` method. This + ensures that the `combined_access` field of FilteredAccessSet is always + updated consistently with the addition of a filter. When checking for + filtered access, it is now possible to account for `Res` and `ResMut` + invalid access. This is currently not needed, but might be in the + future. + + We add the `add_unfiltered_{read,write}` methods to replace previous + usages of `combined_access_mut`. + + We also add improved Debug implementations on FixedBitSet so that their + meaning is much clearer in debug output. + + + --- + + ## Changelog + + * Fix `Res` and `Query` parameter never being mutually exclusive. + + ## Migration Guide + + Note: this mostly changes ECS internals, but since the API is public, it is technically breaking: + * Removed `FilteredAccessSet::combined_access_mut` + * Replace _immutable_ usage of those by `combined_access` + * For _mutable_ usages, use the new `add_unfiltered_{read,write}` methods instead of `combined_access_mut` followed by `add_{read,write}` + +commit 6763b31479246afddecbe4e717e138d4e9653dca +Author: James Liu +Date: Tue Nov 15 22:21:19 2022 +0000 + + Immutable sparse sets for metadata storage (#4928) + + # Objective + Make core types in ECS smaller. The column sparse set in Tables is never updated after creation. + + ## Solution + Create `ImmutableSparseSet` which removes the capacity fields in the backing vec's and the APIs for inserting or removing elements. Drops the size of the sparse set by 3 usizes (24 bytes on 64-bit systems) + + ## Followup + ~~After #4809, Archetype's component SparseSet should be replaced with it.~~ This has been done. + + --- + + ## Changelog + Removed: `Table::component_capacity` + + ## Migration Guide + `Table::component_capacity()` has been removed as Tables do not support adding/removing columns after construction. + + Co-authored-by: Carter Anderson + +commit 11c544c29afcee66defab7aa6b13bf77b8ffe6ae +Author: James Liu +Date: Tue Nov 15 21:39:21 2022 +0000 + + Remove redundant table and sparse set component IDs from Archetype (#4927) + + # Objective + Archetype is a deceptively large type in memory. It stores metadata about which components are in which storage in multiple locations, which is only used when creating new Archetypes while moving entities. + + ## Solution + Remove the redundant `Box<[ComponentId]>`s and iterate over the sparse set of component metadata instead. Reduces Archetype's size by 4 usizes (32 bytes on 64-bit systems), as well as the additional allocations for holding these slices. + + It'd seem like there's a downside that the origin archetype has it's component metadata iterated over twice when creating a new archetype, but this change also removes the extra `Vec` allocations when creating a new archetype which may amortize out to a net gain here. This change likely negatively impacts creating new archetypes with a large number of components, but that's a cost mitigated by the fact that these archetypal relationships are cached in Edges and is incurred only once for each edge created. + + ## Additional Context + There are several other in-flight PRs that shrink Archetype: + + - #4800 merges the entities and rows Vecs together (shaves off 24 bytes per archetype) + - #4809 removes unique_components and moves it to it's own dedicated storage (shaves off 72 bytes per archetype) + + --- + + ## Changelog + Changed: `Archetype::table_components` and `Archetype::sparse_set_components` return iterators instead of slices. `Archetype::new` requires iterators instead of parallel slices/vecs. + + ## Migration Guide + Do I still need to do this? I really hope people were not relying on the public facing APIs changed here. + +commit 51aab032edcb2e97befe19ea985d35758c5e7e6d +Author: James Liu +Date: Tue Nov 15 20:31:17 2022 +0000 + + Bump gilrs version to 0.10 (#6558) + + # Objective + Fix #6555. + + ## Solution + Bump `gilrs` version to 0.10. + +commit 688f13cd838efb1c0c44f2aa20ed844b45d6115f +Author: James Liu +Date: Tue Nov 15 00:19:11 2022 +0000 + + Fix get_unchecked_manual using archetype index instead of table row. (#6625) + + # Objective + Fix #6623. + + ## Solution + Use the right table row instead of the `EntityLocation` archetype index. + +commit 342f69e304d2df5a41ba5a77020a10de8f7d900a +Author: James Liu +Date: Mon Nov 14 23:34:52 2022 +0000 + + Shrink ComputedVisibility (#6305) + + # Objective + `ComputedVisibility` could afford to be smaller/faster. Optimizing the size and performance of operations on the component will positively benefit almost all extraction systems. + + This was listed as one of the potential pieces of future work for #5310. + + ## Solution + Merge both internal booleans into a single `u8` bitflag field. Rely on bitmasks to evaluate local, hierarchical, and general visibility. + + Pros: + + - `ComputedVisibility::is_visible` should be a single bitmask test instead of two. + - `ComputedVisibility` is now only 1 byte. Should be able to fit 100% more per cache line when using dense iteration. + + Cons: + + - Harder to read. + - Setting individual values inside `ComputedVisiblity` require bitmask mutations. + + This should be a non-breaking change. No public API was changed. The only publicly visible effect is that `ComputedVisibility` is now 1 byte instead of 2. + +commit 8ebd4d909ce905b33e71a0678ae601afb509085c +Author: Mike +Date: Mon Nov 14 23:08:31 2022 +0000 + + add span to winit event handler (#6612) + + # Objective + + - Add a span for the winit event handler. I've found this useful in my PR for pipelined rendering and I've seen it come up in a few other contexts now. + + ![image](https://user-images.githubusercontent.com/2180432/201588888-5dc02063-2c41-471b-8937-a71aeaf174b4.png) + +commit eaa35cf99fac8df2ad1b0b682fb37db04feb028a +Author: Hsiang-Cheng Yang +Date: Mon Nov 14 23:08:30 2022 +0000 + + use `Mul` to double the value of `Vec3` (#6607) + + improve the example code + +commit 6993f3cfe392e00437ba9f9798031f44e9b5a2b5 +Author: Daniél Kerkmann +Date: Mon Nov 14 23:08:29 2022 +0000 + + Make function `Size::new` const for `bevy_ui` `widgets` (#6602) + + # Objective + + Fixes #6594 + + ## Solution + + - `New` function for `Size` is now a `const` function :) + + ## Changelog + + - `New` function for `Size` is now a `const` function + + ## Migration Guide + + - Nothing has been changed + +commit 13abb1fc16b1d968db0b7b8ea70b8e096623fc06 +Author: Alessandro Salvatore Nicosia +Date: Mon Nov 14 23:08:28 2022 +0000 + + derived Debug on EventReader (#6600) + + # Objective + Fixes #6588 + + ## Solution + + Added Debug to the derived traits of EventReader. + +commit b2090e3a8db94e68693bb00a2486d160bd35df7f +Author: Jakob Hellermann +Date: Mon Nov 14 23:08:27 2022 +0000 + + add `Resources::iter` to iterate over all resource IDs (#6592) + + # Objective + + In bevy 0.8 you could list all resources using `world.archetypes().resource().components()`. As far as I can tell the resource archetype has been replaced with the `Resources` storage, and it would be nice if it could be used to iterate over all resource component IDs as well. + + ## Solution + + - add `fn Resources::iter(&self) -> impl Iterator` + +commit 69011b7e268433e4a1b7eeefc595f93ec3da51a7 +Author: Johan Klokkhammer Helsing +Date: Mon Nov 14 23:08:26 2022 +0000 + + Derive clone and debug for `AssetPlugin` (#6583) + + # Objective + + - Derive Clone and Debug for `AssetPlugin` + - Make it possible to log asset server settings + - And get an owned instance if wrapping `AssetPlugin` in another plugin. See: https://github.com/johanhelsing/bevy_web_asset/blob/129224ef72a609ce54088f01183f6962fed8780e/src/web_asset_plugin.rs#L45 + +commit 8f9556050ad51748146572aeb477e1842f755761 +Author: 张林伟 +Date: Mon Nov 14 23:08:24 2022 +0000 + + Make WindowId::primary() const (#6582) + + # Objective + + - fixes https://github.com/bevyengine/bevy/issues/6577 + + ## Solution + + - simply add `const` to `primary()`. + +commit 1f8cc9dd678e9655f1a02617a858af001b8e2969 +Author: Gino Valente +Date: Mon Nov 14 23:08:23 2022 +0000 + + bevy_scene: Add missing registration for `SmallVec<[Entity; 8]>` (#6578) + + # Objective + + > Part of #6573 + + `Children` was not being properly deserialized in scenes. This was due to a missing registration on `SmallVec<[Entity; 8]>`, which is used by `Children`. + + ## Solution + + Register `SmallVec<[Entity; 8]>`. + + --- + + ## Changelog + + - Registered `SmallVec<[Entity; 8]>` + +commit af2a1992549f9ea0a529c80cbf069c40e362b08a +Author: Zhell +Date: Mon Nov 14 23:08:22 2022 +0000 + + [Fixes #6030] Bevy scene optional serde (#6076) + + # Objective + + Fixes #6030, making ``serde`` optional. + + ## Solution + + This was solved by making a ``serialize`` feature that can activate ``serde``, which is now optional. + + When ``serialize`` is deactivated, the ``Plugin`` implementation for ``ScenePlugin`` does nothing. + + + Co-authored-by: Linus Käll + +commit f2f8f9097f13081389e1377a151d5ab10606e78d +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Nov 14 22:53:50 2022 +0000 + + Add safe constructors for untyped pointers `Ptr` and `PtrMut` (#6539) + + # Objective + + Currently, `Ptr` and `PtrMut` can only be constructed via unsafe code. This means that downgrading a reference to an untyped pointer is very cumbersome, despite being a very simple operation. + + ## Solution + + Define conversions for easily and safely constructing untyped pointers. This is the non-owned counterpart to `OwningPtr::make`. + + Before: + + ```rust + let ptr = unsafe { PtrMut::new(NonNull::from(&mut value).cast()) }; + ``` + + After: + + ```rust + let ptr = PtrMut::from(&mut value); + ``` + + + Co-authored-by: Carter Anderson + +commit 635320f1726cca24bf6058b60ada1e01f05c9ca4 +Author: laundmo +Date: Mon Nov 14 22:34:29 2022 +0000 + + Expose winit always_on_top (#6527) + + # Objective + + I needed a window which is always on top, to create a overlay app. + + ## Solution + + expose the `always_on_top` property of winit in bevy's `WindowDescriptor` as a boolean flag + + --- + + ## Changelog + + ### Added + - add `WindowDescriptor.always_on_top` which configures a window to stay on top. + +commit b765682c6e02407a0005c78dde1b14f83c1cc6d7 +Author: Lixou +Date: Mon Nov 14 22:34:28 2022 +0000 + + Add AutoMax next to ScalingMode::AutoMin (#6496) + + # Objective + + `ScalingMode::Auto` for cameras only targets min_height and min_width, or as the docs say it `Use minimal possible viewport size while keeping the aspect ratio.` + + But there is no ScalingMode that targets max_height and Max_width or `Use maximal possible viewport size while keeping the aspect ratio.` + + ## Solution + + Added `ScalingMode::AutoMax` that does the exact opposite of `ScalingMode::Auto` + + --- + + ## Changelog + + Renamed `ScalingMode::Auto` to `ScalingMode::AutoMin`. + + ## Migration Guide + + just rename `ScalingMode::Auto` to `ScalingMode::AutoMin` if you are using it. + + + Co-authored-by: Lixou <82600264+DasLixou@users.noreply.github.com> + +commit db0d7698e27959eb25d135310f565af6ec8ddf6e +Author: 2ne1ugly +Date: Mon Nov 14 22:34:27 2022 +0000 + + Change `From` to `TryFrom` (#6484) + + # Objective + + - Fixes #6476 + + ## Solution + + - Return error instead of panic through `TryFrom` + - ~~Add `.except()` in examples~~ + - Add `.unwrap()` in examples + +commit 4de4e54755a975fbc3d7bd544466cc9a1acb042a +Author: Jakub Arnold +Date: Mon Nov 14 22:34:26 2022 +0000 + + Update post_processing example to not render UI with first pass camera (#6469) + + # Objective + + Make sure the post processing example won't render UI twice. + + ## Solution + + Disable UI on the first pass camera with `UiCameraConfig` + +commit dc09ee36e26737489ac7f4cf0c95778036cb1cde +Author: Yyee +Date: Mon Nov 14 22:15:46 2022 +0000 + + Add pixelated Bevy to assets and an example (#6408) + + # Objective + Fixes #2279 + + ## Solution + Added pixelated Bevy to assets folder and used in a `pixel_perfect` example. + +commit 308e092153afbfedc73d92370c6df9f8581d4da4 +Author: ira +Date: Mon Nov 14 21:59:18 2022 +0000 + + Add `Windows::get_focused(_mut)` (#6571) + + Add a method to get the focused window. + + Use this instead of `WindowFocused` events in `close_on_esc`. + Seems that the OS/window manager might not always send focused events on application startup. + + Sadly, not a fix for #5646. + + Co-authored-by: devil-ira + +commit 5f1261110fdd8f382084125a3592159948571497 +Author: ickshonpe +Date: Mon Nov 14 21:59:17 2022 +0000 + + Flip UI image (#6292) + + # Objective + Fixes #3225, Allow for flippable UI Images + + ## Solution + Add flip_x and flip_y fields to UiImage, and swap the UV coordinates accordingly in ui_prepare_nodes. + + ## Changelog + * Changes UiImage to a struct with texture, flip_x, and flip_y fields. + * Adds flip_x and flip_y fields to ExtractedUiNode. + * Changes extract_uinodes to extract the flip_x and flip_y values from UiImage. + * Changes prepare_uinodes to swap the UV coordinates as required. + * Changes UiImage derefs to texture field accesses. + +commit 3ac06b57e90404f7655fab80ed1e81ca1deb86f4 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Nov 14 21:16:53 2022 +0000 + + Respect alignment for zero-sized types stored in the world (#6618) + + # Objective + + Fixes #6615. + + `BlobVec` does not respect alignment for zero-sized types, which results in UB whenever a ZST with alignment other than 1 is used in the world. + + ## Solution + + Add the fn `bevy_ptr::dangling_with_align`. + + --- + + ## Changelog + + + Added the function `dangling_with_align` to `bevy_ptr`, which creates a well-aligned dangling pointer to a type whose alignment is not known at compile time. + +commit 9498bfffcbb67b0933289c776dc63c3c391db4a5 +Author: radiish +Date: Mon Nov 14 21:03:39 2022 +0000 + + Add `remove` method to `Map` reflection trait. (#6564) + + # Objective + + - Implements removal of entries from a `dyn Map` + - Fixes #6563 + + ## Solution + + - Adds a `remove` method to the `Map` trait which takes in a `&dyn Reflect` key and returns the value removed if it was present. + + --- + + ## Changelog + + - Added `Map::remove` + + ## Migration Guide + + - Implementors of `Map` will need to implement the `remove` method. + + + Co-authored-by: radiish + +commit 1967c3ddefb56260b243f8cbf7265f4d86729aec +Author: Nicola Papale +Date: Mon Nov 14 14:01:16 2022 +0000 + + Fix Entity hygiene in WorldQuery (#6614) + + # Objective + + Fix #6593 + + ## Solution + + Fully qualify `Entity` in the `WorldQuery` macro + +commit 7231e00507502662c59cc24e06b19f013e45a6cb +Author: Tymon +Date: Mon Nov 14 13:44:29 2022 +0000 + + Note about flex in `Style` docs (#6616) + + # Objective + + - Fixes #6606 + + ## Solution + + - Deleted the note Bevy's UI being upside down since it's no longer true as of version 0.9.0 + +commit e48c05c73474a5f6a212257cecda7ceaf2465cf3 +Author: Lixou <82600264+DasLixou@users.noreply.github.com> +Date: Sun Nov 13 15:35:48 2022 +0000 + + Fix Link in valid_parent_check_plugin.rs (#6584) + + # Objective + + Link doesn't get to right segment + + ## Solution + + Fix link + +commit f7c8eb7d86fbfccb633d27ad9db76efe5eeedef8 +Author: Sol Toder +Date: Sat Nov 12 22:59:49 2022 +0000 + + Correct docs for ButtonSettingsError to read 0.0..=1.0 (#6570) + + # Objective + + The [documentation for `ButtonSettingsError`](https://docs.rs/bevy/0.9.0/bevy/input/gamepad/enum.ButtonSettingsError.html) incorrectly describes the valid range of values as `0.0..=2.0`, probably because it was copied from `AxisSettingsError`. The actual range, as seen in the functions that return it and in its own `thiserror` description, is `0.0..=1.0`. + + ## Solution + + Update the doc comments to reflect the correct range. + + + Co-authored-by: Sol Toder + +commit 920543c824735dc1df6f4a59e7036e653dd5a553 (tag: v0.9.0) +Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Date: Sat Nov 12 20:01:29 2022 +0000 + + Release 0.9.0 (#6568) + + Preparing next release + This PR has been auto-generated + +commit d0fe37609aed5fa4c977d5f2f624e4acdffe625d +Author: Carter Anderson +Date: Sat Nov 12 19:45:30 2022 +0000 + + Add 0.9.0 changelog (#6567) + +commit 2179a3ebf460a3f35da8c9b403248442b2f54a34 +Author: James Liu +Date: Sat Nov 12 16:15:04 2022 +0000 + + Make Entity::to_bits const (#6559) + + # Objective + Fix #6548. Most of these methods were already made `const` in #5688. `Entity::to_bits` is the only one that remained. + + ## Solution + Make it const. + +commit c3c4088317f0ea09de8d96e22fa5beb28e486c30 +Author: Aevyrie +Date: Sat Nov 12 09:31:03 2022 +0000 + + Fix instancing example for hdr (#6554) + + # Objective + + - Using the instancing example as reference, I found it was breaking when enabling HDR on the camera. I found that this was because, unlike in internal code, this was not updating the specialization key with `view.hdr`. + + ## Solution + + - Add the missing HDR bit. + +commit ffa489a846346af427f6b09642bd8b2cfb016de6 +Author: Nicola Papale +Date: Sat Nov 12 08:06:56 2022 +0000 + + Ignore `Timeout` errors on Linux AMD & Intel (#5957) + + # Objective + + - Fix #3606 + - Fix #4579 + - Fix #3380 + + ## Solution + + When running on a Linux machine with some AMD or Intel device, when calling + `surface.get_current_texture()`, ignore `wgpu::SurfaceError::Timeout` errors. + + + ## Alternative + + An alternative solution found in the `wgpu` examples is: + + ```rust + let frame = surface + .get_current_texture() + .or_else(|_| { + render_device.configure_surface(surface, &swap_chain_descriptor); + surface.get_current_texture() + }) + .expect("Error reconfiguring surface"); + window.swap_chain_texture = Some(TextureView::from(frame)); + ``` + + See: + + Veloren [handles the Timeout error the way this PR proposes to handle it](https://github.com/gfx-rs/wgpu/issues/1218#issuecomment-1092056971). + + The reason I went with this PR's solution is that `configure_surface` seems to be quite an expensive operation, and it would run every frame with the wgpu framework solution, despite the fact it works perfectly fine without `configure_surface`. + + I know this looks super hacky with the linux-specific line and the AMD check, but my understanding is that the `Timeout` occurrence is specific to a quirk of some AMD drivers on linux, and if otherwise met should be considered a bug. + + + Co-authored-by: Carter Anderson + +commit 7ced5336e6b779880029e00074dfeab34bf8169e +Author: ira +Date: Sat Nov 12 01:28:31 2022 +0000 + + Fix panic when the primary window is closed (#6545) + + Issue introduced by #6533. + + Co-authored-by: devil-ira + +commit 4ef192b91a569d18c807d56be5791490529634ac +Author: François +Date: Fri Nov 11 23:46:45 2022 +0000 + + Better bloom default settings (#6546) + + # Objective + + - Use better defaults for bloom + + ## Solution + + - Divide the intensity by 3. It's still noticeable + - Change the mip level? (not sure about that change, it's from a discussion with @superdump) + + + ### bloom example + main: + Screenshot 2022-11-11 at 01 09 26 + this pr: + Screenshot 2022-11-11 at 01 08 00 + + + ### bistro scene + main: + Screenshot 2022-11-11 at 01 16 42 + this pr: + Screenshot 2022-11-11 at 01 15 12 + +commit 72fbcc7633248703d58f2dbf1b47cdfde945325a +Author: Aevyrie +Date: Fri Nov 11 19:43:45 2022 +0000 + + Fix color banding by dithering image before quantization (#5264) + + # Objective + + - Closes #5262 + - Fix color banding caused by quantization. + + ## Solution + + - Adds dithering to the tonemapping node from #3425. + - This is inspired by Godot's default "debanding" shader: https://gist.github.com/belzecue/ + - Unlike Godot: + - debanding happens after tonemapping. My understanding is that this is preferred, because we are running the debanding at the last moment before quantization (`[f32, f32, f32, f32]` -> `f32`). This ensures we aren't biasing the dithering strength by applying it in a different (linear) color space. + - This code instead uses and reference the origin source, Valve at GDC 2015 + + ![Screenshot from 2022-11-10 13-44-46](https://user-images.githubusercontent.com/2632925/201218880-70f4cdab-a1ed-44de-a88c-8759e77197f1.png) + ![Screenshot from 2022-11-10 13-41-11](https://user-images.githubusercontent.com/2632925/201218883-72393352-b162-41da-88bb-6e54a1e26853.png) + + + ## Additional Notes + + Real time rendering to standard dynamic range outputs is limited to 8 bits of depth per color channel. Internally we keep everything in full 32-bit precision (`vec4`) inside passes and 16-bit between passes until the image is ready to be displayed, at which point the GPU implicitly converts our `vec4` into a single 32bit value per pixel, with each channel (rgba) getting 8 of those 32 bits. + + ### The Problem + + 8 bits of color depth is simply not enough precision to make each step invisible - we only have 256 values per channel! Human vision can perceive steps in luma to about 14 bits of precision. When drawing a very slight gradient, the transition between steps become visible because with a gradient, neighboring pixels will all jump to the next "step" of precision at the same time. + + ### The Solution + + One solution is to simply output in HDR - more bits of color data means the transition between bands will become smaller. However, not everyone has hardware that supports 10+ bit color depth. Additionally, 10 bit color doesn't even fully solve the issue, banding will result in coherent bands on shallow gradients, but the steps will be harder to perceive. + + The solution in this PR adds noise to the signal before it is "quantized" or resampled from 32 to 8 bits. Done naively, it's easy to add unneeded noise to the image. To ensure dithering is correct and absolutely minimal, noise is adding *within* one step of the output color depth. When converting from the 32bit to 8bit signal, the value is rounded to the nearest 8 bit value (0 - 255). Banding occurs around the transition from one value to the next, let's say from 50-51. Dithering will never add more than +/-0.5 bits of noise, so the pixels near this transition might round to 50 instead of 51 but will never round more than one step. This means that the output image won't have excess variance: + - in a gradient from 49 to 51, there will be a step between each band at 49, 50, and 51. + - Done correctly, the modified image of this gradient will never have a adjacent pixels more than one step (0-255) from each other. + - I.e. when scanning across the gradient you should expect to see: + ``` + |-band-| |-band-| |-band-| + Baseline: 49 49 49 50 50 50 51 51 51 + Dithered: 49 50 49 50 50 51 50 51 51 + Dithered (wrong): 49 50 51 49 50 51 49 51 50 + ``` + + ![Screenshot from 2022-11-10 14-12-36](https://user-images.githubusercontent.com/2632925/201219075-ab3f46be-d4e9-4869-b66b-a92e1706f49e.png) + ![Screenshot from 2022-11-10 14-11-48](https://user-images.githubusercontent.com/2632925/201219079-ec5d2add-817d-487a-8fc1-84569c9cda73.png) + + + + + You can see from above how correct dithering "fuzzes" the transition between bands to reduce distinct steps in color, without adding excess noise. + + ### HDR + + The previous section (and this PR) assumes the final output is to an 8-bit texture, however this is not always the case. When Bevy adds HDR support, the dithering code will need to take the per-channel depth into account instead of assuming it to be 0-255. Edit: I talked with Rob about this and it seems like the current solution is okay. We may need to revisit once we have actual HDR final image output. + + --- + + ## Changelog + + ### Added + + - All pipelines now support deband dithering. This is enabled by default in 3D, and can be toggled in the `Tonemapping` component in camera bundles. Banding is a graphical artifact created when the rendered image is crunched from high precision (f32 per color channel) down to the final output (u8 per channel in SDR). This results in subtle gradients becoming blocky due to the reduced color precision. Deband dithering applies a small amount of noise to the signal before it is "crunched", which breaks up the hard edges of blocks (bands) of color. Note that this does not add excess noise to the image, as the amount of noise is less than a single step of a color channel - just enough to break up the transition between color blocks in a gradient. + + + Co-authored-by: Carter Anderson + +commit c4e791d62890cc02773564bad7592345d2b8f05c +Author: Robert Swain +Date: Fri Nov 11 03:31:57 2022 +0000 + + bevy_pbr: Normalize skinned normals (#6543) + + # Objective + + - Make the many foxes not unnecessarily bright. Broken since #5666. + - Fixes #6528 + + ## Solution + + - In #5666 normalisation of normals was moved from the fragment stage to the vertex stage. However, it was not added to the vertex stage for skinned normals. The many foxes are skinned and their skinned normals were not unit normals. which made them brighter. Normalising the skinned normals fixes this. + + --- + + ## Changelog + + - Fixed: Non-unit length skinned normals are now normalized. + +commit 99c815fd00334ac0b1a18e6eff8d103352f918cd +Author: ira +Date: Thu Nov 10 20:10:51 2022 +0000 + + Move the cursor's origin back to the bottom-left (#6533) + + This reverts commit 8429b6d6ca8a3de0ba2774b294861fad4916e268 as discussed in #6522. + + I tested that the game_menu example works as it should. + + Co-authored-by: devil-ira + +commit 9b56b549ad866ee200b890216b2d6dd39cfa34ad +Author: ira +Date: Thu Nov 10 16:55:53 2022 +0000 + + Reuse `ndc_to_world` matrix in `Camera::viewport_to_world` (#6532) + + # Objective + + Solve #6531. + + + Co-authored-by: devil-ira + +commit 1914a3f288a812667f735ee9e7806cf1560dacc0 +Author: dataphract +Date: Mon Nov 7 21:43:07 2022 +0000 + + fix: explicitly specify required version of async-task (#6509) + + # Objective + + Attempting to build `bevy_tasks` produces the following error: + + ``` + error[E0599]: no method named `is_finished` found for struct `async_executor::Task` in the current scope + --> /[...]]/bevy/crates/bevy_tasks/src/task.rs:51:16 + | + 51 | self.0.is_finished() + | ^^^^^^^^^^^ method not found in `async_executor::Task` + + ``` + + It looks like this was introduced along with `Task::is_finished`, which delegates to `async_task::Task::is_finished`. However, the latter was only introduced in `async-task` 4.2.0; `bevy_tasks` does not explicitly depend on `async-task` but on `async-executor` ^1.3.0, which in turn depends on `async-task` ^4.0.0. + + ## Solution + + Add an explicit dependency on `async-task` ^4.2.0. + +commit d688ba5f29151db701425d854fc25dfbad6ad5c4 +Author: ira +Date: Mon Nov 7 21:25:31 2022 +0000 + + Add `send_event` and friends to `WorldCell` (#6515) + + # Objective + + Copy `send_event` and friends from `World` to `WorldCell`. + + Clean up `bevy_winit` using `WorldCell::send_event`. + + ## Changelog + + Added `send_event`, `send_event_default`, and `send_event_batch` to `WorldCell`. + + Co-authored-by: devil-ira + +commit 4ad621fe0f8883a64f330654747cb539511c2d7c +Author: Jakob Hellermann +Date: Mon Nov 7 19:44:17 2022 +0000 + + `Reflect` for `Tonemapping` and `ClusterConfig` (#6488) + + # Objective + + - it would be useful to inspect these structs using reflection + + ## Solution + + - derive and register reflect + - Note that `#[reflect(Component)]` requires `Default` (or `FromWorld`) until #6060, so I implemented `Default` for `Tonemapping` with `is_enabled: false` + +commit 0aa17d0acaa6d1c6fe0594ca0bc106e7991ba299 +Author: 研究社交 +Date: Mon Nov 7 19:44:15 2022 +0000 + + Macro for Loading Internal Binary Assets (#6478) + + # Objective + + The `load_internal_asset` macro is helpful when creating rendering plugins, but it doesn't support load binary assets (like those compiled as spir-v). + + ## Solution + + Add a `load_internal_binary_asset` macro that use `include_bytes!`. + +commit 1170b307850e3546793978a246a4c33363c5019c +Author: Rob Parrett +Date: Mon Nov 7 19:44:14 2022 +0000 + + Fix panic when using globals uniform in wasm builds (#6460) + + # Objective + + Fixes #5393 + + ## Solution + + - Add padding to `GlobalsUniform` / `Globals` to make it 16-byte aligned. + + Still not super clear on whether this is a `naga` thing or an `encase` thing or what. But now that we're offering `globals` up to users and #5393 is not just breaking an example, maybe we should do this sort of workaround? + +commit 0aab699a849929fc800978f052a148ee0f1335a7 +Author: François +Date: Mon Nov 7 19:44:13 2022 +0000 + + Update glam 0.22, hexasphere 8.0, encase 0.4 (#6427) + + # Objective + + - Update glam to 0.22, hexasphere to 8.0, encase to 0.4 + + ## Solution + + - Update glam to 0.22, hexasphere to 8.0, encase to 0.4 + - ~~waiting on https://github.com/teoxoy/encase/pull/17 and https://github.com/OptimisticPeach/hexasphere/pull/13~~ + +commit 944b311c6707f2f73dbe8dacd82d9fe3b8b3cbbc +Author: ira +Date: Mon Nov 7 19:23:34 2022 +0000 + + Improve logging consistency for entity despawning (#6501) + + * Move the despawn debug log from `World::despawn` to `EntityMut::despawn`. + * Move the despawn non-existent warning log from `Commands::despawn` to `World::despawn`. + + This should make logging consistent regardless of which of the three `despawn` methods is used. + + Co-authored-by: devil-ira + +commit 02fbf16c8096e49ced66db571373128ea9508b9f +Author: Gino Valente +Date: Mon Nov 7 02:11:16 2022 +0000 + + bevy_reflect: Add `Reflect::into_reflect` (#6502) + + # Objective + + Using `Reflect` we can easily switch between a specific reflection trait object, such as a `dyn Struct`, to a `dyn Reflect` object via `Reflect::as_reflect` or `Reflect::as_reflect_mut`. + + ```rust + fn do_something(value: &dyn Reflect) {/* ... */} + + let foo: Box = Box::new(Foo::default()); + do_something(foo.as_reflect()); + ``` + + However, there is no way to convert a _boxed_ reflection trait object to a `Box`. + + ## Solution + + Add a `Reflect::into_reflect` method which allows converting a boxed reflection trait object back into a boxed `Reflect` trait object. + + ```rust + fn do_something(value: Box) {/* ... */} + + let foo: Box = Box::new(Foo::default()); + do_something(foo.into_reflect()); + ``` + + --- + + ## Changelog + + - Added `Reflect::into_reflect` + +commit 33299f0badf823380231436b6cb5c68c6b59335c +Author: François +Date: Sun Nov 6 22:43:52 2022 +0000 + + update allowed duplicate dependencies (#6500) + + # Objective + + - Fix deny issues + + ## Solution + + - Allow new duplicated dependencies + +commit efc111c7f2cdb90d1e7584848e1aa0f6ccd74022 +Author: Hennadii Chernyshchyk +Date: Sun Nov 6 17:14:10 2022 +0000 + + Add CameraRenderGraph::set (#6470) + + # Objective + + Some render plugins, like [bevy-hikari](https://github.com/cryscan/bevy-hikari) require to set `CameraRenderGraph`. In order to switch between render graphs I need to insert a new `CameraRenderGraph` component. It's not very ergonomic. + + ## Solution + + Add `CameraRenderGraph::set` like in [Name](https://docs.rs/bevy/latest/bevy/core/struct.Name.html). + + --- + + ## Changelog + + ### Added + + - `CameraRenderGraph::set`. + +commit feebbc5ea917a292fbecf259470094d359631fa4 +Author: Hennadii Chernyshchyk +Date: Sun Nov 6 16:58:38 2022 +0000 + + Add reflect_owned (#6494) + + # Objective + + There is no way to gen an owned value of `Reflect`. + + ## Solution + + Add it! This was originally a part of #6421, but @MrGVSV asked me to create a separate for it to implement reflect diffing. + + --- + + ## Changelog + + ### Added + + - `Reflect::reflect_owned` to get an owned version of `Reflect`. + +commit 694c980c821c758f3d272e77a0dc7a75107d7ade +Author: TimJentzsch +Date: Sun Nov 6 01:42:15 2022 +0000 + + Fix `clippy::iter_with_drain` (#6485) + + # Objective + + Fixes #6483. + + - Fix the [`clippy::iter_with_drain`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain) warnings + - From the docs: "`.into_iter()` is simpler with better performance" + + ## Solution + + - Replace `.drain(..)` for `Vec` with `.into_iter()` + +commit 66f495c44ee9a460f54727e38a13d60f1b60e915 +Author: Brian Merchant +Date: Sat Nov 5 20:48:15 2022 +0000 + + Cleaning up NodeBundle, and some slight UI module re-organization (#6473) + + # Objective + + `NodeBundle` contains an `image` field, which can be misleading, because if you do supply an image there, nothing will be shown to screen. You need to use an `ImageBundle` instead. + + ## Solution + + * `image` (`UiImage`) field is removed from `NodeBundle`, + * extraction stage queries now make an optional query for `UiImage`, if one is not found, use the image handle that is used as a default by `UiImage`: https://github.com/bevyengine/bevy/blob/c019a60b39c5683656025bc9d24a02744aa59dea/crates/bevy_ui/src/ui_node.rs#L464 + * touching up docs for `NodeBundle` to help guide what `NodeBundle` should be used for + * renamed `entity.rs` to `node_bundle.rs` as that gives more of a hint regarding the module's purpose + * separating `camera_config` stuff from the pre-made UI node bundles so that `node_bundle.rs` makes more sense as a module name. + +commit 5ae94750a199693983c833838729d036fab4f95c +Author: Jakob Hellermann +Date: Sat Nov 5 16:43:15 2022 +0000 + + make `register` on `TypeRegistry` idempotent (#6487) + + # Objective + + - adding a new `.register` should not overwrite old type data + - separate crates should both be able to register the same type + + I ran into this while debugging why `register::>` removed the `ReflectHandle` type data from a prior `register_asset_reflect`. + + + ## Solution + + - make `register` do nothing if called again for the same type + - I also removed some unnecessary duplicate registrations + +commit 3d64acd0c30c1267f7f18a7fff2aca02fec98dec +Author: Rob Parrett +Date: Sat Nov 5 16:30:13 2022 +0000 + + Add more info to texture loading error in texture_atlas example (#6456) + + # Objective + + - Fix an awkwardly phrased/typoed error message + - Actually tell users which file caused the error + - IMO we don't need to panic + + ## Solution + + - Add a warning including the involved asset path when a non-image is found by `load_folder` + - Note: uses `let else` which is stable now + + ``` + 2022-11-03T14:17:59.006861Z WARN texture_atlas: Some(AssetPath { path: "textures/rpg/tiles/whatisthisdoinghere.ogg", label: None }) did not resolve to an `Image` asset. + ``` + +commit 0e41b79a35be98552a0b330dbc657fc22422357e +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sat Nov 5 16:15:08 2022 +0000 + + `debug_checked_unwrap` should track its caller (#6452) + + # Objective + + When an error causes `debug_checked_unreachable` to be called, the panic message unhelpfully points to the function definition instead of the place that caused the error. + + ## Solution + + Add the `#[track_caller]` attribute in debug mode. + +commit 96c9c60f806906c85b52183d60c2f78a743cb925 +Author: targrub +Date: Sat Nov 5 14:12:04 2022 +0000 + + Use `cbrt()` instead of `powf(1./3.)` (#6481) + + # Objective + + - Use cube root library function instead of handrolling. + + ## Solution + + - Instead of `powf(1./3.)` use `cbrt()`. + +commit 40ea5b4ef60d7f32e7bb8c37a177fb69baaa40e6 +Author: xtr3m3nerd +Date: Sat Nov 5 13:51:12 2022 +0000 + + UI scaling fix (#6479) + + # Objective + + Fixes: https://github.com/bevyengine/bevy/issues/6466 + Summary: The UI Scaling example dynamically scales the UI which will dynamically allocate fonts to the font atlas surpassing the protective limit, throwing a panic. + + ## Solution + + - Set TextSettings.allow_dynamic_font_size = true for the UI Scaling example. This is the ideal solution since the dynamic changes to the UI are not continuous yet still discrete. + - Update the panic text to reflect ui scaling as a potential cause + +commit ea4aeff9ec8e204b8d4bc8cbb10c28e90fe271ff +Author: James Liu +Date: Sat Nov 5 01:52:30 2022 +0000 + + Remove LTO (#6472) + + # Objective + #6461 introduced `lto = true` as a profile setting for release builds. This is causing the `run-examples` CI task to timeout. + + ## Solution + Remove it. + +commit c019a60b39c5683656025bc9d24a02744aa59dea +Author: Carter Anderson +Date: Fri Nov 4 22:19:02 2022 +0000 + + Add "end of main pass post processing" render graph node (#6468) + + # Objective + + Bevy UI (and third party plugins) currently have no good way to position themselves after all post processing effects. They currently use the tonemapping node, but this is not adequate if there is anything after tonemapping (such as FXAA). + + ## Solution + + Add a logical `END_MAIN_PASS_POST_PROCESSING` RenderGraph node that main pass post processing effects position themselves before, and things like UIs can position themselves after. + +commit e5905379de5ba8c6018947da8b0665d4b17f9de3 +Author: Carter Anderson +Date: Fri Nov 4 21:32:09 2022 +0000 + + Use new let-else syntax where possible (#6463) + + # Objective + + Let-else syntax is now stable! + + ## Solution + + Use it where possible! + +commit 1bd3d8576941d09fc43fef901e1bbbf45b24c544 +Author: Marco Buono +Date: Fri Nov 4 20:12:26 2022 +0000 + + Take DirectionalLight's GlobalTransform into account when calculating shadow map volume (not just direction) (#6384) + + # Objective + + This PR fixes #5789, by enabling movable (and scalable) directional light shadow volumes. + + ## Solution + + This PR changes `ExtractedDirectionalLight` to hold a copy of the `DirectionalLight` entity's `GlobalTransform`, instead of just a `direction` vector. This allows the shadow map volume (as defined by the light's `shadow_projection` field) to be transformed honoring translation _and_ scale transforms, and not just rotation. + + It also augments the texel size calculation (used to determine the `shadow_normal_bias`) so that it now takes into account the upper bound of the x/y/z scale of the `GlobalTransform`. + + This change makes the directional light extraction code more consistent with point and spot lights (that already use `transform`), and allows easily moving and scaling the shadow volume along with a player entity based on camera distance/angle, immediately enabling more real world use cases until we have a more sophisticated adaptive implementation, such as the one described in #3629. + + **Note:** While it was previously possible to update the projection achieving a similar effect, depending on the light direction and distance to the origin, the fact that the shadow map camera was always positioned at the origin with a hardcoded `Vec3::Y` up value meant you would get sub-optimal or inconsistent/incorrect results. + + --- + + ## Changelog + + ### Changed + + - `DirectionalLight` shadow volumes now honor translation and scale transforms + + ## Migration Guide + + - If your directional lights were positioned at the origin and not scaled (the default, most common scenario) no changes are needed on your part; it just works as before; + - If you previously had a system for dynamically updating directional light shadow projections, you might now be able to simplify your code by updating the directional light entity's transform instead; + - In the unlikely scenario that a scene with directional lights that previously rendered shadows correctly has missing shadows, make sure your directional lights are positioned at (0, 0, 0) and are not scaled to a size that's too large or too small. + +commit 1fe3589a1ada6d8583f3385126a31a8d286510ac +Author: JMS55 +Date: Fri Nov 4 17:53:55 2022 +0000 + + Improve BloomSettings docs (#6465) + + + + Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com> + Co-authored-by: Carter Anderson + Co-authored-by: DGriffin91 + +commit 9dd019bf862fcfc9ef0afea8028f2390f10a4891 +Author: Thierry Berger +Date: Fri Nov 4 17:53:54 2022 +0000 + + Change Detection Benchmarks (#4972) + + # Objective + + Fixes #4883. + + ## Solution + + - Add benchmarks for Changed and Added + + Disclaimer: I'm not that much familiar with benchmarking. + +commit b0bd8722f33f2b31f281358c8f4d9cfa4056ed77 +Author: ira +Date: Fri Nov 4 17:30:40 2022 +0000 + + Fix unsound `EntityMut::remove_children`. Add `EntityMut::world_scope` (#6464) + + `EntityMut::remove_children` does not call `self.update_location()` which is unsound. + Verified by adding the following assertion, which fails when running the tests. + ```rust + let before = self.location(); + self.update_location(); + assert_eq!(before, self.location()); + ``` + + I also removed incorrect messages like "parent entity is not modified" and the unhelpful "Inserting a bundle in the children entities may change the parent entity's location if they were of the same archetype" which might lead people to think that's the *only* thing that can change the entity's location. + + # Changelog + Added `EntityMut::world_scope`. + + Co-authored-by: devil-ira + +commit 3a14ae40eea1d430c56ae6cdd3b9bdc1037656a6 +Author: Charles +Date: Fri Nov 4 11:42:23 2022 +0000 + + Remove Camera2d in bloom example (#6462) + + # Objective + + The bloom example has a 2d camera for the UI. This is an artifact of an older version of bevy. All cameras can render the UI now. + + ## Solution + + Remove the 2d camera + +commit ec8c8fbc8a960acdfc4894cd56b3c13147c32fdb +Author: James Liu +Date: Fri Nov 4 06:04:55 2022 +0000 + + Remove unnecesary branches/panics from Query accesses (#6461) + + # Objective + Supercedes #6452. Upon inspection of the [generated assembly](https://gist.github.com/james7132/c2740c6941b80d7912f1e8888e223cbb#file-original-s) of a [simple Bevy binary](https://gist.github.com/james7132/c2740c6941b80d7912f1e8888e223cbb#file-source-rs) compiled with `cargo rustc --release -- --emit asm`, it's apparent that there are multiple unnecessary branches in the generated assembly: + + ```assembly + .LBB5_5: + cmpq %r10, %r11 + je .LBB5_15 + movq (%r11), %rcx + movq 328(%r15), %rdx + cmpq %rdx, %rcx + jae .LBB5_14 + movq 312(%r15), %rdi + leaq (%rcx,%rcx,2), %rcx + shlq $5, %rcx + movq 336(%r12), %rdx + movq 64(%rdi,%rcx), %rax + cmpq %rdx, %rax + jbe .LBB5_4 + leaq (%rdi,%rcx), %rsi + movq 48(%rsi), %rbp + shlq $4, %rdx + cmpq $0, (%rbp,%rdx) + je .LBB5_4 + movq 344(%r12), %rbx + cmpq %rbx, %rax + jbe .LBB5_4 + shlq $4, %rbx + cmpq $0, (%rbp,%rbx) + je .LBB5_4 + addq $8, %r11 + movq 88(%rdi,%rcx), %rcx + testq %rcx, %rcx + je .LBB5_5 + movq (%rsi), %rax + movq 8(%rbp,%rdx), %rdx + leaq (%rdx,%rdx,4), %rdi + shlq $4, %rdi + movq 32(%rax,%rdi), %rdx + movq 56(%rax,%rdi), %r8 + movq 8(%rbp,%rbx), %rbp + leaq (%rbp,%rbp,4), %rbp + shlq $4, %rbp + movq 32(%rax,%rbp), %r9 + xorl %ebp, %ebp + jmp .LBB5_13 + .p2align 4, 0x90 + ``` + + Almost every one of the instructions starting with `j` is a potential branch, which can significantly slow down accesses. Of these, two labels are both common and never used: + + ```asm + .LBB5_14: + leaq __unnamed_2(%rip), %r8 + callq _ZN4core9panicking18panic_bounds_check17h70367088e72af65aE + ud2 + .LBB5_4: + callq _ZN8bevy_ecs5query25debug_checked_unreachable17h0855ff520ceaea77E + ud2 + .seh_endproc + ``` + + These correpsond to subprocedure calls to panicking due to out of bounds from indexing `Tables` and `debug_checked_unreadable`. Both of which should be inlined and optimized out, but are not. + + ## Solution + Make `debug_checked_unreachable` a macro to forcibly inline either `unreachable!()` in debug builds, and `std::hint::unreachable_unchecked()` in release mode. Replace the `Tables` and `Archetype` index access with `get(id).unwrap_or_else(|| debug_checked_unreachable!())` to assume that the table or archetype provided exists. + + This has no external breaking change of any kind. + + The equivalent section of code with these changes removes most of the conditional jump instructions: + + ```asm + .LBB5_5: + movss (%rbx,%rbp,4), %xmm0 + movl %r14d, 4(%r8,%rbp,8) + addss (%rdi,%rbp,4), %xmm0 + movss %xmm0, (%rdi,%rbp,4) + incq %rbp + .LBB5_1: + cmpq %rdx, %rbp + jne .LBB5_5 + .p2align 4, 0x90 + .LBB5_2: + cmpq %rcx, %rax + je .LBB5_6 + movq (%rax), %rdx + addq $8, %rax + movq 312(%rsi), %rbp + leaq (%rdx,%rdx,2), %rbx + shlq $5, %rbx + movq 88(%rbp,%rbx), %rdx + testq %rdx, %rdx + je .LBB5_2 + leaq (%rbx,%rbp), %r8 + movq 336(%r15), %rdi + movq 344(%r15), %r9 + movq 48(%rbp,%rbx), %r10 + shlq $4, %rdi + movq (%r8), %rbx + movq 8(%r10,%rdi), %rdi + leaq (%rdi,%rdi,4), %rbp + shlq $4, %rbp + movq 32(%rbx,%rbp), %rdi + movq 56(%rbx,%rbp), %r8 + shlq $4, %r9 + movq 8(%r10,%r9), %rbp + leaq (%rbp,%rbp,4), %rbp + shlq $4, %rbp + movq 32(%rbx,%rbp), %rbx + xorl %ebp, %ebp + jmp .LBB5_5 + .LBB5_6: + addq $40, %rsp + popq %rbx + popq %rbp + popq %rdi + popq %rsi + popq %r14 + popq %r15 + retq + .seh_endproc + + ``` + + ## Performance + + Microbenchmarks results: + +
+ + ``` + group main no-panic-query + ----- ---- -------------- + busy_systems/01x_entities_03_systems 1.20 42.4±2.66µs ? ?/sec 1.00 35.3±1.68µs ? ?/sec + busy_systems/01x_entities_06_systems 1.32 83.8±3.50µs ? ?/sec 1.00 63.6±1.72µs ? ?/sec + busy_systems/01x_entities_09_systems 1.15 113.3±8.90µs ? ?/sec 1.00 98.2±6.15µs ? ?/sec + busy_systems/01x_entities_12_systems 1.27 160.8±32.44µs ? ?/sec 1.00 126.6±4.70µs ? ?/sec + busy_systems/01x_entities_15_systems 1.12 179.6±3.71µs ? ?/sec 1.00 160.3±11.03µs ? ?/sec + busy_systems/02x_entities_03_systems 1.18 76.8±3.14µs ? ?/sec 1.00 65.2±3.17µs ? ?/sec + busy_systems/02x_entities_06_systems 1.16 144.6±6.10µs ? ?/sec 1.00 124.5±5.14µs ? ?/sec + busy_systems/02x_entities_09_systems 1.19 215.3±9.18µs ? ?/sec 1.00 181.5±5.67µs ? ?/sec + busy_systems/02x_entities_12_systems 1.20 266.7±8.33µs ? ?/sec 1.00 222.0±9.53µs ? ?/sec + busy_systems/02x_entities_15_systems 1.23 338.8±10.53µs ? ?/sec 1.00 276.3±6.94µs ? ?/sec + busy_systems/03x_entities_03_systems 1.43 113.5±5.06µs ? ?/sec 1.00 79.6±1.49µs ? ?/sec + busy_systems/03x_entities_06_systems 1.38 217.3±12.67µs ? ?/sec 1.00 157.5±3.07µs ? ?/sec + busy_systems/03x_entities_09_systems 1.23 308.8±24.75µs ? ?/sec 1.00 251.6±8.93µs ? ?/sec + busy_systems/03x_entities_12_systems 1.05 347.7±12.43µs ? ?/sec 1.00 330.6±11.43µs ? ?/sec + busy_systems/03x_entities_15_systems 1.13 455.5±13.88µs ? ?/sec 1.00 401.7±17.29µs ? ?/sec + busy_systems/04x_entities_03_systems 1.24 144.7±5.89µs ? ?/sec 1.00 116.9±6.29µs ? ?/sec + busy_systems/04x_entities_06_systems 1.24 282.8±21.40µs ? ?/sec 1.00 228.6±21.31µs ? ?/sec + busy_systems/04x_entities_09_systems 1.35 431.8±14.10µs ? ?/sec 1.00 319.6±9.83µs ? ?/sec + busy_systems/04x_entities_12_systems 1.16 493.8±22.87µs ? ?/sec 1.00 424.9±15.24µs ? ?/sec + busy_systems/04x_entities_15_systems 1.10 587.5±23.25µs ? ?/sec 1.00 531.7±16.32µs ? ?/sec + busy_systems/05x_entities_03_systems 1.14 148.2±9.61µs ? ?/sec 1.00 129.5±4.32µs ? ?/sec + busy_systems/05x_entities_06_systems 1.31 359.7±17.46µs ? ?/sec 1.00 273.6±10.55µs ? ?/sec + busy_systems/05x_entities_09_systems 1.22 473.5±23.11µs ? ?/sec 1.00 389.3±13.62µs ? ?/sec + busy_systems/05x_entities_12_systems 1.05 562.9±20.76µs ? ?/sec 1.00 536.5±24.35µs ? ?/sec + busy_systems/05x_entities_15_systems 1.23 818.5±28.70µs ? ?/sec 1.00 666.6±45.87µs ? ?/sec + contrived/01x_entities_03_systems 1.27 27.5±0.49µs ? ?/sec 1.00 21.6±1.71µs ? ?/sec + contrived/01x_entities_06_systems 1.22 49.9±1.18µs ? ?/sec 1.00 40.7±2.62µs ? ?/sec + contrived/01x_entities_09_systems 1.30 72.3±2.39µs ? ?/sec 1.00 55.4±2.60µs ? ?/sec + contrived/01x_entities_12_systems 1.28 94.3±9.44µs ? ?/sec 1.00 73.7±3.62µs ? ?/sec + contrived/01x_entities_15_systems 1.25 118.0±2.43µs ? ?/sec 1.00 94.1±3.99µs ? ?/sec + contrived/02x_entities_03_systems 1.23 41.6±1.71µs ? ?/sec 1.00 33.7±2.30µs ? ?/sec + contrived/02x_entities_06_systems 1.19 78.6±2.63µs ? ?/sec 1.00 65.9±2.35µs ? ?/sec + contrived/02x_entities_09_systems 1.28 113.6±3.60µs ? ?/sec 1.00 88.6±3.60µs ? ?/sec + contrived/02x_entities_12_systems 1.20 146.4±5.75µs ? ?/sec 1.00 121.7±3.35µs ? ?/sec + contrived/02x_entities_15_systems 1.23 178.5±4.86µs ? ?/sec 1.00 145.7±4.00µs ? ?/sec + contrived/03x_entities_03_systems 1.42 58.3±2.77µs ? ?/sec 1.00 41.1±1.54µs ? ?/sec + contrived/03x_entities_06_systems 1.32 108.5±7.30µs ? ?/sec 1.00 82.4±4.86µs ? ?/sec + contrived/03x_entities_09_systems 1.23 153.7±4.61µs ? ?/sec 1.00 125.0±4.76µs ? ?/sec + contrived/03x_entities_12_systems 1.18 197.5±5.12µs ? ?/sec 1.00 166.8±8.14µs ? ?/sec + contrived/03x_entities_15_systems 1.23 238.8±6.38µs ? ?/sec 1.00 194.6±4.55µs ? ?/sec + contrived/04x_entities_03_systems 1.34 66.4±3.42µs ? ?/sec 1.00 49.5±1.98µs ? ?/sec + contrived/04x_entities_06_systems 1.27 134.3±4.86µs ? ?/sec 1.00 105.8±3.58µs ? ?/sec + contrived/04x_entities_09_systems 1.26 193.2±3.83µs ? ?/sec 1.00 153.0±5.60µs ? ?/sec + contrived/04x_entities_12_systems 1.16 237.1±5.78µs ? ?/sec 1.00 204.9±18.77µs ? ?/sec + contrived/04x_entities_15_systems 1.17 289.2±4.76µs ? ?/sec 1.00 246.3±8.57µs ? ?/sec + contrived/05x_entities_03_systems 1.26 80.4±2.90µs ? ?/sec 1.00 63.7±3.07µs ? ?/sec + contrived/05x_entities_06_systems 1.27 161.6±13.47µs ? ?/sec 1.00 127.2±5.59µs ? ?/sec + contrived/05x_entities_09_systems 1.22 228.0±7.76µs ? ?/sec 1.00 186.2±7.68µs ? ?/sec + contrived/05x_entities_12_systems 1.20 289.5±6.21µs ? ?/sec 1.00 241.8±7.52µs ? ?/sec + contrived/05x_entities_15_systems 1.18 357.3±11.24µs ? ?/sec 1.00 302.7±7.21µs ? ?/sec + heavy_compute/base 1.01 302.4±3.52µs ? ?/sec 1.00 300.2±3.40µs ? ?/sec + iter_fragmented/base 1.00 348.1±7.51ns ? ?/sec 1.01 351.9±8.32ns ? ?/sec + iter_fragmented/foreach 1.03 239.8±23.78ns ? ?/sec 1.00 233.8±18.12ns ? ?/sec + iter_fragmented/foreach_wide 1.00 3.9±0.13µs ? ?/sec 1.02 4.0±0.22µs ? ?/sec + iter_fragmented/wide 1.18 4.6±0.15µs ? ?/sec 1.00 3.9±0.10µs ? ?/sec + iter_fragmented_sparse/base 1.02 8.1±0.15ns ? ?/sec 1.00 7.9±0.56ns ? ?/sec + iter_fragmented_sparse/foreach 1.00 7.8±0.22ns ? ?/sec 1.01 7.9±0.62ns ? ?/sec + iter_fragmented_sparse/foreach_wide 1.00 37.2±1.17ns ? ?/sec 1.10 40.9±0.95ns ? ?/sec + iter_fragmented_sparse/wide 1.09 48.4±2.13ns ? ?/sec 1.00 44.5±18.34ns ? ?/sec + iter_simple/base 1.02 8.4±0.10µs ? ?/sec 1.00 8.2±0.14µs ? ?/sec + iter_simple/foreach 1.01 8.3±0.07µs ? ?/sec 1.00 8.2±0.09µs ? ?/sec + iter_simple/foreach_sparse_set 1.00 25.3±0.32µs ? ?/sec 1.02 25.7±0.42µs ? ?/sec + iter_simple/foreach_wide 1.03 41.1±0.94µs ? ?/sec 1.00 39.9±0.41µs ? ?/sec + iter_simple/foreach_wide_sparse_set 1.05 123.6±2.05µs ? ?/sec 1.00 118.1±2.78µs ? ?/sec + iter_simple/sparse_set 1.14 30.5±1.40µs ? ?/sec 1.00 26.9±0.64µs ? ?/sec + iter_simple/system 1.01 8.4±0.25µs ? ?/sec 1.00 8.4±0.11µs ? ?/sec + iter_simple/wide 1.18 48.2±0.62µs ? ?/sec 1.00 40.7±0.38µs ? ?/sec + iter_simple/wide_sparse_set 1.12 140.8±21.56µs ? ?/sec 1.00 126.0±2.30µs ? ?/sec + query_get/50000_entities_sparse 1.17 378.6±7.60µs ? ?/sec 1.00 324.1±23.17µs ? ?/sec + query_get/50000_entities_table 1.08 330.9±10.90µs ? ?/sec 1.00 306.8±4.98µs ? ?/sec + query_get_component/50000_entities_sparse 1.00 976.7±19.55µs ? ?/sec 1.00 979.8±35.87µs ? ?/sec + query_get_component/50000_entities_table 1.00 1029.0±15.11µs ? ?/sec 1.05 1080.0±59.18µs ? ?/sec + query_get_component_simple/system 1.13 839.7±14.18µs ? ?/sec 1.00 742.8±10.72µs ? ?/sec + query_get_component_simple/unchecked 1.01 909.0±15.17µs ? ?/sec 1.00 898.0±13.56µs ? ?/sec + query_get_many_10/50000_calls_sparse 1.04 5.5±0.54ms ? ?/sec 1.00 5.3±0.67ms ? ?/sec + query_get_many_10/50000_calls_table 1.01 4.9±0.49ms ? ?/sec 1.00 4.8±0.45ms ? ?/sec + query_get_many_2/50000_calls_sparse 1.28 848.4±210.89µs ? ?/sec 1.00 664.8±47.69µs ? ?/sec + query_get_many_2/50000_calls_table 1.05 779.0±73.85µs ? ?/sec 1.00 739.2±83.02µs ? ?/sec + query_get_many_5/50000_calls_sparse 1.05 2.4±0.37ms ? ?/sec 1.00 2.3±0.33ms ? ?/sec + query_get_many_5/50000_calls_table 1.00 1939.9±75.22µs ? ?/sec 1.04 2.0±0.19ms ? ?/sec + run_criteria/yes_using_query/001_systems 1.00 3.7±0.38µs ? ?/sec 1.30 4.9±0.14µs ? ?/sec + run_criteria/yes_using_query/006_systems 1.00 8.9±0.40µs ? ?/sec 1.17 10.3±0.57µs ? ?/sec + run_criteria/yes_using_query/011_systems 1.00 13.9±0.49µs ? ?/sec 1.08 15.0±0.89µs ? ?/sec + run_criteria/yes_using_query/016_systems 1.00 18.8±0.74µs ? ?/sec 1.00 18.8±1.43µs ? ?/sec + run_criteria/yes_using_query/021_systems 1.07 24.1±0.87µs ? ?/sec 1.00 22.6±1.58µs ? ?/sec + run_criteria/yes_using_query/026_systems 1.04 27.9±0.62µs ? ?/sec 1.00 26.8±1.71µs ? ?/sec + run_criteria/yes_using_query/031_systems 1.09 33.3±1.03µs ? ?/sec 1.00 30.5±2.18µs ? ?/sec + run_criteria/yes_using_query/036_systems 1.14 38.7±0.80µs ? ?/sec 1.00 33.9±1.75µs ? ?/sec + run_criteria/yes_using_query/041_systems 1.18 43.7±1.07µs ? ?/sec 1.00 37.0±2.39µs ? ?/sec + run_criteria/yes_using_query/046_systems 1.14 47.6±1.16µs ? ?/sec 1.00 41.9±2.09µs ? ?/sec + run_criteria/yes_using_query/051_systems 1.17 52.9±2.04µs ? ?/sec 1.00 45.3±1.75µs ? ?/sec + run_criteria/yes_using_query/056_systems 1.25 59.2±2.38µs ? ?/sec 1.00 47.2±2.01µs ? ?/sec + run_criteria/yes_using_query/061_systems 1.28 66.1±15.84µs ? ?/sec 1.00 51.5±2.47µs ? ?/sec + run_criteria/yes_using_query/066_systems 1.28 70.2±2.57µs ? ?/sec 1.00 54.7±2.58µs ? ?/sec + run_criteria/yes_using_query/071_systems 1.30 75.5±2.27µs ? ?/sec 1.00 58.2±3.31µs ? ?/sec + run_criteria/yes_using_query/076_systems 1.26 81.5±2.66µs ? ?/sec 1.00 64.5±3.13µs ? ?/sec + run_criteria/yes_using_query/081_systems 1.29 89.7±2.58µs ? ?/sec 1.00 69.3±3.47µs ? ?/sec + run_criteria/yes_using_query/086_systems 1.33 95.6±3.39µs ? ?/sec 1.00 71.8±3.48µs ? ?/sec + run_criteria/yes_using_query/091_systems 1.25 102.0±3.67µs ? ?/sec 1.00 81.4±4.82µs ? ?/sec + run_criteria/yes_using_query/096_systems 1.33 111.7±3.29µs ? ?/sec 1.00 83.8±4.15µs ? ?/sec + run_criteria/yes_using_query/101_systems 1.29 113.2±12.04µs ? ?/sec 1.00 87.7±5.15µs ? ?/sec + world_query_for_each/50000_entities_sparse 1.00 47.4±0.51µs ? ?/sec 1.00 47.3±0.33µs ? ?/sec + world_query_for_each/50000_entities_table 1.00 27.2±0.50µs ? ?/sec 1.00 27.2±0.17µs ? ?/sec + world_query_get/50000_entities_sparse_wide 1.09 210.5±1.78µs ? ?/sec 1.00 192.5±2.61µs ? ?/sec + world_query_get/50000_entities_table 1.00 127.7±2.09µs ? ?/sec 1.07 136.2±5.95µs ? ?/sec + world_query_get/50000_entities_table_wide 1.00 209.8±2.37µs ? ?/sec 1.15 240.6±2.04µs ? ?/sec + world_query_iter/50000_entities_sparse 1.00 54.2±0.36µs ? ?/sec 1.01 54.7±0.61µs ? ?/sec + world_query_iter/50000_entities_table 1.00 27.2±0.31µs ? ?/sec 1.00 27.3±0.64µs ? ?/sec + ``` +
+ + NOTE: This PR includes a change to enable LTO on our benchmarks to get a "fully optimized" baseline for our benchmarks. Both the main and the current PR's results were with LTO enabled. + +commit 2c5d072e76638fd40ef798064c42ab368d1405ff +Author: ira +Date: Fri Nov 4 03:45:17 2022 +0000 + + Allow passing `glam` vector types as vertex attributes (#6442) + + Allow passing `Vec`s of glam vector types as vertex attributes. + Alternative to #4548 and #2719 + + Also used some macros to cut down on all the repetition. + + # Migration Guide + Implementations of `From>` and `From>` for `VertexAttributeValues` have been removed. + I you're passing either `Vec<[u16; 4]>` or `Vec<[u8; 4]>` into `Mesh::insert_attribute` it will now require wrapping it with right the `VertexAttributeValues` enum variant. + + Co-authored-by: devil-ira + +commit 97f7a1a99c4d51d18e215995f0f1018290f79c1d +Author: Gino Valente +Date: Fri Nov 4 02:22:54 2022 +0000 + + bevy_reflect: Binary formats (#6140) + + # Objective + + Closes #5934 + + Currently it is not possible to de/serialize data to non-self-describing formats using reflection. + + ## Solution + + Add support for non-self-describing de/serialization using reflection. + + This allows us to use binary formatters, like [`postcard`](https://crates.io/crates/postcard): + + ```rust + #[derive(Reflect, FromReflect, Debug, PartialEq)] + struct Foo { + data: String + } + + let mut registry = TypeRegistry::new(); + registry.register::(); + + let input = Foo { + data: "Hello world!".to_string() + }; + + // === Serialize! === // + let serializer = ReflectSerializer::new(&input, ®istry); + let bytes: Vec = postcard::to_allocvec(&serializer).unwrap(); + + println!("{:?}", bytes); // Output: [129, 217, 61, 98, ...] + + // === Deserialize! === // + let deserializer = UntypedReflectDeserializer::new(®istry); + + let dynamic_output = deserializer + .deserialize(&mut postcard::Deserializer::from_bytes(&bytes)) + .unwrap(); + + let output = ::from_reflect(dynamic_output.as_ref()).unwrap(); + + assert_eq!(expected, output); // OK! + ``` + + #### Crates Tested + + - ~~[`rmp-serde`](https://crates.io/crates/rmp-serde)~~ Apparently, this _is_ self-describing + - ~~[`bincode` v2.0.0-rc.1](https://crates.io/crates/bincode/2.0.0-rc.1) (using [this PR](https://github.com/bincode-org/bincode/pull/586))~~ This actually works for the latest release (v1.3.3) of [`bincode`](https://crates.io/crates/bincode) as well. You just need to be sure to use fixed-int encoding. + - [`postcard`](https://crates.io/crates/postcard) + + ## Future Work + + Ideally, we would refactor the `serde` module, but I don't think I'll do that in this PR so as to keep the diff relatively small (and to avoid any painful rebases). This should probably be done once this is merged, though. + + Some areas we could improve with a refactor: + + * Split deserialization logic across multiple files + * Consolidate helper functions/structs + * Make the logic more DRY + + --- + + ## Changelog + + - Add support for non-self-describing de/serialization using reflection. + + + Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com> + +commit 4c4f47697c087930ea831c7a5c39b12f0405dd60 +Author: JMS55 +Date: Fri Nov 4 01:34:12 2022 +0000 + + Bloom (#6397) + + # Objective + + - Adds a bloom pass for HDR-enabled Camera3ds. + - Supersedes (and all credit due to!) https://github.com/bevyengine/bevy/pull/3430 and https://github.com/bevyengine/bevy/pull/2876 + + ![image](https://user-images.githubusercontent.com/47158642/198698783-228edc00-20b5-4218-a613-331ccd474f38.png) + + ## Solution + + - A threshold is applied to isolate emissive samples, and then a series of downscale and upscaling passes are applied and composited together. + - Bloom is applied to 2d or 3d Cameras with hdr: true and a BloomSettings component. + + --- + + ## Changelog + + - Added a `core_pipeline::bloom::BloomSettings` component. + - Added `BloomNode` that runs between the main pass and tonemapping. + - Added a `BloomPlugin` that is loaded as part of CorePipelinePlugin. + - Added a bloom example project. + + Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com> + Co-authored-by: Carter Anderson + Co-authored-by: DGriffin91 + +commit 2e653e5774a6ddb0f4b789a27ff51f8927b20439 +Author: Carter Anderson +Date: Thu Nov 3 22:50:41 2022 +0000 + + Fix spawning empty bundles (#6425) + + # Objective + + Alternative to #6424 + Fixes #6226 + + Fixes spawning empty bundles + + ## Solution + + Add `BundleComponentStatus` trait and implement it for `AddBundle` and a new `SpawnBundleStatus` type (which always returns an Added status). `write_components` is now generic on `BundleComponentStatus` instead of taking `AddBundle` directly. This means BundleSpawner can now avoid needing AddBundle from the Empty archetype, which means BundleSpawner no longer needs a reference to the original archetype. + + In theory this cuts down on the work done in `write_components` when spawning, but I'm seeing no change in the spawn benchmarks. + +commit e6a016458768312e72ad669e49cd082a389272a3 +Author: Carter Anderson +Date: Thu Nov 3 21:14:03 2022 +0000 + + Specialize UI pipeline on "hdr-ness" (#6459) + + # Objective + + The UI pass in HDR breaks currently because the color attachment format does not match the HDR ViewTarget. + + ## Solution + + Specialize the UI pipeline on "hdr-ness" and select the appropriate format (like we do in the other built in pipelines). + +commit fc56c686af20f5a91aae436511a634b758d31643 +Author: Robert Swain +Date: Thu Nov 3 20:37:32 2022 +0000 + + bevy_pbr: Fix incorrect and unnecessary normal-mapping code (#5766) + + # Objective + + - Fixes #4019 + - Fix lighting of double-sided materials when using a negative scale + - The FlightHelmet.gltf model's hose uses a double-sided material. Loading the model with a uniform scale of -1.0, and comparing against Blender, it was identified that negating the world-space tangent, bitangent, and interpolated normal produces incorrect lighting. Discussion with Morten Mikkelsen clarified that this is both incorrect and unnecessary. + + ## Solution + + - Remove the code that negates the T, B, and N vectors (the interpolated world-space tangent, calculated world-space bitangent, and interpolated world-space normal) when seeing the back face of a double-sided material with negative scale. + - Negate the world normal for a double-sided back face only when not using normal mapping + + ### Before, on `main`, flipping T, B, and N + + Screenshot 2022-08-22 at 15 11 53 + + ### After, on this PR + + Screenshot 2022-08-22 at 15 12 11 + + ### Double-sided material without normal maps + + https://user-images.githubusercontent.com/302146/185988113-44a384e7-0b55-4946-9b99-20f8c803ab7e.mp4 + + --- + + ## Changelog + + - Fixed: Lighting of normal-mapped, double-sided materials applied to models with negative scale + - Fixed: Lighting and shadowing of back faces with no normal-mapping and a double-sided material + + ## Migration Guide + + `prepare_normal` from the `bevy_pbr::pbr_functions` shader import has been reworked. + + Before: + ```rust + pbr_input.world_normal = in.world_normal; + + pbr_input.N = prepare_normal( + pbr_input.material.flags, + in.world_normal, + #ifdef VERTEX_TANGENTS + #ifdef STANDARDMATERIAL_NORMAL_MAP + in.world_tangent, + #endif + #endif + in.uv, + in.is_front, + ); + ``` + + After: + ```rust + pbr_input.world_normal = prepare_world_normal( + in.world_normal, + (material.flags & STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u, + in.is_front, + ); + + pbr_input.N = apply_normal_mapping( + pbr_input.material.flags, + pbr_input.world_normal, + #ifdef VERTEX_TANGENTS + #ifdef STANDARDMATERIAL_NORMAL_MAP + in.world_tangent, + #endif + #endif + in.uv, + ); + ``` + +commit 30e35764a127da382e300cd2eb390079322c5ece +Author: Boxy +Date: Thu Nov 3 16:33:05 2022 +0000 + + Replace `WorldQueryGats` trait with actual gats (#6319) + + # Objective + + Replace `WorldQueryGats` trait with actual gats + + ## Solution + + Replace `WorldQueryGats` trait with actual gats + + --- + + ## Changelog + + - Replaced `WorldQueryGats` trait with actual gats + + ## Migration Guide + + - Replace usage of `WorldQueryGats` assoc types with the actual gats on `WorldQuery` trait + +commit 157f2c1584a7b535b07fdb43871cab7fed643ad1 +Author: Yasha Borevich +Date: Thu Nov 3 15:33:41 2022 +0000 + + Respect mipmap_filter when create ImageDescriptor with linear()/nearest() (#6349) + + Respect mipmap_filter when create ImageDescriptor with linear()/nearest() + + # Objective + + Fixes #6348 + + ## Migration Guide + + This PR changes default `ImageSettings` and may lead to unexpected behaviour for existing projects with mipmapped textures. Users should provide custom `ImageSettings` resource with `mipmap_filter=FilterMode::Nearest` if they want to keep old behaviour. + + Co-authored-by: Yakov Borevich + +commit aa742395d3d0f4459b1fe74fbb248c2e68819450 +Author: Rob Parrett +Date: Thu Nov 3 15:09:27 2022 +0000 + + Fix trybuild tests broken by rust 1.65 (#6457) + + # Objective + + - Fix tests that now fail in rust 1.65 + + ## Solution + + - Update `.stderr` files with new output + +commit 262b3fc40d7c4171dd585f7127cfb54573edb170 +Author: ira +Date: Thu Nov 3 12:38:47 2022 +0000 + + Fix `mesh.wgsl` error for meshes without normals (#6439) + + # Objective + Split `model` assignment out of `#ifdef VERTEX_NORMALS`. + Remove outdated code/comments talking about required mesh attributes. + + Co-authored-by: devil-ira + +commit 701ed8c59fa2ee2660ce7e8fb6c07d9df030f6a9 +Author: Kurt Kühnert +Date: Thu Nov 3 07:09:51 2022 +0000 + + Increase the `MAX_DIRECTIONAL_LIGHTS` from 1 to 10 (#6066) + + # Objective + + Currently we are limiting the amount of direction lights in a scene to one. + + ## Solution + + Increase the amount of direction lights from 1 to 10. + This still is not a perfect solution, but should unblock many use cases. + We could probably just store the directional lights similar to the point lights in an storage buffer, allowing for an variable amount of directional lights. + + + Co-authored-by: Kurt Kühnert <51823519+Ku95@users.noreply.github.com> + +commit 54a1e51623152172142497424c53f3dccb8b7eb7 +Author: James Liu +Date: Wed Nov 2 23:40:08 2022 +0000 + + TaskPool Panic Handling (#6443) + + # Objective + Right now, the `TaskPool` implementation allows panics to permanently kill worker threads upon panicking. This is currently non-recoverable without using a `std::panic::catch_unwind` in every scheduled task. This is poor ergonomics and even poorer developer experience. This is exacerbated by #2250 as these threads are global and cannot be replaced after initialization. + + Removes the need for temporary fixes like #4998. Fixes #4996. Fixes #6081. Fixes #5285. Fixes #5054. Supersedes #2307. + + ## Solution + + The current solution is to wrap `Executor::run` in `TaskPool` with a `catch_unwind`, and discarding the potential panic. This was taken straight from [smol](https://github.com/smol-rs/smol/blob/404c7bcc0aea59b82d7347058043b8de7133241c/src/spawn.rs#L44)'s current implementation. ~~However, this is not entirely ideal as:~~ + + - ~~the signaled to the awaiting task. We would need to change `Task` to use `async_task::FallibleTask` internally, and even then it doesn't signal *why* it panicked, just that it did.~~ (See below). + - ~~no error is logged of any kind~~ (See below) + - ~~it's unclear if it drops other tasks in the executor~~ (it does not) + - ~~This allows the ECS parallel executor to keep chugging even though a system's task has been dropped. This inevitably leads to deadlock in the executor.~~ Assuming we don't catch the unwind in ParallelExecutor, this will naturally kill the main thread. + + ### Alternatives + A final solution likely will incorporate elements of any or all of the following. + + #### ~~Log and Ignore~~ + ~~Log the panic, drop the task, keep chugging. This only addresses the discoverability of the panic. The process will continue to run, probably deadlocking the executor. tokio's detatched tasks operate in this fashion.~~ + + Panics already do this by default, even when caught by `catch_unwind`. + + #### ~~`catch_unwind` in `ParallelExecutor`~~ + ~~Add another layer catching system-level panics into the `ParallelExecutor`. How the executor continues when a core dependency of many systems fails to run is up for debate.~~ + + `async_task::Task` bubbles up panics already, this will transitively push panics all the way to the main thread. + + #### ~~Emulate/Copy `tokio::JoinHandle` with `Task`~~ + ~~`tokio::JoinHandle` bubbles up the panic from the underlying task when awaited. This can be transitively applied across other APIs that also use `Task` like `Query::par_for_each` and `TaskPool::scope`, bubbling up the panic until it's either caught or it reaches the main thread.~~ + + `async_task::Task` bubbles up panics already, this will transitively push panics all the way to the main thread. + + #### Abort on Panic + The nuclear option. Log the error, abort the entire process on any thread in the task pool panicking. Definitely avoids any additional infrastructure for passing the panic around, and might actually lead to more efficient code as any unwinding is optimized out. However gives the developer zero options for dealing with the issue, a seemingly poor choice for debuggability, and prevents graceful shutdown of the process. Potentially an option for handling very low-level task management (a la #4740). Roughly takes the shape of: + + ```rust + struct AbortOnPanic; + + impl Drop for AbortOnPanic { + fn drop(&mut self) { + abort!(); + } + } + + let guard = AbortOnPanic; + // Run task + std::mem::forget(AbortOnPanic); + ``` + + --- + + ## Changelog + + Changed: `bevy_tasks::TaskPool`'s threads will no longer terminate permanently when a task scheduled onto them panics. + Changed: `bevy_tasks::Task` and`bevy_tasks::Scope` will propagate panics in the spawned tasks/scopes to the parent thread. + +commit 4b5a33d970c50b5e1af3d31bebd26809988ca444 +Author: Gabriel Bourgeois +Date: Wed Nov 2 22:06:04 2022 +0000 + + Add z-index support with a predictable UI stack (#5877) + + # Objective + + Add consistent UI rendering and interaction where deep nodes inside two different hierarchies will never render on top of one-another by default and offer an escape hatch (z-index) for nodes to change their depth. + + ## The problem with current implementation + + The current implementation of UI rendering is broken in that regard, mainly because [it sets the Z value of the `Transform` component based on a "global Z" space](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/update.rs#L43) shared by all nodes in the UI. This doesn't account for the fact that each node's final `GlobalTransform` value will be relative to its parent. This effectively makes the depth unpredictable when two deep trees are rendered on top of one-another. + + At the moment, it's also up to each part of the UI code to sort all of the UI nodes. The solution that's offered here does the full sorting of UI node entities once and offers the result through a resource so that all systems can use it. + + ## Solution + + ### New ZIndex component + This adds a new optional `ZIndex` enum component for nodes which offers two mechanism: + - `ZIndex::Local(i32)`: Overrides the depth of the node relative to its siblings. + - `ZIndex::Global(i32)`: Overrides the depth of the node relative to the UI root. This basically allows any node in the tree to "escape" the parent and be ordered relative to the entire UI. + + Note that in the current implementation, omitting `ZIndex` on a node has the same result as adding `ZIndex::Local(0)`. Additionally, the "global" stacking context is essentially a way to add your node to the root stacking context, so using `ZIndex::Local(n)` on a root node (one without parent) will share that space with all nodes using `Index::Global(n)`. + + ### New UiStack resource + This adds a new `UiStack` resource which is calculated from both hierarchy and `ZIndex` during UI update and contains a vector of all node entities in the UI, ordered by depth (from farthest from camera to closest). This is exposed publicly by the bevy_ui crate with the hope that it can be used for consistent ordering and to reduce the amount of sorting that needs to be done by UI systems (i.e. instead of sorting everything by `global_transform.z` in every system, this array can be iterated over). + + ### New z_index example + This also adds a new z_index example that showcases the new `ZIndex` component. It's also a good general demo of the new UI stack system, because making this kind of UI was very broken with the old system (e.g. nodes would render on top of each other, not respecting hierarchy or insert order at all). + + ![image](https://user-images.githubusercontent.com/1060971/189015985-8ea8f989-0e9d-4601-a7e0-4a27a43a53f9.png) + + --- + + ## Changelog + + - Added the `ZIndex` component to bevy_ui. + - Added the `UiStack` resource to bevy_ui, and added implementation in a new `stack.rs` module. + - Removed the previous Z updating system from bevy_ui, because it was replaced with the above. + - Changed bevy_ui rendering to use UiStack instead of z ordering. + - Changed bevy_ui focus/interaction system to use UiStack instead of z ordering. + - Added a new z_index example. + + ## ZIndex demo + Here's a demo I wrote to test these features + https://user-images.githubusercontent.com/1060971/188329295-d7beebd6-9aee-43ab-821e-d437df5dbe8a.mp4 + + + Co-authored-by: Carter Anderson + +commit 334e09892b4434ab40c76222c919d2f168544ce8 +Author: Alice Cecile +Date: Wed Nov 2 20:40:45 2022 +0000 + + Revert "Show prelude re-exports in docs (#6448)" (#6449) + + This reverts commit 53d387f34039c5d369159a681b279793d71dbd6b. + + # Objective + + Reverts #6448. This didn't have the intended effect: we're now getting bevy::prelude shown in the docs again. + + Co-authored-by: Alejandro Pascual + +commit 53d387f34039c5d369159a681b279793d71dbd6b +Author: Alejandro Pascual +Date: Wed Nov 2 19:35:06 2022 +0000 + + Show prelude re-exports in docs (#6448) + + # Objective + + - Right now re-exports are completely hidden in prelude docs. + - Fixes #6433 + + ## Solution + + - We could show the re-exports without inlining their documentation. + +commit b672465047148b753aca369f8cf82299f4fa33ea +Author: targrub +Date: Wed Nov 2 16:47:40 2022 +0000 + + Fix doctest warnings (#6447) + + # Objective + + - Fixes doctest warnings from upcoming Rust release. + + ` cargo doc --workspace --all-features --no-deps --document-private-items` using `beta-x86_64-pc-windows-msvc (default) + rustc 1.66.0-beta.1 (e080cc5a6 2022-11-01)` was giving warnings on a few comments. + + ## Solution + + - Quoted the Rust code parts. + +commit a8a62fcf3daf23241920ddd4e11f2f154a67a0e3 +Author: Edvin Kjell +Date: Wed Nov 2 15:19:50 2022 +0000 + + [Fixes #6059] ``Entity``'s “ID” should be named “index” instead (#6107) + + # Objective + + Fixes #6059, changing all incorrect occurrences of ``id`` in the ``entity`` module to ``index``: + + * struct level documentation, + * ``id`` struct field, + * ``id`` method and its documentation. + + ## Solution + + Renaming and verifying using CI. + + + Co-authored-by: Edvin Kjell <43633999+Edwox@users.noreply.github.com> + +commit ed3ecda91d9df58fb782800f8867dc257ccf1a61 +Author: BeastLe9enD +Date: Wed Nov 2 12:27:22 2022 +0000 + + Add `is_finished` to `Task` (#6444) + + # Objective + + In some scenarios it can be useful to check if a task has been finished without polling it. I added a function called `is_finished` to check if a task has been finished. + + ## Solution + + Since `async_task` supports it out of the box, it is just a simple wrapper function. + + --- + +commit 5640ec855e3e932a4addaa5e5f3d0dd4800f44f8 +Author: Griffin +Date: Wed Nov 2 06:51:28 2022 +0000 + + Add FXAA postprocessing (#6393) + + # Objective + + - Add post processing passes for FXAA (Fast Approximate Anti-Aliasing) + - Add example comparing MSAA and FXAA + + ## Solution + + When the FXAA plugin is added, passes for FXAA are inserted between the main pass and the tonemapping pass. Supports using either HDR or LDR output from the main pass. + + --- + + ## Changelog + + - Add a new FXAANode that runs after the main pass when the FXAA plugin is added. + + Co-authored-by: Carter Anderson + +commit 1f22d544891adbeb717f5a8dac3e814b8e521a14 +Author: CGMossa +Date: Tue Nov 1 23:44:55 2022 +0000 + + Fixed docs for `derive(WorldQuery)`. (#5283) + + For `derive(WorldQuery)`, there are three structs generated, `Item`, `Fetch` and `State`. + These inherit the visibility of the derived structure, thus `#![warn(missing_docs)]` would + warn about missing documentation for these structures. + + - [ ] I'd like some advice on what to write here, as I personally don't really understand `Fetch` nor `State`. + +commit 0cfdbddf2e6350b11bd9dce2d4fe89ac9c99aec9 +Author: Ida Iyes +Date: Tue Nov 1 11:35:44 2022 +0000 + + bevy_dynamic_plugin: make it possible to handle loading errors (#6437) + + # Objective + + Currently, `bevy_dynamic_plugin` simply panics on error. This makes it impossible to handle failures in applications that use this feature. + + For example, I'd like to build an optional expansion for my game, that may not be distributed to all users. I want to use `bevy_dynamic_plugin` for loading it. I want my game to try to load it on startup, but continue without it if it cannot be loaded. + + ## Solution + + - Make the `dynamically_load_plugin` function return a `Result`, so it can gracefully return loading errors. + - Create an error enum type, to provide useful information about the kind of error. This adds `thiserror` to the dependencies of `bevy_dynamic_plugin`, but that dependency is already used in other parts of bevy (such as `bevy_asset`), so not a big deal. + + I chose not to change the behavior of the builder method in the App extension trait. I kept it as panicking. There is no clean way (that I'm aware of) to make a builder-style API that has fallible methods. So it is either a panic or a warning. I feel the panic is more appropriate. + + --- + + ## Changelog + + ### Changed + - `bevy_dynamic_plugin::dynamically_load_plugin` now returns `Result` instead of panicking, to allow for error handling + +commit 3d6706f86d91d8c8df2f88f4b3dd6344580fc037 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Tue Nov 1 03:51:41 2022 +0000 + + Speed up `Query::get_many` and add benchmarks (#6400) + + # Objective + + * Add benchmarks for `Query::get_many`. + * Speed up `Query::get_many`. + + ## Solution + + Previously, `get_many` and `get_many_mut` used the method `array::map`, which tends to optimize very poorly. This PR replaces uses of that method with loops. + + ## Benchmarks + + | Benchmark name | Execution time | Change from this PR | + |--------------------------------------|----------------|---------------------| + | query_get_many_2/50000_calls_table | 1.3732 ms | -24.967% | + | query_get_many_2/50000_calls_sparse | 1.3826 ms | -24.572% | + | query_get_many_5/50000_calls_table | 2.6833 ms | -30.681% | + | query_get_many_5/50000_calls_sparse | 2.9936 ms | -30.672% | + | query_get_many_10/50000_calls_table | 5.7771 ms | -36.950% | + | query_get_many_10/50000_calls_sparse | 7.4345 ms | -36.987% | + +commit e7719bf245249fe51d2897dd54bb93986096d230 +Author: Lucas Jenß +Date: Tue Nov 1 03:15:34 2022 +0000 + + Mention world_query(ignore) attribute for WorldQuery derivation (#6309) + + # Objective + + Add documentation `#[world_query(ignore)]`. Fixes #6283. + + --- + + I've only described it's behavior so far (which appears to be the same as with `system_param`). Is there another use-case for this besides with `PhantomData`? I could only find a single usage of this construct on GitHub, which is [here](https://github.com/tqwewe/bevy-editor-2/blob/ffcb816927a1bbdcf1cb0136ce47864e5040f9fb/bevy/examples/ecs/custom_query_param.rs#L102). + + I was also wondering if it would make sense to add a usage example to the `custom_query_example`? 🤔 That's why it's currently still in there. + + + + + Co-authored-by: Lucas Jenß <243719+x3ro@users.noreply.github.com> + +commit 87d4c6380da909f399f5d988f8d9554e518f4cb4 +Author: Hennadii Chernyshchyk +Date: Mon Oct 31 21:20:57 2022 +0000 + + Add `serialize` feature to `bevy_core` (#6423) + + # Objective + + `bevy_core` is missing a feature corresponding to the `serialize` feature on the `bevy` crate. Similar to #6378 and https://github.com/bevyengine/bevy/pull/6379 to serialize `Name` easily. + + ## Solution + + Add this feature and hand-written serialization for `Name` (to avoid storing `hash` field). + + --- + + ## Changelog + + ### Added + + * `Serialize` and `Deserialize` derives for `Name` under `serialize` feature. + +commit b6e46a73cda4946ade06f346b16da68b42faa367 +Author: Carter Anderson +Date: Mon Oct 31 20:22:18 2022 +0000 + + Rework ViewTarget to better support post processing (#6415) + + # Objective + + Post processing effects cannot read and write to the same texture. Currently they must own their own intermediate texture and redundantly copy from that back to the main texture. This is very inefficient. + + Additionally, working with ViewTarget is more complicated than it needs to be, especially when working with HDR textures. + + ## Solution + + `ViewTarget` now stores two copies of the "main texture". It uses an atomic value to track which is currently the "main texture" (this interior mutability is necessary to accommodate read-only RenderGraph execution). + + `ViewTarget` now has a `post_process_write` method, which will return a source and destination texture. Each call to this method will flip between the two copies of the "main texture". + + ```rust + let post_process = render_target.post_process_write(); + let source_texture = post_process.source; + let destination_texture = post_process.destination; + ``` + The caller _must_ read from the source texture and write to the destination texture, as it is assumed that the destination texture will become the new "main texture". + + + For simplicity / understandability `ViewTarget` is now a flat type. "hdr-ness" is a property of the `TextureFormat`. The internals are fully private in the interest of providing simple / consistent apis. Developers can now easily access the main texture by calling `view_target.main_texture()`. + + HDR ViewTargets no longer have an "ldr texture" with `TextureFormat::bevy_default`. They _only_ have their two "hdr" textures. This simplifies the mental model. All we have is the "currently active hdr texture" and the "other hdr texture", which we flip between for post processing effects. + + The tonemapping node has been rephrased to use this "post processing pattern". The blit pass has been removed, and it now only runs a pass when HDR is enabled. Notably, both the input and output texture are assumed to be HDR. This means that tonemapping behaves just like any other "post processing effect". It could theoretically be moved anywhere in the "effect chain" and continue to work. + + In general, I think these changes will make the lives of people making post processing effects much easier. And they better position us to start building higher level / more structured "post processing effect stacks". + + --- + + ## Changelog + + - `ViewTarget` now stores two copies of the "main texture". Calling `ViewTarget::post_process_write` will flip between copies of the main texture. + +commit 89b3422f62f49f9ec519165bf1feb750c4e603ba +Author: François +Date: Mon Oct 31 17:36:23 2022 +0000 + + migrate away from actions-rs actions to dtolnay/rust-toolchain (#6432) + + # Objective + + - actions from actions-rs are outdated and use deprecated function + - They haven't been updated for the last two years (https://github.com/actions-rs/toolchain) + + ## Solution + + - use the newer and up-to-date https://github.com/dtolnay/rust-toolchain + +commit 55b3cb01834d66b322aba4844253039561578c64 +Author: Jakob Hellermann +Date: Mon Oct 31 16:35:22 2022 +0000 + + add `ReflectDefault` to std types (#6429) + + # Objective + + - `ReflectDefault` can be used to create default values for reflected types + - `std` primitives that are `Default`-constructable should register `ReflectDefault` + + ## Solution + + - register `ReflectDefault` + +commit 558859691ec505a32d84252fac4bc3267bd66659 +Author: Niklas Eicker +Date: Mon Oct 31 16:35:20 2022 +0000 + + Fix return_after_run example (#6420) + + # Objective + + - Fixes #6311 + - Make it clearer what should be done in the example (close the Bevy app window) + + ## Solution + + - Remove the second windowed Bevy App [since winit does not support this](https://github.com/rust-windowing/winit/blob/v0.27.4/src/event_loop.rs#L82-L83) + - Add title to the Bevy window asking the user to close it + + This is more of a quick fix to have a working example. It would be nicer if we had a small real usecase for this functionality. + Another alternativ that I tried out: If we want to showcase a second Bevy app as it was before, we could still do this as long as one of them does not have a window. But I don't see how this is helpful in the context of the example, so I stuck with only one Bevy app and a simple print afterwards. + +commit bb968f41bc1a0ec9a4ee0449cf272ff77e504646 +Author: Gino Valente +Date: Mon Oct 31 16:35:18 2022 +0000 + + bevy_scene: Serialize entities to map (#6416) + + # Objective + + Entities are unique, however, this is not reflected in the scene format. Currently, entities are stored in a list where a user could inadvertently create a duplicate of the same entity. + + ## Solution + + Switch from the list representation to a map representation for entities. + + --- + + ## Changelog + + * The `entities` field in the scene format is now a map of entity ID to entity data + + ## Migration Guide + + The scene format now stores its collection of entities in a map rather than a list: + + ```rust + // OLD + ( + entities: [ + ( + entity: 12, + components: { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + }, + ), + ], + ) + + // NEW + ( + entities: { + 12: ( + components: { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + }, + ), + }, + ) + ``` + +commit 8cdd977a12053d141ed232d9f0bd289c13b55708 +Author: François +Date: Mon Oct 31 16:12:19 2022 +0000 + + Unique plugin (#6411) + + # Objective + + - Make it impossible to add a plugin twice + - This is going to be more a risk for plugins with configurations, to avoid things like `App::new().add_plugins(DefaultPlugins).add_plugin(ImagePlugin::default_nearest())` + + ## Solution + + - Panic when a plugin is added twice + - It's still possible to mark a plugin as not unique by overriding `is_unique` + - ~~Simpler version of~~ #3988 (not simpler anymore because of how `PluginGroupBuilder` implements `PluginGroup`) + +commit ca82fa883beacd973cb86a8141c11a36f6256573 +Author: François +Date: Mon Oct 31 16:12:18 2022 +0000 + + do not set cursor grab on window creation if not asked for (#6381) + + # Objective + + - Bevy main crashs on Safari mobile + - On Safari mobile, calling winit_window.set_cursor_grab(true) fails as the API is not implemented (as there is no cursor on Safari mobile, the api doesn't make sense there). I don't know about other mobile browsers + + ## Solution + + - Do not call the api to release cursor grab on window creation, as the cursor is not grabbed anyway at this point + - This is #3617 which was lost in #6218 + +commit bf6c457553bf97df58977e3bb1c01572b0927e6d +Author: amiani +Date: Mon Oct 31 16:12:15 2022 +0000 + + add serialize feature to bevy_transform (#6379) + + # Objective + Fixes #6378 + `bevy_transform` is missing a feature corresponding to the `serialize` feature on the `bevy` crate. + + ## Solution + + Adds a `serialize` feature to `bevy_transform`. + Derives `serde::Serialize` and `Deserialize` when feature is enabled. + +commit 599ca782e3159b95db3808af22f9abac9bbbe005 +Author: Lena Milizé +Date: Mon Oct 31 15:57:51 2022 +0000 + + Add a way to toggle `AudioSink` (#6321) + + # Objective + + Currently toggling an `AudioSink` (for example from a game menu) requires writing + + ```rs + if sink.is_paused() { + sink.play(); + } else { + sink.pause(); + } + ``` + + It would be nicer if we could reduce this down to a single line + + ```rs + sink.toggle(); + ``` + + ## Solution + + Add an `AudioSink::toggle` method which does exactly that. + + --- + + ## Changelog + + - Added `AudioSink::toggle` which can be used to toggle state of a sink. + +commit 13da481bea13236dc96afee60cd593d842e0e54c +Author: ira +Date: Mon Oct 31 15:57:50 2022 +0000 + + Add methods to `Query<&Children>` and `Query<&Parent>` to iterate over descendants and ancestors (#6185) + + # Objective + Add methods to `Query<&Children>` and `Query<&Parent>` to iterate over descendants and ancestors, respectively. + + ## Changelog + + * Added extension trait for `Query` in `bevy_hierarchy`, `HierarchyQueryExt` + * Added method `iter_descendants` to `Query<&Children>` via `HierarchyQueryExt` for iterating over the descendants of an entity. + * Added method `iter_ancestors` to `Query<&Parent>` via `HierarchyQueryExt` for iterating over the ancestors of an entity. + + Co-authored-by: devil-ira + +commit 8b9aa2cceb34f166854201d7727730ac7aba5357 +Author: Yoh Deadfall +Date: Mon Oct 31 15:36:08 2022 +0000 + + Freeing memory held by visible entities vector (#3009) + + - Freeing unused memory held by visible entities + - Fixed comment style + + # Objective + + With Rust 1.56 it's possible to shrink vectors to a specified capacity. Visibility system had a comment before asking for that feature to free unused memory by a vector if its capacity is two times larger than the length. + + ## Solution + + Shrinking the vector of visible entities to the nearest power of 2 elements next to `len()`, if capacity exceeds it more than two times. + +commit 75403289b2e875b3af21a8617d44c039bdbbb40b +Author: Hennadii Chernyshchyk +Date: Sun Oct 30 16:02:31 2022 +0000 + + Add FromReflect for Timer (#6422) + + # Objective + + - Time have `Reflect`, but doesn't have `FromReflect`. + + ## Solution + + - Add it for `Timer`, `Stopwatch` and `TimerMode`. + + --- + + ## Changelog + + ### Added + + * `FromReflect` derive for `Timer`, `Stopwatch` and `TimerMode`. + +commit aa8c74591bf539aa23778914b45e1231b0bc6426 +Author: Patrick Towles +Date: Sun Oct 30 00:00:47 2022 +0000 + + Removed web-sys from bevy_window, never used (#6414) + + # Objective + + Noticed bevy_window doesn't ever use web-sys. + That logic resides to bevy_winit and winit. + + ## Solution + + Remove web-sys dependency + +commit cca0ca5025973677c159ee62a0c903c6b96e340e +Author: Hennadii Chernyshchyk +Date: Sat Oct 29 22:32:47 2022 +0000 + + Add FromReflect for Visibility (#6410) + + # Objective + + - `Visibility` don't have `FromReflect` derive. + + ## Solution + + - Add it. + + --- + + ## Changelog + + ### Added + + - `FromReflect` for `Visibility`. + +commit 336049da68b7eb9284915b0ae66a6e80832489df +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Sat Oct 29 18:15:28 2022 +0000 + + Remove outdated uses of single-tuple bundles (#6406) + + # Objective + + Bevy still has many instances of using single-tuples `(T,)` to create a bundle. Due to #2975, this is no longer necessary. + + ## Solution + + Search for regex `\(.+\s*,\)`. This should have found every instance. + +commit dfb80ee74fe00c5d3794ba08e6aefc2fe4981f7d +Author: Carter Anderson +Date: Sat Oct 29 04:13:54 2022 +0000 + + Fix query.to_readonly().get_component_mut() soundness bug (#6401) + + # Objective + + Fix the soundness issue outlined in #5866. In short the problem is that `query.to_readonly().get_component_mut::()` can provide unsound mutable access to the component. This PR is an alternative to just removing the offending api. Given that `to_readonly` is a useful tool, I think this approach is a preferable short term solution. Long term I think theres a better solution out there, but we can find that on its own time. + + ## Solution + + Add what amounts to a "dirty flag" that marks Queries that have been converted to their read-only variant via `to_readonly` as dirty. When this flag is set to true, `get_component_mut` will fail with an error, preventing the unsound access. + +commit dd7ff887604ff3c101161476776740ef6bca9173 +Author: Zhixing Zhang +Date: Fri Oct 28 22:43:16 2022 +0000 + + Add multi draw indirect draw calls (#6392) + + # Objective + + - Allows bevy users to dispatch `multi_draw_indirect`, `multi_draw_indexed_indirect`, `multi_draw_indirect_count`, `multi_draw_indexed_indirect_count` draw calls. + - Fixes #6216 + + ## Solution + + - Added the corresponding wrapper methods to `TrackedRenderPass` + + --- + + ## Changelog + + > Added `multi_draw_*` draw calls to `TrackedRenderPass` + + + Co-authored-by: Zhixing Zhang + +commit 306c1ac6177d8ff55c07410b8aaac5ff4cf84020 +Author: Mark Nokalt +Date: Fri Oct 28 22:43:14 2022 +0000 + + Rename Handle::as_weak() to cast_weak() (#5321) + + # Objective + + Following discussion on #3536 and #3522, `Handle::as_weak()` takes a type `U`, reinterpreting the handle as of another asset type while keeping the same ID. This is mainly used today in font atlas code. This PR does two things: + + - Rename the method to `cast_weak()` to make its intent more clear + - Actually change the type uuid in the handle if it's not an asset path variant. + + ## Migration Guide + + - Rename `Handle::as_weak` uses to `Handle::cast_weak` + + The method now properly sets the associated type uuid if the handle is a direct reference (e.g. not a reference to an `AssetPath`), so adjust you code accordingly if you relied on the previous behavior. + +commit 71f8b4a92f48b24a9c268fc08e747390bcb43f41 +Author: Hennadii Chernyshchyk +Date: Fri Oct 28 22:21:30 2022 +0000 + + Use default serde impls for Entity (#6194) + + # Objective + + Currently for entities we serialize only `id`. But this is not very expected behavior. For example, in networking, when the server sends its state, it contains entities and components. On the client, I create new objects and map them (using `EntityMap`) to those received from the server (to know which one matches which). And if `generation` field is missing, this mapping can be broken. Example: + + 1. Server sends an entity `Entity{ id: 2, generation: 1}` with components. + 2. Client puts the received entity in a map and create a new entity that maps to this received entity. The new entity have different `id` and `generation`. Let's call it `Entity{ id: 12, generation: 4}`. + 3. Client sends a command for `Entity{ id: 12, generation: 4}`. To do so, it maps local entity to the one from server. But `generation` field is 0 because it was omitted for serialization on the server. So it maps to `Entity{ id: 2, generation: 0}`. + 4. Server receives `Entity{ id: 2, generation: 0}` which is invalid. + + In my game I worked around it by [writing custom serialization](https://github.com/dollisgame/dollis/blob/master/src/core/network/entity_serde.rs) and using `serde(with = "...")`. But it feels like a bad default to me. + + Using `Entity` over a custom `NetworkId` also have the following advantages: + + 1. Re-use `MapEntities` trait to map `Entity`s in replicated components. + 2. Instead of server `Entity <-> NetworkId ` and `Entity <-> NetworkId`, we map entities only on client. + 3. No need to handling uniqueness. It's a rare case, but makes things simpler. For example, I don't need to query for a resource to create an unique ID. + + Closes #6143. + + ## Solution + + Use default serde impls. If anyone want to avoid wasting memory on `generation`, they can create a new type that holds `u32`. This is what Bevy do for [DynamicEntity](https://docs.rs/bevy/latest/bevy/scene/struct.DynamicEntity.html) to serialize scenes. And I don't see any use case to serialize an entity id expect this one. + + --- + + ## Changelog + + ### Changed + + - Entity now serializes / deserializes `generation` field. + + ## Migration Guide + + - Entity now fully serialized. If you want to serialze only `id`, as it was before, you can create a new type that wraps `u32`. + +commit d8bf5f82249da10e88a28856e00444276b14f048 +Author: Carter Anderson +Date: Fri Oct 28 21:51:38 2022 +0000 + + Update tracing-chrome to 0.6.0 (#6398) + + Alternative to #4799 + + Tested and this works as expected + +commit e71c4d280294aba2ad494443170790dfba67ba03 +Author: Jakob Hellermann +Date: Fri Oct 28 21:03:01 2022 +0000 + + fix nightly clippy warnings (#6395) + + # Objective + + - fix new clippy lints before they get stable and break CI + + ## Solution + + - run `clippy --fix` to auto-fix machine-applicable lints + - silence `clippy::should_implement_trait` for `fn HandleId::default` + + ## Changes + - always prefer `format!("{inline}")` over `format!("{}", not_inline)` + - prefer `Box::default` (or `Box::::default` if necessary) over `Box::new(T::default())` + +commit c27186c1d611c2a7d6a790adb6acf3b652cbd930 +Author: Waffle Maybe +Date: Fri Oct 28 21:03:00 2022 +0000 + + Fix "previous release tag" link in the changelog (#6394) + + Simply fix an outdated tag in `CHANGELOG.md`. + +commit f867319336541acb8ed80743c723effeb4be8896 +Author: Jakob Hellermann +Date: Fri Oct 28 20:42:33 2022 +0000 + + add `ReflectAsset` and `ReflectHandle` (#5923) + + # Objective + ![image](https://user-images.githubusercontent.com/22177966/189350194-639a0211-e984-4f73-ae62-0ede44891eb9.png) + + ^ enable this + + Concretely, I need to + - list all handle ids for an asset type + - fetch the asset as `dyn Reflect`, given a `HandleUntyped` + - when encountering a `Handle`, find out what asset type that handle refers to (`T`'s type id) and turn the handle into a `HandleUntyped` + + ## Solution + + - add `ReflectAsset` type containing function pointers for working with assets + ```rust + pub struct ReflectAsset { + type_uuid: Uuid, + assets_resource_type_id: TypeId, // TypeId of the `Assets` resource + + get: fn(&World, HandleUntyped) -> Option<&dyn Reflect>, + get_mut: fn(&mut World, HandleUntyped) -> Option<&mut dyn Reflect>, + get_unchecked_mut: unsafe fn(&World, HandleUntyped) -> Option<&mut dyn Reflect>, + add: fn(&mut World, &dyn Reflect) -> HandleUntyped, + set: fn(&mut World, HandleUntyped, &dyn Reflect) -> HandleUntyped, + len: fn(&World) -> usize, + ids: for<'w> fn(&'w World) -> Box + 'w>, + remove: fn(&mut World, HandleUntyped) -> Option>, + } + ``` + - add `ReflectHandle` type relating the handle back to the asset type and providing a way to create a `HandleUntyped` + ```rust + pub struct ReflectHandle { + type_uuid: Uuid, + asset_type_id: TypeId, + downcast_handle_untyped: fn(&dyn Any) -> Option, + } + ``` + - add the corresponding `FromType` impls + - add a function `app.register_asset_reflect` which is supposed to be called after `.add_asset` and registers `ReflectAsset` and `ReflectHandle` in the type registry + --- + + ## Changelog + + - add `ReflectAsset` and `ReflectHandle` types, which allow code to use reflection to manipulate arbitrary assets without knowing their types at compile time + +commit 0401f04ba971f49cba92d0c7da93cc8dc9f9a3de +Author: Jakob Hellermann +Date: Fri Oct 28 19:56:31 2022 +0000 + + update camera projection if viewport changed (#5945) + + fixes https://github.com/bevyengine/bevy/issues/5944 + + Uses the second solution: + > 2. keep track of the old viewport in the computed_state, and if camera.viewport != camera.computed_state.old_viewport, then update the projection. This is more reliable, but needs to store two UVec2s more in the camera (probably not a big deal). + +commit fe7ebd432675e2fb155028a7bda43482e0c90a52 +Author: James Liu +Date: Fri Oct 28 09:25:50 2022 +0000 + + Clean up Fetch code (#4800) + + # Objective + Clean up code surrounding fetch by pulling out the common parts into the iteration code. + + ## Solution + Merge `Fetch::table_fetch` and `Fetch::archetype_fetch` into a single API: `Fetch::fetch(&mut self, entity: &Entity, table_row: &usize)`. This provides everything any fetch requires to internally decide which storage to read from and get the underlying data. All of these functions are marked as `#[inline(always)]` and the arguments are passed as references to attempt to optimize out the argument that isn't being used. + + External to `Fetch`, Query iteration has been changed to keep track of the table row and entity outside of fetch, which moves a lot of the expensive bookkeeping `Fetch` structs had previously done internally into the outer loop. + + ~~TODO: Benchmark, docs~~ Done. + + --- + + ## Changelog + Changed: `Fetch::table_fetch` and `Fetch::archetype_fetch` have been merged into a single `Fetch::fetch` function. + + ## Migration Guide + TODO + + Co-authored-by: Brian Merchant + Co-authored-by: Saverio Miroddi + +commit 284b1f13020527f2858c2de66a5cc7e3a97bc211 +Author: Gino Valente +Date: Thu Oct 27 23:38:03 2022 +0000 + + bevy_scene: Stabilize entity order in `DynamicSceneBuilder` (#6382) + + # Objective + + Currently, `DynamicSceneBuilder` keeps track of entities via a `HashMap`. This has an unintended side-effect in that, when building the full `DynamicScene`, we aren't guaranteed any particular order. + + In other words, inserting Entity A then Entity B can result in either `[A, B]` or `[B, A]`. This can be rather annoying when running tests on scenes generated via the builder as it will work sometimes but not other times. There's also the potential that this might unnecessarily clutter up VCS diffs for scene files (assuming they had an intentional order). + + ## Solution + + Store `DynamicSceneBuilder`'s entities in a `Vec` rather than a `HashMap`. + + --- + + ## Changelog + + * Stablized entity order in `DynamicSceneBuilder` (0.9.0-dev) + +commit 4bcf49b2ea6fb5f42388b0e15d204020053ee5c7 +Author: Hans Meine +Date: Thu Oct 27 15:48:29 2022 +0000 + + elaborate on Timer docs (#6385) + + These tiny changes answer question I had when using the Timer class. + +commit 456971381c1c51edc6df46bbcbfccd5a7392aca7 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Thu Oct 27 12:56:03 2022 +0000 + + Resolve most remaining execution-order ambiguities (#6341) + + # Objective + + Bevy's internal plugins have lots of execution-order ambiguities, which makes the ambiguity detection tool very noisy for our users. + + ## Solution + + Silence every last ambiguity that can currently be resolved. + Each time an ambiguity is silenced, it is accompanied by a comment describing why it is correct. This description should be based on the public API of the respective systems. Thus, I have added documentation to some systems describing how they use some resources. + + # Future work + + Some ambiguities remain, due to issues out of scope for this PR. + + * The ambiguity checker does not respect `Without<>` filters, leading to false positives. + * Ambiguities between `bevy_ui` and `bevy_animation` cannot be resolved, since neither crate knows that the other exists. We will need a general solution to this problem. + +commit 0934abc6bbd83c9dfdf019d73b4566c1848af5ae +Author: Elbert Ronnie +Date: Thu Oct 27 12:34:38 2022 +0000 + + Expose rodio's Source and Sample traits in bevy_audio (#6374) + + # Objective + + - Fixes #5876 . + + ## Solution + + - added pub use statements to re-export the following traits in bevy_audio: rodio::source::Source, rodio::Sample, rodio::cpal::Sample. + - rodio::cpal::Sample was re-exported as CpalSample to avoid naming conflict with rodio::Sample. + +commit 894334b51e8fcab57a4c58fe3a45018c21c0a887 +Author: Gino Valente +Date: Thu Oct 27 01:46:33 2022 +0000 + + bevy_scene: Use map for scene `components` (#6345) + + # Objective + + Currently scenes define components using a list: + + ```rust + [ + ( + entity: 0, + components: [ + { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + }, + { + "my_crate::Foo": ( + text: "Hello World", + ), + }, + { + "my_crate::Bar": ( + baz: 123, + ), + }, + ], + ), + ] + ``` + + However, this representation has some drawbacks (as pointed out by @Metadorius in [this](https://github.com/bevyengine/bevy/pull/4561#issuecomment-1202215565) comment): + + 1. Increased nesting and more characters (minor effect on overall size) + 2. More importantly, by definition, entities cannot have more than one instance of any given component. Therefore, such data is best stored as a map— where all values are meant to have unique keys. + + + ## Solution + + Change `components` to store a map of components rather than a list: + + ```rust + [ + ( + entity: 0, + components: { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + "my_crate::Foo": ( + text: "Hello World", + ), + "my_crate::Bar": ( + baz: 123 + ), + }, + ), + ] + ``` + + #### Code Representation + + This change only affects the scene format itself. `DynamicEntity` still stores its components as a list. The reason for this is that storing such data as a map is not really needed since: + 1. The "key" of each value is easily found by just calling `Reflect::type_name` on it + 2. We should be generating such structs using the `World` itself which upholds the one-component-per-entity rule + + One could in theory create manually create a `DynamicEntity` with duplicate components, but this isn't something I think we should focus on in this PR. `DynamicEntity` can be broken in other ways (i.e. storing a non-component in the components list), and resolving its issues can be done in a separate PR. + + --- + + ## Changelog + + * The scene format now uses a map to represent the collection of components rather than a list + + ## Migration Guide + + The scene format now uses a map to represent the collection of components. Scene files will need to update from the old list format. + +
+ Example Code + + ```rust + // OLD + [ + ( + entity: 0, + components: [ + { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + }, + { + "my_crate::Foo": ( + text: "Hello World", + ), + }, + { + "my_crate::Bar": ( + baz: 123, + ), + }, + ], + ), + ] + + // NEW + [ + ( + entity: 0, + components: { + "bevy_transform::components::transform::Transform": ( + translation: ( + x: 0.0, + y: 0.0, + z: 0.0 + ), + rotation: (0.0, 0.0, 0.0, 1.0), + scale: ( + x: 1.0, + y: 1.0, + z: 1.0 + ), + ), + "my_crate::Foo": ( + text: "Hello World", + ), + "my_crate::Bar": ( + baz: 123 + ), + }, + ), + ] + ``` + +
+ +commit 4d3d3c869e94580ca0b12ba9a412ccbd3c6f517f +Author: Carter Anderson +Date: Wed Oct 26 23:12:12 2022 +0000 + + Support arbitrary RenderTarget texture formats (#6380) + + # Objective + + Currently, Bevy only supports rendering to the current "surface texture format". This means that "render to texture" scenarios must use the exact format the primary window's surface uses, or Bevy will crash. This is even harder than it used to be now that we detect preferred surface formats at runtime instead of using hard coded BevyDefault values. + + ## Solution + + 1. Look up and store each window surface's texture format alongside other extracted window information + 2. Specialize the upscaling pass on the current `RenderTarget`'s texture format, now that we can cheaply correlate render targets to their current texture format + 3. Remove the old `SurfaceTextureFormat` and `AvailableTextureFormats`: these are now redundant with the information stored on each extracted window, and probably should not have been globals in the first place (as in theory each surface could have a different format). + + This means you can now use any texture format you want when rendering to a texture! For example, changing the `render_to_texture` example to use `R16Float` now doesn't crash / properly only stores the red component: + ![image](https://user-images.githubusercontent.com/2694663/198140125-c606dd0e-6fdf-4544-b93d-dbbd10dbadd2.png) + +commit 838b318863a4d9374e16c8b46dce8be53519c88f +Author: Jakob Hellermann +Date: Wed Oct 26 20:13:59 2022 +0000 + + separate tonemapping and upscaling passes (#3425) + + Attempt to make features like bloom https://github.com/bevyengine/bevy/pull/2876 easier to implement. + + **This PR:** + - Moves the tonemapping from `pbr.wgsl` into a separate pass + - also add a separate upscaling pass after the tonemapping which writes to the swap chain (enables resolution-independant rendering and post-processing after tonemapping) + - adds a `hdr` bool to the camera which controls whether the pbr and sprite shaders render into a `Rgba16Float` texture + + **Open questions:** + - ~should the 2d graph work the same as the 3d one?~ it is the same now + - ~The current solution is a bit inflexible because while you can add a post processing pass that writes to e.g. the `hdr_texture`, you can't write to a separate `user_postprocess_texture` while reading the `hdr_texture` and tell the tone mapping pass to read from the `user_postprocess_texture` instead. If the tonemapping and upscaling render graph nodes were to take in a `TextureView` instead of the view entity this would almost work, but the bind groups for their respective input textures are already created in the `Queue` render stage in the hardcoded order.~ solved by creating bind groups in render node + + **New render graph:** + + ![render_graph](https://user-images.githubusercontent.com/22177966/147767249-57dd4229-cfab-4ec5-9bf3-dc76dccf8e8b.png) +
+ Before + + ![render_graph_old](https://user-images.githubusercontent.com/22177966/147284579-c895fdbd-4028-41cf-914c-e1ffef60e44e.png) +
+ + Co-authored-by: Carter Anderson + +commit 2023ce63c7362385372f1d231e72f00747cb3187 +Author: TehPers +Date: Wed Oct 26 19:52:20 2022 +0000 + + Derive `Reflect` + `FromReflect` for input types (#6232) + + # Objective + + Adds support for reflecting many more of the input types. This allows those types to be used via scripting, `bevy-inspector-egui`, etc. These types are registered by the `InputPlugin` so that they're automatically available to anyone who wants to use them + + Closes #6223 + + ## Solution + + Many types now have `#[derive(Reflect, FromReflect)]` added to them in `bevy_input`. Additionally, `#[reflect(traits...)]` has been added for applicable traits to the types. + + This PR does not add reflection support for types which have private fields. Notably, `Touch` and `Touches` don't implement `Reflect`/`FromReflect`. + + This adds the "glam" feature to the `bevy_reflect` dependency for package `bevy_input`. Since `bevy_input` transitively depends on `glam` already, all this brings in are the reflection `impl`s. + + ## Migration Guide + + - `Input` now implements `Reflect` via `#[reflect]` instead of `#[reflect_value]`. This means it now exposes its private fields via the `Reflect` trait rather than being treated as a value type. For code that relies on the `Input` struct being treated as a value type by reflection, it is still possible to wrap the `Input` type with a wrapper struct and apply `#[reflect_value]` to it. + - As a reminder, private fields exposed via reflection are not subject to any stability guarantees. + --- + + ## Changelog + + Added + - Implemented `Reflect` + `FromReflect` for many input-related types. These types are automatically registered when adding the `InputPlugin`. + +commit c18b1a839b70ad32ce9ca924bf7bf9dd8bd3ad57 +Author: targrub +Date: Wed Oct 26 19:15:15 2022 +0000 + + Prepare for upcoming rustlang by fixing upcoming clippy warnings (#6376) + + # Objective + + - Proactive changing of code to comply with warnings generated by beta of rustlang version of cargo clippy. + + ## Solution + + - Code changed as recommended by `rustup update`, `rustup default beta`, `cargo run -p ci -- clippy`. + - Tested using `beta` and `stable`. No clippy warnings in either after changes made. + + --- + + ## Changelog + + - Warnings fixed were: `clippy::explicit-auto-deref` (present in 11 files), `clippy::needless-borrow` (present in 2 files), and `clippy::only-used-in-recursion` (only 1 file). + +commit a083882cb2b250a6b0375b02d980ff7c97cd3d24 +Author: François +Date: Wed Oct 26 18:57:23 2022 +0000 + + ignore nanosec precision tests on apple m1 (#6377) + + # Objective + + - Some tests are very flaky on a m1 + - m1 currently have a 41 ns precision + + ## Solution + + - Do not run tests that compare a `Duration` or a `f64` on a m1 (and m2) + +commit 7671ddea72f7ecdcaa8b808e3f2fdf74452a8f07 +Author: François +Date: Wed Oct 26 17:52:16 2022 +0000 + + can get the settings of a plugin from the app (#6372) + + # Objective + + - Make the settings of plugins readable during app building + + ## Solution + + - Added a vector of added plugins to the app. Their settings can be accessed as read only + +commit 54cf45c5b3c8879966c90e1a8bf718d27f571c67 +Author: Boxy +Date: Wed Oct 26 13:16:25 2022 +0000 + + Avoid making `Fetch`s `Clone` (#5593) + + # Objective + + - Do not implement `Copy` or `Clone` for `Fetch` types as this is kind of sus soundness wise (it feels like cloning an `IterMut` in safe code to me). Cloning a fetch seems important to think about soundness wise when doing it so I prefer this over adding a `Clone` bound to the assoc type definition (i.e. `type Fetch: Clone`) even though that would also solve the other listed things here. + - Remove a bunch of `QueryFetch<'w, Q>: Clone` bounds from our API as now all fetches can be "cloned" for use in `iter_combinations`. This should also help avoid the type inference regression ptrification introduced where `for<'a> QueryFetch<'a, Q>: Trait` bounds misbehave since we no longer need any of those kind of higher ranked bounds (although in practice we had none anyway). + - Stop being able to "forget" to implement clone for fetches, we've had a lot of issues where either `derive(Clone)` was used instead of a manual impl (so we ended up with too tight bounds on the impl) or flat out forgot to implement Clone at all. With this change all fetches are able to be cloned for `iter_combinations` so this will no longer be possible to mess up. + + On an unrelated note, while making this PR I realised we probably want safety invariants on `archetype/table_fetch` that nothing aliases the table_row/archetype_index according to the access we set. + + --- + + ## Changelog + + `Clone` and `Copy` were removed from all `Fetch` types. + + ## Migration Guide + + - Call `WorldQuery::clone_fetch` instead of `fetch.clone()`. Make sure to add safety comments :) + +commit 5622d56be1262fce8a2d458f2b78abf1cab3ab50 +Author: François +Date: Tue Oct 25 22:19:34 2022 +0000 + + Use plugin setup for resource only used at setup time (#6360) + + # Objective + + - Build on #6336 for more plugin configurations + + ## Solution + + - `LogSettings`, `ImageSettings` and `DefaultTaskPoolOptions` are now plugins settings rather than resources + + --- + + ## Changelog + + - `LogSettings` plugin settings have been move to `LogPlugin`, `ImageSettings` to `ImagePlugin` and `DefaultTaskPoolOptions` to `CorePlugin` + + ## Migration Guide + + The `LogSettings` settings have been moved from a resource to `LogPlugin` configuration: + + ```rust + // Old (Bevy 0.8) + app + .insert_resource(LogSettings { + level: Level::DEBUG, + filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(), + }) + .add_plugins(DefaultPlugins) + + // New (Bevy 0.9) + app.add_plugins(DefaultPlugins.set(LogPlugin { + level: Level::DEBUG, + filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(), + })) + ``` + + + The `ImageSettings` settings have been moved from a resource to `ImagePlugin` configuration: + + ```rust + // Old (Bevy 0.8) + app + .insert_resource(ImageSettings::default_nearest()) + .add_plugins(DefaultPlugins) + + // New (Bevy 0.9) + app.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) + ``` + + + The `DefaultTaskPoolOptions` settings have been moved from a resource to `CorePlugin::task_pool_options`: + + ```rust + // Old (Bevy 0.8) + app + .insert_resource(DefaultTaskPoolOptions::with_num_threads(4)) + .add_plugins(DefaultPlugins) + + // New (Bevy 0.9) + app.add_plugins(DefaultPlugins.set(CorePlugin { + task_pool_options: TaskPoolOptions::with_num_threads(4), + })) + ``` + +commit a6f6a8f6e2023a53e39fd7c125077756eba40477 +Author: dataphract +Date: Tue Oct 25 10:21:31 2022 +0000 + + fix: specify required trybuild patch version (#6333) + + # Objective + + This is a follow-up to #6317, which makes use of a feature of the newest `trybuild` version, `1.0.71`, but does not specify the new patch version in `bevy_ecs_compile_fail_tests/Cargo.toml`. + + The PR passed CI because CI downloaded the latest `trybuild` version satisfying the dependency specification. However, Cargo will not know an update is required if a user already has a `^1.0` version of `trybuild` cached locally, which causes the new `$N` syntax to fail the tests. + + ## Solution + + Updated the `trybuild` requirement to `1.0.71`. + +commit c245b1774328ef5a8ade9b423fcd937f720a1fe1 +Author: Larry Du +Date: Tue Oct 25 09:55:31 2022 +0000 + + Revert thiserror version requirement to match version for all crates. (#6365) + + # Objective + + - Reverts unnecessary version increase for `thiserror` caused by the following PR. https://github.com/bevyengine/bevy/commit/9066d514208671d8c62031465dea5eb977c51e25 + - The aforementioned PR should have increased `thiserrror` version uniformly across all bevy crates. As far as I can tell it was unneccessary to bump versions + + ## Solution + + - Revert versions to the matching version used by other bevy "crates" + + ``` + MBP-Larry-Du.local:~/Code/bevy:$ git grep thiserror + CHANGELOG.md:- [Derive thiserror::Error for HexColorError][2740] + crates/bevy_asset/Cargo.toml:thiserror = "1.0" + crates/bevy_asset/src/asset_server.rs:use thiserror::Error; + crates/bevy_asset/src/io/mod.rs:use thiserror::Error; + crates/bevy_gltf/Cargo.toml:thiserror = "1.0" + crates/bevy_gltf/src/loader.rs:use thiserror::Error; + crates/bevy_input/Cargo.toml:thiserror = "1.0" + crates/bevy_input/src/gamepad.rs:use thiserror::Error; + crates/bevy_reflect/Cargo.toml:thiserror = "1.0" + crates/bevy_reflect/src/path.rs:use thiserror::Error; + crates/bevy_render/Cargo.toml:thiserror = "1.0" + ``` + --- + + ## Changelog + + > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. + + - What changed as a result of this PR? Fixed dependency conflict for building projects. + Current build of StarRust runs successfully with the `thiserror` reversion: https://github.com/LarsDu/StarRust + But will run into dependency conflicts if `thiserror` is version 1.037 + + + Co-authored-by: Larry Du + +commit c6f27eb0547ce909fa01ff063ec9a3e531c14564 +Author: Carter Weinberg +Date: Tue Oct 25 00:19:23 2022 +0000 + + Add More Description to the Iter Combinations Documentation (#6260) + + # Objective + + I was trying to implement a collision system for my game, and believed that the iter_combinations method might be what I need. But I couldn't find a simple explanation of what a combination was in Bevy and thought it could use some more explanation. + + ## Solution + + I added some description to the documentation that can hopefully further elaborate on what a combination is. + + I also changed up the docs for the method because a combination is a different thing than a permutation but the Bevy docs seemed to use them interchangeably. + +commit 45e5eb1db3c54e725bdef31bbc172b3febfddb98 +Author: Theo Ottah +Date: Mon Oct 24 23:03:15 2022 +0000 + + Remove ExactSizeIterator from QueryCombinationIter (#5895) + + # Objective + + - `QueryCombinationIter` can have sizes greater than `usize::MAX`. + - Fixes #5846 + + ## Solution + + - Only the implementation of `ExactSizeIterator` has been removed. Instead of using `query_combination.len()`, you can use `query_combination.size_hint().0` to get the same value as before. + + --- + + ## Migration Guide + + - Switch to using other methods of getting the length. + +commit ecb6f8fab37d3eba05a56c7307b2e953c7df2fbc +Author: François +Date: Mon Oct 24 21:48:07 2022 +0000 + + Update deny configuration (#6359) + + # Objective + + - update deny config + + ## Solution + + - update nix duplicate version to ignore + - update security advisories + +commit 1bb751cb8d5a49395466f45b189e6fbec82bce7a +Author: Carter Anderson +Date: Mon Oct 24 21:20:33 2022 +0000 + + Plugins own their settings. Rework PluginGroup trait. (#6336) + + # Objective + + Fixes #5884 #2879 + Alternative to #2988 #5885 #2886 + + "Immutable" Plugin settings are currently represented as normal ECS resources, which are read as part of plugin init. This presents a number of problems: + + 1. If a user inserts the plugin settings resource after the plugin is initialized, it will be silently ignored (and use the defaults instead) + 2. Users can modify the plugin settings resource after the plugin has been initialized. This creates a false sense of control over settings that can no longer be changed. + + (1) and (2) are especially problematic and confusing for the `WindowDescriptor` resource, but this is a general problem. + + ## Solution + + Immutable Plugin settings now live on each Plugin struct (ex: `WindowPlugin`). PluginGroups have been reworked to support overriding plugin values. This also removes the need for the `add_plugins_with` api, as the `add_plugins` api can use the builder pattern directly. Settings that can be used at runtime continue to be represented as ECS resources. + + Plugins are now configured like this: + + ```rust + app.add_plugin(AssetPlugin { + watch_for_changes: true, + ..default() + }) + ``` + + PluginGroups are now configured like this: + + ```rust + app.add_plugins(DefaultPlugins + .set(AssetPlugin { + watch_for_changes: true, + ..default() + }) + ) + ``` + + This is an alternative to #2988, which is similar. But I personally prefer this solution for a couple of reasons: + * ~~#2988 doesn't solve (1)~~ #2988 does solve (1) and will panic in that case. I was wrong! + * This PR directly ties plugin settings to Plugin types in a 1:1 relationship, rather than a loose "setup resource" <-> plugin coupling (where the setup resource is consumed by the first plugin that uses it). + * I'm not a huge fan of overloading the ECS resource concept and implementation for something that has very different use cases and constraints. + + ## Changelog + + - PluginGroups can now be configured directly using the builder pattern. Individual plugin values can be overridden by using `plugin_group.set(SomePlugin {})`, which enables overriding default plugin values. + - `WindowDescriptor` plugin settings have been moved to `WindowPlugin` and `AssetServerSettings` have been moved to `AssetPlugin` + - `app.add_plugins_with` has been replaced by using `add_plugins` with the builder pattern. + + ## Migration Guide + + The `WindowDescriptor` settings have been moved from a resource to `WindowPlugin::window`: + + ```rust + // Old (Bevy 0.8) + app + .insert_resource(WindowDescriptor { + width: 400.0, + ..default() + }) + .add_plugins(DefaultPlugins) + + // New (Bevy 0.9) + app.add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + width: 400.0, + ..default() + }, + ..default() + })) + ``` + + + The `AssetServerSettings` resource has been removed in favor of direct `AssetPlugin` configuration: + + ```rust + // Old (Bevy 0.8) + app + .insert_resource(AssetServerSettings { + watch_for_changes: true, + ..default() + }) + .add_plugins(DefaultPlugins) + + // New (Bevy 0.9) + app.add_plugins(DefaultPlugins.set(AssetPlugin { + watch_for_changes: true, + ..default() + })) + ``` + + `add_plugins_with` has been replaced by `add_plugins` in combination with the builder pattern: + + ```rust + // Old (Bevy 0.8) + app.add_plugins_with(DefaultPlugins, |group| group.disable::()); + + // New (Bevy 0.9) + app.add_plugins(DefaultPlugins.build().disable::()); + ``` + +commit beab0bdc63d5956322875bb5f5529c99d42da126 +Author: Gino Valente +Date: Mon Oct 24 21:01:11 2022 +0000 + + bevy_scene: Replace root list with struct (#6354) + + # Objective + + Scenes are currently represented as a list of entities. This is all we need currently, but we may want to add more data to this format in the future (metadata, asset lists, etc.). + + It would be nice to update the format in preparation of possible future changes. Doing so now (i.e., before 0.9) could mean reduced[^1] breakage for things added in 0.10. + + [^1]: Obviously, adding features runs the risk of breaking things regardless. But if all features added are for whatever reason optional or well-contained, then users should at least have an easier time updating. + + ## Solution + + Made the scene root a struct rather than a list. + + ```rust + ( + entities: [ + // Entity data here... + ] + ) + ``` + + --- + + ## Changelog + + * The scene format now puts the entity list in a newly added `entities` field, rather than having it be the root object + + ## Migration Guide + + The scene file format now uses a struct as the root object rather than a list of entities. The list of entities is now found in the `entities` field of this struct. + + ```rust + // OLD + [ + ( + entity: 0, + components: [ + // Components... + ] + ), + ] + + // NEW + ( + entities: [ + ( + entity: 0, + components: [ + // Components... + ] + ), + ] + ) + ``` + + + Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com> + +commit f6b03aa27c3906ccb7963f0967d41cdb31ddc6b1 +Author: Andre Popovitch +Date: Mon Oct 24 21:01:09 2022 +0000 + + Rename `play` to `start` and add new `play` method that won't overwrite the existing animation if it's already playing (#6350) + + # Objective + + - You usually want to say that a given animation *should* be playing, doing nothing if it's already playing. + + ## Solution + + - Rename play to start and add new play method that won't overwrite the existing animation if it's already playing #6350 + + --- + + ## Changelog + + ### Changed + + `AnimationPlayer::play` will now not restart the animation if it's already playing + + ### Added + + An `AnimationPlayer ::start` method, which has the old behavior of `play` + + ## Migration guide + + - If you were using `play` to restart an animation that was already playing, that functionality has been moved to `start`. Now, `play` won't have any effect if the requested animation is already playing. + +commit b291223e341c3a57c97d6f80b13e61e31d430a12 +Author: ira +Date: Mon Oct 24 21:01:08 2022 +0000 + + Implement IntoIterator for ECS wrapper types. (#5096) + + # Objective + + Improve ergonomics by passing on the `IntoIterator` impl of the underlying type to wrapper types. + + ## Solution + + Implement `IntoIterator` for ECS wrapper types (Mut, Local, Res, etc.). + + Co-authored-by: devil-ira + +commit 6aa2dce0d1fb4257a5df49459484d39037a6da8f +Author: Lucidus115 +Date: Mon Oct 24 20:42:13 2022 +0000 + + Re-add local bool `has_received_time` in `time_system` (#6357) + + # Objective + + - Fixes #6355 + + ## Solution + + - Add the removed local bool from #6159 + +commit 3c13c75036108eec91beba58621e32e50c1be11d +Author: TheRawMeatball +Date: Mon Oct 24 19:24:49 2022 +0000 + + Optimize rendering slow-down at high entity counts (#5509) + + # Objective + + - Improve #3953 + + ## Solution + + - The very specific circumstances under which the render world is reset meant that the flush_as_invalid function could be replaced with one that had a noop as its init method. + - This removes a double-writing issue leading to greatly increased performance. + + Running the reproduction code in the linked issue, this change nearly doubles the framerate. + + Co-authored-by: Carter Anderson + +commit 3689d5d086f0742ca3688c7f8acbc40cfb150c16 +Author: Matthias Deiml +Date: Mon Oct 24 15:38:51 2022 +0000 + + Avoid creating `SurfaceConfiguration` in `prepare_windows` (#6255) + + # Objective + + - Avoids creating a `SurfaceConfiguration` for every window in every frame for the `prepare_windows` system + - As such also avoid calling `get_supported_formats` for every window in every frame + + ## Solution + + - Construct `SurfaceConfiguration` lazyly in `prepare_windows` + + --- + + This also changes the error message for failed initial surface configuration from "Failed to acquire next swapchain texture" to "Error configuring surface". + +commit 0cbd1bbe43cccd60ce1f13bd779694a35f58f8a1 +Author: François +Date: Mon Oct 24 14:53:19 2022 +0000 + + expose window alpha mode (#6331) + + # Objective + + - Being able to set the `CompositeAlphaMode` + + ## Solution + + - Expose it on `WindowDescriptor`, in the same way as `PresentMode` is exposed + +commit c9888a969c28928e244ac8c0ec0c587a922d9f49 +Author: Rob Parrett +Date: Mon Oct 24 14:53:18 2022 +0000 + + Fix outdated and badly formatted docs for `WindowDescriptor::transparent` (#6329) + + # Objective + + See title + + ## Before / After + + Screen Shot 2022-10-21 at 10 51 12 AM + Screen Shot 2022-10-21 at 10 51 24 AM + + ## Open questions + + ~~The old docs previously linked to a winit but that was preventing transparency for working on Windows 11. The recent winit upgrade should have fixed this.~~ + + ~~I'm unable to test on Windows 11 though, so someone should verify that we no longer need to call this out as being broken.~~ + + edit: Seems like we're good on Windows 11, thanks. + +commit b2f223b98f34d2fe437b9eea2e7e834200f731b7 +Author: Lena Milizé +Date: Mon Oct 24 14:53:16 2022 +0000 + + document insert_non_send_resource panics (#6328) + + Signed-off-by: Lena Milizé + + # Objective + + Fixes #6277. + + ## Solution + + Adds `# Panics` section to [`fn insert_non_send_resource`](http://dev-docs.bevyengine.org/bevy/ecs/world/struct.World.html#method.insert_non_send_resource) documentation, which explains that it panics when called from thread other than main thread. + +commit e8368a076164f6cd05582c44597d19590453ebf9 +Author: dataphract +Date: Mon Oct 24 14:53:14 2022 +0000 + + doc: document `PerspectiveProjection` (#6310) + + # Objective + + Fixes #6279. + + ## Solution + + Added documentation explaining the meanings and default values of `PerspectiveProjection`'s fields. + + + Co-authored-by: dataphract <86984145+dataphract@users.noreply.github.com> + +commit 19fc1f1ed2ddd8b9cbd0c79f1fa6b82c075dafb8 +Author: Gino Valente +Date: Mon Oct 24 14:53:12 2022 +0000 + + bevy_reflect: Fix `DynamicScene` not respecting component registrations during serialization (#6288) + + # Objective + + When running the scene example, you might notice we end up printing out the following: + ```ron + // ... + { + "scene::ComponentB": ( + value: "hello", + _time_since_startup: ( + secs: 0, + nanos: 0, + ), + ), + }, + // ... + ``` + + We should not be printing out `_time_since_startup` as the field is marked with `#[reflect(skip_serializing)]`: + + ```rust + #[derive(Component, Reflect)] + #[reflect(Component)] + struct ComponentB { + pub value: String, + #[reflect(skip_serializing)] + pub _time_since_startup: Duration, + } + ``` + + This is because when we create the `DynamicScene`, we end up calling `Reflect::clone_value`: + + https://github.com/bevyengine/bevy/blob/82126697ee4f635cf6b22e0b9f25e5aca95fda4a/crates/bevy_scene/src/dynamic_scene_builder.rs#L114-L114 + + This results in non-Value types being cloned into Dynamic types, which means the `TypeId` returned from `reflected_value.type_id()` is not the same as the original component's. + + And this meant we were not able to locate the correct `TypeRegistration`. + + ## Solution + + Use `TypeInfo::type_id()` instead of calling `Any::type_id()` on the value directly. + + --- + + ## Changelog + + * Fix a bug introduced in `0.9.0-dev` where scenes disregarded component's type registrations + +commit a3ca184128c1574cccd7866863a03f2a80368751 +Author: François +Date: Mon Oct 24 14:33:51 2022 +0000 + + Fix clipping in UI (#6351) + + # Objective + + - Clipping (visible in the UI example with text scrolling) is funky + - Fixes #6287 + + ## Solution + + - Fix UV calculation: + - correct order for values (issue introduced in #6000) + + - add the `y` values instead of subtracting them now that vertical order is reversed + - take scale factor into account (bug already present before reversing the order) + - While around clipping, I changed clip to only mutate when changed + + No more funkiness! 😞 + + Screenshot 2022-10-23 at 22 44 18 + +commit bcc33f6757523a9a7aca4a73388b0bb633b0d77a +Author: dataphract +Date: Mon Oct 24 14:33:50 2022 +0000 + + feat: add GamepadInfo, expose gamepad names (#6342) + + # Objective + + Fixes #6339. + + ## Solution + + This PR adds a new type, `GamepadInfo`, which holds metadata associated with a particular `Gamepad`. The `Gamepads` resource now holds a `HashMap`. The `GamepadInfo` is created when the gamepad backend (by default `bevy_gilrs`) emits a "gamepad connected" event. + + The `gamepad_viewer` example has been updated to showcase the new functionality. + + Before: + + ![bevy-gamepad-old](https://user-images.githubusercontent.com/86984145/197359427-2130a3c0-bd8a-4683-ae24-2a9eaa98b586.png) + + After: + + ![bevy-gamepad-new](https://user-images.githubusercontent.com/86984145/197359429-f7963163-df26-4906-af7f-6186fe3bd338.png) + + + --- + + ## Changelog + + ### Added + + - Added `GamepadInfo`. + - Added `Gamepads::name()`, which returns the name of the specified gamepad if it exists. + + ### Changed + + - `GamepadEventType::Connected` is now a tuple variant with a single field of type `GamepadInfo`. + - Since `GamepadInfo` is not `Copy`, `GamepadEventType` is no longer `Copy`. The same is true of `GamepadEvent` and `GamepadEventRaw`. + + ## Migration Guide + + - Pattern matches on `GamepadEventType::Connected` will need to be updated, as the form of the variant has changed. + - Code that requires `GamepadEvent`, `GamepadEventRaw` or `GamepadEventType` to be `Copy` will need to be updated. + +commit c9ec5c771a2a5af318b672a5cddf8831b6c8b7c9 +Author: ira +Date: Mon Oct 24 14:33:49 2022 +0000 + + Add `set_parent` and `remove_parent` to `EntityCommands` (#6189) + + I found myself doing + ```rust + let child = commands.spawn(..).id(); + commands.entity(parent).add_child(child); + ``` + When that could just be + ```rust + commands.spawn(..).set_parent(parent); + ``` + + Adding `set_parent` was trivial as it's just an `AddChild` command. Most of the changes are for `remove_parent`. + Also updated some outdated docs. + + Co-authored-by: devil-ira + +commit f7d3fbc7d52078354430704e585885688118dcf7 +Author: Lucidus115 +Date: Mon Oct 24 14:33:47 2022 +0000 + + Add `TimeUpdateStrategy` resource for manual `Time` updating (#6159) + + # Objective + + - Addresses #6146 by allowing manual `Time` updating + + ## Solution + - Create `TimeUpdateStrategy` config resource + - Allow users to specify a manual `Instant/Duration` or leave as default (automatic) + - Get resource in `bevy_time::time_system`and update time with desired value + --- + + ## Changelog + + - Add `TimeUpdateStrategy` resource + - Update `bevy_time::time_system` to use optional manual values + + Co-authored-by: BuildTools + Co-authored-by: Lucidus115 <92978847+Lucidus115@users.noreply.github.com> + +commit 9066d514208671d8c62031465dea5eb977c51e25 +Author: Dawid Piotrowski +Date: Mon Oct 24 14:33:46 2022 +0000 + + Utility methods for Val (#6134) + + # Objective + + Adds a better interface for performing mathematical operations with UI unit `Val`. Fixes #6080. + + ## Solution + + - Added `try_add` and `try_sub` methods to Val. + - Removed the `Add` and `AddAssign` impls for `Val` that introduced unintuitive and bug-prone behaviour. + - As a consequence of the prior, ~~changed the `Add` and `Sub` impls for the `Size` struct to take a `(Val, Val)` instead of `Vec2`~~ deleted the `Add` and `Sub` impls for the `Size` struct + - Added a `From<(Val, Val)>` impl for the `Size` struct + - Added `evaluate(size: f32)` method that converts from `Val::Percent` to `Val::Px`. + - Added `try_add_with_size` and `try_sub_with_size` methods to `Val`, which evaluate `Val::Percent` values into `Val::Px` values before adding. + + --- + + ## Migration Guide + + Instead of using the + and - operators, perform calculations on `Val`s using the new `try_add` and `try_sub` methods. Multiplication and division remained unchanged. Also, when adding or subtracting from `Size`, ~~use a `Val` tuple instead of `Vec2`~~ perform the addition on `width` and `height` separately. + + + Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com> + +commit 7a41efa227de1285e9011c908e7f31f1abae9b38 +Author: Marc-Stefan Cassola +Date: Mon Oct 24 14:33:45 2022 +0000 + + implemented #[bundle(ignore)] (#6123) + + # Objective + + Fixes #5559 + + Replaces #5628 + + ## Solution + + Because the generated method from_components() creates an instance of Self my implementation requires any field type that is marked to be ignored to implement Default. + + --- + + ## Changelog + + Added the possibility to ignore fields in a bundle with `#[bundle(ignore)]`. Typically used when `PhantomData` needs to be added to a `Bundle`. + +commit 1d22634cfbef189ba7355f6114f418885b06da9b +Author: Cameron <51241057+maniwani@users.noreply.github.com> +Date: Mon Oct 24 14:14:25 2022 +0000 + + better wording for time scaling docs (#6340) + + Quick follow-up to #5752. I think this is a slightly better wording. + +commit c226fee70793515257c938cbebbd3ddf7d142f0f +Author: Yyee +Date: Mon Oct 24 14:14:24 2022 +0000 + + Add From for AssetPath<'a> (#6337) + + # Objective + Fixes #6291 + + ## Solution + Implement `From` for `AssetPath<'a>` + +commit 0f3f628c48814c9fce49f518e5809eb500fb7a4e +Author: Mike +Date: Mon Oct 24 13:46:40 2022 +0000 + + tick local executor (#6121) + + # Objective + + - #4466 broke local tasks running. + - Fixes https://github.com/bevyengine/bevy/issues/6120 + + ## Solution + + - Add system for ticking local executors on main thread into bevy_core where the tasks pools are initialized. + - Add ticking local executors into thread executors + + ## Changelog + + - tick all thread local executors in task pool. + + ## Notes + + - ~~Not 100% sure about this PR. Ticking the local executor for the main thread in scope feels a little kludgy as it requires users of bevy_tasks to be calling scope periodically for those tasks to make progress.~~ took this out in favor of a system that ticks the local executors. + +commit 64a8485a112156d296b4e8c89a5cd95dd8f45463 +Author: François +Date: Mon Oct 24 13:46:39 2022 +0000 + + Disabling default features support in bevy_ecs, bevy_reflect and bevy (#5993) + + # Objective + + - Fix disabling features in bevy_ecs (broken by #5630) + - Add tests in CI for bevy_ecs, bevy_reflect and bevy as those crates could be use standalone + +commit e4af823b451a52ec7a70bc16d151c4beea8c6725 +Author: ira +Date: Mon Oct 24 13:46:38 2022 +0000 + + Clarify the behaviour of `iter_many` in the docs (#5973) + + Add the following message: + ``` + Items are returned in the order of the list of entities. + Entities that don't match the query are skipped. + ``` + + Additionally, the docs in `iter.rs` and `state.rs` were updated to match those in `query.rs`. + + Co-authored-by: devil-ira + +commit c19aa5939d0c9b7e8c0557933475bf7df273b1e3 +Author: Christopher Durham +Date: Mon Oct 24 13:46:37 2022 +0000 + + Add Exponential Moving Average into diagnostics (#4992) + + # Objective + + - Add Time-Adjusted Rolling EMA-based smoothing to diagnostics. + - Closes #4983; see that issue for more more information. + + ## Terms + + - EMA - [Exponential Moving Average](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average) + - SMA - [Simple Moving Average](https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average) + + ## Solution + + - We use a fairly standard approximation of a true EMA where $EMA_{\text{frame}} = EMA_{\text{previous}} + \alpha \left( x_{\text{frame}} - EMA_{\text{previous}} \right)$ where $\alpha = \Delta t / \tau$ and $\tau$ is an arbitrary smoothness factor. (See #4983 for more discussion of the math.) + - The smoothness factor is here defaulted to $2 / 21$; this was chosen fairly arbitrarily as supposedly related to the existing 20-bucket SMA. + - The smoothness factor can be set on a per-diagnostic basis via `Diagnostic::with_smoothing_factor`. + + --- + + ## Changelog + + ### Added + + - `Diagnostic::smoothed` - provides an exponentially smoothed view of a recorded diagnostic, to e.g. reduce jitter in frametime readings. + + ### Changed + - `LogDiagnosticsPlugin` now records the smoothed value rather than the raw value. + - For diagnostics recorded less often than every 0.1 seconds, this change to defaults will have no visible effect. + - For discrete diagnostics where this smoothing is not desirable, set a smoothing factor of 0 to disable smoothing. + - The average of the recent history is still shown when available. + +commit 2b9653094762f0be2ef46b5cfbc7f68f2516114c +Author: James Liu +Date: Mon Oct 24 13:46:36 2022 +0000 + + Extract Resources into their own dedicated storage (#4809) + + # Objective + At least partially addresses #6282. + + Resources are currently stored as a dedicated Resource archetype (ID 1). This allows for easy code reusability, but unnecessarily adds 72 bytes (on 64-bit systems) to the struct that is only used for that one archetype. It also requires several fields to be `pub(crate)` which isn't ideal. + + This should also remove one sparse-set lookup from fetching, inserting, and removing resources from a `World`. + + ## Solution + + - Add `Resources` parallel to `Tables` and `SparseSets` and extract the functionality used by `Archetype` in it. + - Remove `unique_components` from `Archetype` + - Remove the `pub(crate)` on `Archetype::components`. + - Remove `ArchetypeId::RESOURCE` + - Remove `Archetypes::resource` and `Archetypes::resource_mut` + + --- + + ## Changelog + Added: `Resources` type to store resources. + Added: `Storages::resource` + Removed: `ArchetypeId::RESOURCE` + Removed: `Archetypes::resource` and `Archetypes::resources` + Removed: `Archetype::unique_components` and `Archetypes::unique_components_mut` + + ## Migration Guide + Resources have been moved to `Resources` under `Storages` in `World`. All code dependent on `Archetype::unique_components(_mut)` should access it via `world.storages().resources()` instead. + + All APIs accessing the raw data of individual resources (mutable *and* read-only) have been removed as these APIs allowed for unsound unsafe code. All usages of these APIs should be changed to use `World::{get, insert, remove}_resource`. + +commit b508b5c7c7f460452077e7372448532f05d40e60 +Author: James Liu +Date: Mon Oct 24 13:22:05 2022 +0000 + + Skip empty archetypes and tables when iterating over queries (#4724) + + # Objective + Speed up queries that are fragmented over many empty archetypes and tables. + + ## Solution + Add a early-out to check if the table or archetype is empty before iterating over it. This adds an extra branch for every archetype matched, but skips setting the archetype/table to the underlying state and any iteration over it. + + This may not be worth it for the default `Query::iter` and maybe even the `Query::for_each` implementations, but this definitely avoids scheduling unnecessary tasks in the `Query::par_for_each` case. + + Ideally, `matched_archetypes` should only contain archetypes where there's actually work to do, but this would add a `O(n)` flat cost to every call to `update_archetypes` that scales with the number of matched archetypes. + + TODO: Benchmark + +commit 7989cb2650cb84b67eba7c0343b48e8e3b318ba1 +Author: Cameron <51241057+maniwani@users.noreply.github.com> +Date: Sat Oct 22 18:52:29 2022 +0000 + + Add global time scaling (#5752) + + # Objective + + - Make `Time` API more consistent. + - Support time accel/decel/pause. + + ## Solution + + This is just the `Time` half of #3002. I was told that part isn't controversial. + + - Give the "delta time" and "total elapsed time" methods `f32`, `f64`, and `Duration` variants with consistent naming. + - Implement accelerating / decelerating the passage of time. + - Implement stopping time. + + --- + + ## Changelog + + - Changed `time_since_startup` to `elapsed` because `time.time_*` is just silly. + - Added `relative_speed` and `set_relative_speed` methods. + - Added `is_paused`, `pause`, `unpause` , and methods. (I'd prefer `resume`, but `unpause` matches `Timer` API.) + - Added `raw_*` variants of the "delta time" and "total elapsed time" methods. + - Added `first_update` method because there's a non-zero duration between startup and the first update. + + ## Migration Guide + + - `time.time_since_startup()` -> `time.elapsed()` + - `time.seconds_since_startup()` -> `time.elapsed_seconds_f64()` + - `time.seconds_since_startup_wrapped_f32()` -> `time.elapsed_seconds_wrapped()` + + If you aren't sure which to use, most systems should continue to use "scaled" time (e.g. `time.delta_seconds()`). The realtime "unscaled" time measurements (e.g. `time.raw_delta_seconds()`) are mostly for debugging and profiling. + +commit cb5e2d84beb7f36427eeec13729f6dd52e04fbc0 +Author: Torstein Grindvik +Date: Sat Oct 22 08:37:51 2022 +0000 + + Use wgsl saturate (#6318) + + # Objective + + Use saturate wgsl function now implemented in naga (version 0.10.0). There is now no need for one in utils.wgsl. + + naga's version allows usage for not only scalars but vectors as well. + + ## Solution + + Remove the utils.wgsl saturate function. + + ## Changelog + + Remove saturate function from utils.wgsl in favor of saturate in naga v0.10.0. + +commit 543465b721048355e34eb6078923645747c1d44b +Author: Rob Parrett +Date: Fri Oct 21 11:15:06 2022 +0000 + + Fix tests breaking when new WorldQuery impls are added (#6317) + + # Objective + + I recently wanted to look at the possibility of adding `Mutated` and `Unchanged` query filters and was confronted with some seemingly unrelated broken tests. + + These tests were written in such a way that changing the number of WorldQuery impls in the project would break them. + + Fortunately, a [very recent release of trybuild](https://github.com/dtolnay/trybuild/releases/tag/1.0.70) has made this unnecessary. + + ## Solution + + Replace hardcoded numbers in test output with `$N` placeholders. + +commit 48e9dc19640ae5f6c8cee31e6f36bb1ac71860af +Author: Mike +Date: Thu Oct 20 20:23:57 2022 +0000 + + fix failing doc test and clear up docs (#6314) + + # Objective + + Fixes https://github.com/bevyengine/bevy/issues/6306 + + ## Solution + Change the failing assert and expand example to explain when ordering is deterministic or not. + + Co-authored-by: Mike Hsu + +commit abbc0cf3397246f9b6713c767ed2328afc6594ef +Author: Sludge <96552222+SludgePhD@users.noreply.github.com> +Date: Wed Oct 19 21:48:19 2022 +0000 + + Register `RenderLayers` type in `CameraPlugin` (#6308) + + # Objective + + The `RenderLayers` type is never registered, making it unavailable for reflection. + + ## Solution + + Register it in `CameraPlugin`, the same plugin that registers the related `Visibility*` types. + +commit 7db9b08b5f3aa55c039cd6490484f42cec3fadf8 +Author: Rob Parrett +Date: Wed Oct 19 18:54:37 2022 +0000 + + Update clap requirement from 3.2 to 4.0 (#6303) + + # Objective + + Alternative to #6150 + + Dependabot's PR doesn't seem to break anything, but there are some deprecations that we might as well fix up. + + ## Solution + + https://github.com/clap-rs/clap/blob/master/CHANGELOG.md#migrating + + Update clap in `build-wasm-example` and `span-cmp`. Other tools don't use clap. + + Remove references to `value_parser`. It's the default now. + + Change `#[clap()]` to `#[arg()]`. + + Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +commit c313e21d65e036ca6aea3d3467fed8dd2493ae83 +Author: VitalyR +Date: Wed Oct 19 17:40:23 2022 +0000 + + Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7 (#6218) + + # Objective + + - Update `wgpu` to 0.14.0, `naga` to `0.10.0`, `winit` to 0.27.4, `raw-window-handle` to 0.5.0, `ndk` to 0.7. + + ## Solution + + --- + + ## Changelog + + ### Changed + + - Changed `RawWindowHandleWrapper` to `RawHandleWrapper` which wraps both `RawWindowHandle` and `RawDisplayHandle`, which satisfies the `impl HasRawWindowHandle and HasRawDisplayHandle` that `wgpu` 0.14.0 requires. + + - Changed `bevy_window::WindowDescriptor`'s `cursor_locked` to `cursor_grab_mode`, change its type from `bool` to `bevy_window::CursorGrabMode`. + + ## Migration Guide + + - Adjust usage of `bevy_window::WindowDescriptor`'s `cursor_locked` to `cursor_grab_mode`, and adjust its type from `bool` to `bevy_window::CursorGrabMode`. + +commit b2ca3fb8b586a6b949979cf66527c878d305233a +Author: Rob Parrett +Date: Wed Oct 19 15:05:12 2022 +0000 + + Fix camera ambiguity warning in IOS example (#6300) + + # Objective + + Fix a camera ambiguity warning in the IOS example + + ## Solution + + I'm assuming that this was accidentally added when UI cameras stopped being a thing. So just delete the extra camera. + +commit c7fe4027a1cc4ced0171abf64623939ecb2ddf47 +Author: 张林伟 +Date: Wed Oct 19 11:36:26 2022 +0000 + + Rename example file scaling.rs to ui_scaling.rs (#6296) + + # Objective + + To be consistent like other examples, it's better to keep file name and example name same, so we don't need to find correct example name in Cargo.toml. + + ## Solution + + Rename example file scaling.rs to ui_scaling.rs. + +commit a658bfef19992c3b0e7bbbfde24bc88cbb098e27 +Author: Gino Valente +Date: Tue Oct 18 13:49:57 2022 +0000 + + bevy_reflect: Reflect doc comments (#6234) + + # Objective + + Resolves #6197 + + Make it so that doc comments can be retrieved via reflection. + + ## Solution + + Adds the new `documentation` feature to `bevy_reflect` (disabled by default). + + When enabled, documentation can be found using `TypeInfo::doc` for reflected types: + + ```rust + /// Some struct. + /// + /// # Example + /// + /// ```ignore + /// let some_struct = SomeStruct; + /// ``` + #[derive(Reflect)] + struct SomeStruct; + + let info = ::type_info(); + assert_eq!( + Some(" Some struct.\n\n # Example\n\n ```ignore\n let some_struct = SomeStruct;\n ```"), + info.docs() + ); + ``` + + ### Notes for Reviewers + + The bulk of the files simply added the same 16 lines of code (with slightly different documentation). Most of the real changes occur in the `bevy_reflect_derive` files as well as in the added tests. + + --- + + ## Changelog + + * Added `documentation` feature to `bevy_reflect` + * Added `TypeInfo::docs` method (and similar methods for all info types) + +commit 4407cdb423ddb82a1992f2b84015fd3fdab65abe +Author: Michel van der Hulst +Date: Tue Oct 18 13:28:35 2022 +0000 + + Fixes scroll example after inverting UI Y axis (#6290) + +commit 0981789ec7e6e515048c45f57d4494060bc031df +Author: Michel van der Hulst +Date: Tue Oct 18 13:28:34 2022 +0000 + + Fixes incorrect glyph positioning for text2d (#6273) + + # Objective + Fixes #6272 + + ## Solution + Revert to old way of positioning text for Text2D rendered text. + + + Co-authored-by: Michel van der Hulst + +commit c6e0da4bcb2b6f60450fff300f05fcf6ad18136a +Author: thebluefish +Date: Mon Oct 17 16:42:34 2022 +0000 + + Fix end-of-animation index OOB (#6210) + + # Objective + + Fixes #6204 + + ## Solution + + Added another branch to handle end-of-animation special case + +commit b09b2c10566fcfc1aa399504bf255746f309c4a1 +Author: François +Date: Mon Oct 17 16:25:12 2022 +0000 + + Create a scene from a dynamic scene (#6229) + + # Objective + + - Add a method to create a `Scene` from a `DynamicScene` + +commit 88700f35955cb400d411974e5bbdd84fd223149d +Author: James Sully +Date: Mon Oct 17 15:42:43 2022 +0000 + + Add mutating `toggle` method to `Visibility` component (#6268) + + # Objective + + Make toggling the visibility of an entity slightly more convenient. + + ## Solution + + Add a mutating `toggle` method to the `Visibility` component + + ```rust + fn my_system(mut query: Query<&mut Visibility, With>) { + let mut visibility = query.single_mut(); + // before: + visibility.is_visible = !visibility.is_visible; + // after: + visibility.toggle(); + } + ``` + + ## Changelog + + ### Added + - Added a mutating `toggle` method to the `Visibility` component + +commit b840ba3eafa52950c2a19c6cc13b1e3ff69e88cb +Author: Rob Parrett +Date: Mon Oct 17 15:26:39 2022 +0000 + + Tidy up surface creation in RenderPlugin (#6276) + + # Objective + + Tidy up a bit + +commit 708535536b9e97684c2dbdc9eba41752da9e863e +Author: JMS55 <47158642+JMS55@users.noreply.github.com> +Date: Mon Oct 17 14:38:58 2022 +0000 + + Document EntityCommands/EntityMut insert() (#6270) + + Fixes #6258. + +commit bfbcd47725e1557e35549e63badaa0e5464b77b3 +Author: Swords <33922797+SleepySwords@users.noreply.github.com> +Date: Mon Oct 17 14:38:57 2022 +0000 + + Add default implementation of Serialize and Deserialize to Timer and Stopwatch (#6248) + + # Objective + + Fixes #6244 + + ## Solution + + Uses derive to implement `Serialize` and `Deserialize` for `Timer` and `Stopwatch` + + ### Things to consider + - Should fields such as `finished` and `times_finished_this_tick` in `Timer` be serialized? + - Does `Countdown` and `PrintOnCompletionTimer` need to be serialized and deserialized? + + ## Changelog + + Added `Serialize` and `Deserialize` implementations to `Timer` and `Stopwatch`, `Countdown`. + +commit 132e8fb3821cde83e327cc3b18e0a7b748ea19c9 +Author: TehPers +Date: Mon Oct 17 14:38:56 2022 +0000 + + Support multiple `#[reflect]`/`#[reflect_value]` + improve error messages (#6237) + + # Objective + + Currently, surprising behavior happens when specifying `#[reflect(...)]` or `#[reflect_value(...)]` multiple times. Rather than merging the traits lists from all attributes, only the trait list from the last attribute is used. For example, in the following code, only the `Debug` and `Hash` traits are reflected and not `Default` or `PartialEq`: + + ```rs + #[derive(Debug, PartialEq, Hash, Default, Reflect)] + #[reflect(PartialEq, Default)] + #[reflect(Debug, Hash)] + struct Foo; + ``` + + This is especially important when some traits should only be reflected under certain circumstances. For example, this previously had surprisingly behavior when the "serialize" feature is enabled: + + ```rs + #[derive(Debug, Hash, Reflect)] + #[reflect(Debug, Hash)] + #[cfg_attr( + feature = "serialize", + derive(Serialize, Deserialize), + reflect(Serialize, Deserialize) + ] + struct Foo; + ``` + + In addition, compile error messages generated from using the derive macro often point to the `#[derive(Reflect)]` rather than to the source of the error. It would be a lot more helpful if the compiler errors pointed to what specifically caused the error rather than just to the derive macro itself. + + ## Solution + + Merge the trait lists in all `#[reflect(...)]` and `#[reflect_value(...)]` attributes. Additionally, make `#[reflect]` and `#[reflect_value]` mutually exclusive. + + Additionally, span information is carried throughout some parts of the code now to ensure that error messages point to more useful places and better indicate what caused those errors. For example, `#[reflect(Hash, Hash)]` points to the second `Hash` as the source of an error. Also, in the following example, the compiler error now points to the `Hash` in `#[reflect(Hash)]` rather than to the derive macro: + + ```rs + #[derive(Reflect)] + #[reflect(Hash)] // <-- compiler error points to `Hash` for lack of a `Hash` implementation + struct Foo; + ``` + + --- + + ## Changelog + + Changed + - Using multiple `#[reflect(...)]` or `#[reflect_value(...)]` attributes now merges the trait lists. For example, `#[reflect(Debug, Hash)] #[reflect(PartialEq, Default)]` is equivalent to `#[reflect(Debug, Hash, PartialEq, Default)]`. + - Multiple `#[reflect(...)]` and `#[reflect_value(...)]` attributes were previously accepted, but only the last attribute was respected. + - Using both `#[reflect(...)]` and `#[reflect_value(...)]` was previously accepted, but had surprising behavior. This is no longer accepted. + - Improved error messages for `#[derive(Reflect)]` by propagating useful span information. Many errors should now point to the source of those errors rather than to the derive macro. + +commit c11fbfb3e1f8a9aeb7dc0c214ac355ca69973bee +Author: targrub +Date: Mon Oct 17 14:38:55 2022 +0000 + + Add getters and setters for `InputAxis` and `ButtonSettings` (#6088) + + # Objective + Fixes https://github.com/bevyengine/bevy/issues/3418 + + ## Solution + + Originally a rebase of https://github.com/bevyengine/bevy/pull/3446. Work was originally done by mfdorst, who should receive considerable credit. Then the error types were extensively reworked by targrub. + + ## Migration Guide + + `AxisSettings` now has a `new()`, which may return an `AxisSettingsError`. + `AxisSettings` fields made private; now must be accessed through getters and setters. There's a dead zone, from `.deadzone_upperbound()` to `.deadzone_lowerbound()`, and a live zone, from `.deadzone_upperbound()` to `.livezone_upperbound()` and from `.deadzone_lowerbound()` to `.livezone_lowerbound()`. + `AxisSettings` setters no longer panic. + `ButtonSettings` fields made private; now must be accessed through getters and setters. + `ButtonSettings` now has a `new()`, which may return a `ButtonSettingsError`. + + Co-authored-by: targrub <62773321+targrub@users.noreply.github.com> + +commit 964b047466f5dda68d71688b4e9a79526aa858b9 +Author: targrub +Date: Mon Oct 17 14:19:24 2022 +0000 + + Make `raw_window_handle` field in `Window` and `ExtractedWindow` an `Option`. (#6114) + + # Objective + + - Trying to make it possible to do write tests that don't require a raw window handle. + - Fixes https://github.com/bevyengine/bevy/issues/6106. + + ## Solution + + - Make the interface and type changes. Avoid accessing `None`. + --- + + ## Changelog + + - Converted `raw_window_handle` field in both `Window` and `ExtractedWindow` to `Option`. + - Revised accessor function `Window::raw_window_handle()` to return `Option`. + - Skip conditions in loops that would require a raw window handle (to create a `Surface`, for example). + + ## Migration Guide + + `Window::raw_window_handle()` now returns `Option`. + + + Co-authored-by: targrub <62773321+targrub@users.noreply.github.com> + +commit bfd6285c3b47a1b2a19a14db46d3aed215c5bcf1 +Author: Marlon +Date: Mon Oct 17 14:01:53 2022 +0000 + + Add Eq & PartialEq to AssetPath (#6274) + + Adds `Eq` and `ArtialEq` to `AssetPath` to make `AssetPath` usable inside HashMaps. + +commit 5878a62c3ff7e54405bd0f42ad6d64af70e1a878 +Author: Lena Milizé +Date: Mon Oct 17 14:01:52 2022 +0000 + + Link to `linux_dependencies.md` in the panic message when failing to detect a GPU (#6261) + + As suggested in #6104, it would be nice to link directly to `linux_dependencies.md` file in the panic message when running on Linux. And when not compiling for Linux, we fall back to the old message. + + Signed-off-by: Lena Milizé + + # Objective + + Resolves #6104. + + ## Solution + + Add link to `linux_dependencies.md` when compiling for Linux, and fall back to the old one when not. + +commit f9c56b321d5ebe424c8cd6d58fc500147fcfc04b +Author: Zicklag +Date: Mon Oct 17 14:01:50 2022 +0000 + + Enable Constructing ReflectComponent/Resource (#6257) + + # Objective + + - Fixes #6206 + + ## Solution + + - Create a constructor for creating `ReflectComponent` and `ReflectResource` + + --- + + ## Changelog + + > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. + + ### Added + + - Created constructors for `ReflectComponent` and `ReflectResource`, allowing for advanced scripting use-cases. + +commit 89c4b77bddfc5e62983050316d2e8cd454310df8 +Author: JoJoJet <21144246+JoJoJet@users.noreply.github.com> +Date: Mon Oct 17 13:47:02 2022 +0000 + + Add a method for accessing the width of a `Table` (#6249) + + # Objective + + There is currently no good way of getting the width (# of components) of a table outside of `bevy_ecs`. + + # Solution + + Added the methods `Table::{component_count, component_capacity}` + For consistency and clarity, renamed `Table::{len, capacity}` to `entity_count` and `entity_capacity`. + + ## Changelog + + - Added the methods `Table::component_count` and `Table::component_capacity` + - Renamed `Table::len` and `Table::capacity` to `entity_count` and `entity_capacity` + + ## Migration Guide + + Any use of `Table::len` should now be `Table::entity_count`. Any use of `Table::capacity` should now be `Table::entity_capacity`. + +commit 73605f43b664cab6a330e0b3ca1856ffafaceee8 +Author: Lena Milizé +Date: Mon Oct 17 13:47:01 2022 +0000 + + Replace the `bool` argument of `Timer` with `TimerMode` (#6247) + + As mentioned in #2926, it's better to have an explicit type that clearly communicates the intent of the timer mode rather than an opaque boolean, which can be only understood when knowing the signature or having to look up the documentation. + + This also opens up a way to merge different timers, such as `Stopwatch`, and possibly future ones, such as `DiscreteStopwatch` and `DiscreteTimer` from #2683, into one struct. + + Signed-off-by: Lena Milizé + + # Objective + + Fixes #2926. + + ## Solution + + Introduce `TimerMode` which replaces the `bool` argument of `Timer` constructors. A `Default` value for `TimerMode` is `Once`. + + --- + + ## Changelog + + ### Added + + - `TimerMode` enum, along with variants `TimerMode::Once` and `TimerMode::Repeating` + + ### Changed + + - Replace `bool` argument of `Timer::new` and `Timer::from_seconds` with `TimerMode` + - Change `repeating: bool` field of `Timer` with `mode: TimerMode` + + ## Migration Guide + + - Replace `Timer::new(duration, false)` with `Timer::new(duration, TimerMode::Once)`. + - Replace `Timer::new(duration, true)` with `Timer::new(duration, TimerMode::Repeating)`. + - Replace `Timer::from_seconds(seconds, false)` with `Timer::from_seconds(seconds, TimerMode::Once)`. + - Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`. + - Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`. + +commit a0f14681086bad5fa184d380bbc8dbc9db9ab34e +Author: mike +Date: Mon Oct 17 13:47:00 2022 +0000 + + Add iter_entities to World #6228 (#6242) + + # Objective + + - Add a way to iterate over all entities from &World + + ## Solution + + - Added a function `iter_entities` on World which returns an iterator of `Entity` derived from the entities in the `World`'s `archetypes` + + --- + + ## Changelog + + - Added a function `iter_entities` on World, allowing iterating over all entities in contexts where you only have read-only access to the World. + +commit 05c7babba2f5e26503276875d0021bfafcfb3004 +Author: Sergi-Ferrez <61662926+Sergi-Ferrez@users.noreply.github.com> +Date: Mon Oct 17 13:27:24 2022 +0000 + + Clarify `bevy::ui::Node` field and documentation (#5995) + + # Objective + Fixes #5820 + + ## Solution + + Change field name and documentation from `bevy::ui::Node` struct + + --- + + ## Changelog + + `bevy::ui::Node` `size` field has renamed to `calculated_size` + + ## Migration Guide + + All references to the old `size` name has been changed, to access `bevy::ui::Node` `size` field use `calculated_size` + +commit 92ba6224b9b66eb779683603e7022e421511dfe5 +Author: ira +Date: Thu Oct 13 12:53:18 2022 +0000 + + Use `SpatialBundle`/`TransformBundle` in examples (#6002) + + Does what it do + + Co-authored-by: devil-ira + +commit 000e6e2874b0e520015e67e05107a7b172d88386 +Author: Martin Svanberg +Date: Wed Oct 12 20:18:20 2022 +0000 + + Fix documentation for looking_at/look_at (#4696) + + Bevy's coordinate system is right-handed Y up, so +Z points towards my nose and I'm looking in the -Z direction. Therefore, `Transform::looking_at/look_at` must be pointing towards -Z. Or am I wrong here? + +commit ccf7c65a78780eaeec18396581ff3267cd3acbcd +Author: François +Date: Wed Oct 12 01:48:16 2022 +0000 + + dynamic scene builder (#6227) + + # Objective + + - make it easier to build dynamic scenes + + ## Solution + + - add a builder to create a dynamic scene from a world. it can extract an entity or an iterator of entities + - alternative to #6013, leaving the "hierarchy iteration" part to #6185 which does it better + - alternative to #6004 + - using a builder makes it easier to chain several extractions + +commit c0a93aa7a4d612cb3cdc3ef63c089ed032bed513 +Author: Alice Cecile +Date: Tue Oct 11 15:21:12 2022 +0000 + + Rename system chaining to system piping (#6230) + + # Objective + + > System chaining is a confusing name: it implies the ability to construct non-linear graphs, and suggests a sense of system ordering that is only incidentally true. Instead, it actually works by passing data from one system to the next, much like the pipe operator. + + > In the accepted [stageless RFC](https://github.com/bevyengine/rfcs/blob/main/rfcs/45-stageless.md), this concept is renamed to piping, and "system chaining" is used to construct groups of systems with ordering dependencies between them. + + Fixes #6225. + + ## Changelog + + System chaining has been renamed to system piping to improve clarity (and free up the name for new ordering APIs). + + ## Migration Guide + + The `.chain(handler_system)` method on systems is now `.pipe(handler_system)`. + The `IntoChainSystem` trait is now `IntoPipeSystem`, and the `ChainSystem` struct is now `PipeSystem`. + +commit 6ce7ce208e717a0b0afe647599fe47565efcb428 +Author: Michel van der Hulst +Date: Tue Oct 11 12:51:44 2022 +0000 + + Change UI coordinate system to have origin at top left corner (#6000) + + # Objective + Fixes #5572 + + ## Solution + + Approach is to invert the Y-axis of the UI Camera by changing the UI projection matrix to render the UI upside down. + + After that I'm trying to fix all issues, that pop up: + - interaction expected the "old" position + - images and text were displayed upside-down + - baseline of text was based on the top of the glyph instead of bottom + + ... probably a lot more. + + --- + + Result when running examples: +
+ Button example + + main branch: + ![button main](https://user-images.githubusercontent.com/4232644/190856087-61dd1d98-42b5-4238-bd97-149744ddfeba.png) + this pr: + ![button pr](https://user-images.githubusercontent.com/4232644/190856097-3f4bc97a-ed15-4e97-b7f1-2b2dd6bb8b14.png) + +
+ +
+ Text example + + m + ![text main](https://user-images.githubusercontent.com/4232644/192142831-4cf19aa1-f49a-485e-af7b-374d6f5c396c.png) + ain branch: + + + this pr: + ![text pr fixed](https://user-images.githubusercontent.com/4232644/192142829-c433db3b-32e1-4ee8-b493-0b4a4d9c8e70.png) + + +
+ +
+ Text debug example + + main branch: + ![text_debug main](https://user-images.githubusercontent.com/4232644/192142822-940aefa6-e502-410b-8da4-5570f77b5df2.png) + + this pr: + ![text_debug pr fixed](https://user-images.githubusercontent.com/4232644/194547010-8c968f5c-5a71-4ffc-871d-790c06d48016.png) + +
+ +
+ Transparency UI example + + main branch: + ![transparency_ui main](https://user-images.githubusercontent.com/4232644/190856172-328c60fe-3622-4598-97d5-2f1595db13b3.png) + + + this pr: + ![transperency_ui pr](https://user-images.githubusercontent.com/4232644/190856179-a2dafb99-41ea-45a9-9dd6-400fa3ef24b9.png) + +
+ +
+ UI example + + **ui example** + main branch: + ![ui main](https://user-images.githubusercontent.com/4232644/192142812-e20ba31a-6841-46d9-a785-4198cf22dc99.png) + + this pr: + ![ui pr fixed](https://user-images.githubusercontent.com/4232644/192142788-cc0b74e0-7710-4faa-b5a2-60270a5da77c.png) + +
+ + ## Changelog + UI coordinate system and cursor position was changed from bottom left origin, y+ up to top left origin, y+ down. + + ## Migration Guide + All flex layout should be inverted (ColumnReverse => Column, FlexStart => FlexEnd, WrapReverse => Wrap) + System where dealing with cursor position should be changed to account for cursor position being based on the top left instead of bottom left + +commit 13dcdba05f6b080a947a0be5598b200662cc4e8e +Author: François +Date: Tue Oct 11 12:32:03 2022 +0000 + + use bevy default texture format if the surface is not yet available (#6233) + + # Objective + + - Fix #6231 + + ## Solution + + - In case no supported format is found, try to use Bevy default instead of panicking + +commit 7673db731e7de0039dd97aa9c1b4ddf675ef9d60 +Author: Emerson MX +Date: Mon Oct 10 23:59:27 2022 +0000 + + Make TouchInput and ForceTouch serializable (#6191) + + Closes #6021 + +commit 1ca1c8c39e8254cf5408198fa9d112400af55240 +Author: ira +Date: Mon Oct 10 23:40:32 2022 +0000 + + Fix `RemoveChildren` command (#6192) + + # Objective + + `RemoveChildren` could remove the `Parent` component from children belonging to a different parent, which breaks the hierarchy. + + This change looks a little funny because I'm reusing the events to avoid needing to clone the parent's `Children`. + + Co-authored-by: devil-ira + +commit b4accebe1032fee62537903b71a9e2334cfc4b0e +Author: François +Date: Mon Oct 10 23:09:08 2022 +0000 + + scenes: simplify return type of iter_instance_entities (#5994) + + # Objective + + - Taking the API improvement out of #5431 + - `iter_instance_entities` used to return an option of iterator, now it just returns an iterator + + --- + + ## Changelog + + - If you use `SceneSpawner::iter_instance_entities`, it no longer returns an `Option`. The iterator will be empty if the return value used to be `None` + +commit 9a597b758e5b2b2cc4355185a3fcba9564bfb104 +Author: targrub +Date: Mon Oct 10 20:59:38 2022 +0000 + + Adding Debug implementations for App, Stage, Schedule, Query, QueryState, etc. (#6214) + + # Objective + + - Adding Debug implementations for App, Stage, Schedule, Query, QueryState. + - Fixes #1130. + + ## Solution + + - Implemented std::fmt::Debug for a number of structures. + + --- + + ## Changelog + + Also added Debug implementations for ParallelSystemExecutor, SingleThreadedExecutor, various RunCriteria structures, SystemContainer, and SystemDescriptor. + + Opinions are sure to differ as to what information to provide in a Debug implementation. Best guess was taken for this initial version for these structures. + + + Co-authored-by: targrub <62773321+targrub@users.noreply.github.com> + +commit 55d126cab9506dd24d9eeb87b3f31a56fb035c49 +Author: Torstein Grindvik +Date: Mon Oct 10 19:23:43 2022 +0000 + + Add globals struct to mesh2d (#6222) + + See commit message. + I noticed I couldn't use `globals.time` when using `Material2d`. + + I copied the solution from 807336203903e516a8705a13316c2c2c20c0f5bb , and now `Material2d` works for me. + + Perhaps some of these struct definitions could be shared in the future, but for now I've just copy pasted it (it looked like the `View` struct was done that way). + + Ping @IceSentry , I saw a comment on the linked commit that you intended to do this work at some point in the future. + +commit 740ae9a37f3a5d4d8f019021760f805d55d98a01 +Author: Charles +Date: Mon Oct 10 17:58:15 2022 +0000 + + remove mandatory mesh attributes (#6127) + + # Objective + + - It's possible to create a mesh without positions or normals, but currently bevy forces these attributes to be present on any mesh. + + ## Solution + + - Don't assume these attributes are present and add a shader defs for each attributes + - I updated 2d and 3d meshes to use the same logic. + + --- + + ## Changelog + + - Meshes don't require any attributes + + # Notes + I didn't update the pbr.wgsl shader because I'm not sure how to handle it. It doesn't really make sense to use it without positions or normals. + +commit aebd7607114a4932d7596a3be5f82b3f2b52f156 +Author: Light Ning +Date: Mon Oct 10 17:43:10 2022 +0000 + + bevy_input: Fix process touch event (#4352) + + # Objective + + - `process_touch_event` in `bevy_input` don't update position info. `TouchPhase::Ended` and `TouchPhase::Cancelled` should use the position info from `pressed`. Otherwise, it'll not update. The position info is updated from `TouchPhase::Moved`. + + ## Solution + + - Use updated touch info. + + --- + + ## Changelog + + > This section is optional. If this was a trivial fix, or has no externally-visible impact, feel free to skip this section. + + - Fixed: bevy_input, fix process touch event, update touch info + +commit 2cff2278cac1cd8da2b68ee6dbf5b68e4a02300d +Author: JoJoJet +Date: Mon Oct 10 17:06:31 2022 +0000 + + Add a method for mapping `Mut` -> `Mut` (#6199) + + # Objective + + When designing an API, you may wish to provide access only to a specific field of a component or resource. The current options for doing this in safe code are + + * `*Mut::into_inner`, which flags a change no matter what. + * `*Mut::bypass_change_detection`, which misses all changes. + + ## Solution + + Add the method `map_unchanged`. + + ### Example + + ```rust + // When run, zeroes the translation of every entity. + fn reset_all(mut transforms: Query<&mut Transform>) { + for transform in &mut transforms { + // We pinky promise not to modify `t` within the closure. + let translation = transform.map_unchanged(|t| &mut t.translation); + // Only reset the translation if it isn't already zero. + translation.set_if_not_equal(Vec2::ZERO); + } + } + ``` + + --- + + ## Changelog + + + Added the method `map_unchanged` to types `Mut`, `ResMut`, and `NonSendMut`. + +commit eb0a9e15866c167d209ae8465f30509a0d5451b6 +Author: ira +Date: Mon Oct 10 16:50:18 2022 +0000 + + Remove `Transform::apply_non_uniform_scale` (#6133) + + This is a holdover from back when `Transform` was backed by a private `Mat4` two years ago. + Not particularly useful anymore :) + + ## Migration Guide + `Transform::apply_non_uniform_scale` has been removed. + It can be replaced with the following snippet: + ```rust + transform.scale *= scale_factor; + ``` + + + Co-authored-by: devil-ira + +commit 9423cb6a8d0c140e11364eb23c8feb7e576baa8c +Author: ira +Date: Mon Oct 10 16:50:17 2022 +0000 + + Rename `Transform::mul_vec3` to `transform_point` and improve docs (#6132) + + The docs ended up quite verbose :v + + Also added a missing `#[inline]` to `GlobalTransform::mul_transform`. + + I'd say this resolves #5500 + + # Migration Guide + `Transform::mul_vec3` has been renamed to `transform_point`. + + Co-authored-by: devil-ira + +commit 2cde4c73ed61e2cf2d9fc7f058f9f8abf44b059f +Author: cathalogue <77889270+leath-dub@users.noreply.github.com> +Date: Mon Oct 10 16:34:24 2022 +0000 + + Update linux_dependencies.md (#6205) + + for nix build, pkgconfig has been renamed to pkg-config. Very small fix :> + + # Objective + + - Describe the objective or issue this PR addresses. + - If you're fixing a specific issue, say "Fixes #X". + + ## Solution + + - Describe the solution used to achieve the objective above. + + --- + + ## Changelog + + > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. + + - What changed as a result of this PR? + - If applicable, organize changes under "Added", "Changed", or "Fixed" sub-headings + - Stick to one or two sentences. If more detail is needed for a particular change, consider adding it to the "Solution" section + - If you can't summarize the work, your change may be unreasonably large / unrelated. Consider splitting your PR to make it easier to review and merge! + + ## Migration Guide + + > This section is optional. If there are no breaking changes, you can delete this section. + + - If this PR is a breaking change (relative to the last release of Bevy), describe how a user might need to migrate their code to support these changes + - Simply adding new functionality is not a breaking change. + - Fixing behavior that was definitely a bug, rather than a questionable design choice is not a breaking change. + +commit a18e2b1a7f823da05d525137ae758200b852149b +Author: Zicklag +Date: Mon Oct 10 16:34:23 2022 +0000 + + Reflect Default for GlobalTransform (#6200) + + # Objective + + Make `GlobalTransform` constructible from scripts, in the same vein as #6187. + + ## Solution + + - Use the derive macro to reflect default + + --- + + ## Changelog + + > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. + + - `GlobalTransform` now reflects the `Default` trait. + +commit 6ae46f6403d115784d51a5d96b6b0619a9b3c93f +Author: Noah +Date: Mon Oct 10 16:34:22 2022 +0000 + + Fixes Camera not being serializable due to missing registrations in core functionality. (#6170) + + … + + # Objective + + - Fixes Camera not being serializable due to missing registrations in core functionality. + - Fixes #6169 + + ## Solution + + - Updated Bevy_Render CameraPlugin with registrations for Option and then Bevy_Core CorePlugin with registrations for ReflectSerialize and ReflectDeserialize for type data Range respectively according to the solution in #6169 + + + + Co-authored-by: Noah + +commit 3321d68a753905003a0253391b07436d705a66b4 +Author: JoJoJet +Date: Mon Oct 10 16:34:21 2022 +0000 + + Add methods for silencing system-order ambiguity warnings (#6158) + + # Background + + Incremental implementation of #4299. The code is heavily borrowed from that PR. + + # Objective + + The execution order ambiguity checker often emits false positives, since bevy is not aware of invariants upheld by the user. + + ## Solution + + Title + + --- + + ## Changelog + + + Added methods `SystemDescriptor::ignore_all_ambiguities` and `::ambiguous_with`. These allow you to silence warnings for specific system-order ambiguities. + + ## Migration Guide + + ***Note for maintainers**: This should replace the migration guide for #5916* + + Ambiguity sets have been replaced with a simpler API. + + ```rust + // These systems technically conflict, but we don't care which order they run in. + fn jump_on_click(mouse: Res>, mut transforms: Query<&mut Transform>) { ... } + fn jump_on_spacebar(keys: Res>, mut transforms: Query<&mut Transform>) { ... } + + // + // Before + + #[derive(AmbiguitySetLabel)] + struct JumpSystems; + + app + .add_system(jump_on_click.in_ambiguity_set(JumpSystems)) + .add_system(jump_on_spacebar.in_ambiguity_set(JumpSystems)); + + // + // After + + app + .add_system(jump_on_click.ambiguous_with(jump_on_spacebar)) + .add_system(jump_on_spacebar); + + ``` + +commit f5322cd7570b6398e0f9e69c1b75a63cb10f6d88 +Author: VitalyR +Date: Mon Oct 10 16:10:05 2022 +0000 + + get proper texture format after the renderer is initialized, fix #3897 (#5413) + + # Objective + There is no Srgb support on some GPU and display protocols with `winit` (for example, Nvidia's GPUs with Wayland). Thus `TextureFormat::bevy_default()` which returns `Rgba8UnormSrgb` or `Bgra8UnormSrgb` will cause panics on such platforms. This patch will resolve this problem. Fix https://github.com/bevyengine/bevy/issues/3897. + + ## Solution + + Make `initialize_renderer` expose `wgpu::Adapter` and `first_available_texture_format`, use the `first_available_texture_format` by default. + + ## Changelog + + * Fixed https://github.com/bevyengine/bevy/issues/3897. + +commit 173852790283ffead8dba92f8ce667b9ee29064b +Author: TimJentzsch +Date: Sun Oct 9 21:03:05 2022 +0000 + + Make the default background color of `NodeBundle` transparent (#6211) + + # Objective + + Closes #6202. + + The default background color for `NodeBundle` is currently white. + However, it's very rare that you actually want a white background color. + Instead, you often want a background color specific to the style of your game or a transparent background (e.g. for UI layout nodes). + + ## Solution + + `Default` is not derived for `NodeBundle` anymore, but explicitly specified. + The default background color is now transparent (`Color::NONE.into()`) as this is the most common use-case, is familiar from the web and makes specifying a layout for your UI less tedious. + + --- + + ## Changelog + + - Changed the default `NodeBundle.background_color` to be transparent (`Color::NONE.into()`). + + ## Migration Guide + + If you want a `NodeBundle` with a white background color, you must explicitly specify it: + + Before: + + ```rust + let node = NodeBundle { + ..default() + } + ``` + + After: + + ```rust + let node = NodeBundle { + background_color: Color::WHITE.into(), + ..default() + } + ``` + +commit 5e71d7f833a74cc3796d83ffb40be8ed5f102de4 +Author: CatThingy +Date: Sun Oct 9 16:21:42 2022 +0000 + + Call `mesh2d_tangent_local_to_world` with the right arguments (#6209) + + # Objective + + Allow `Mesh2d` shaders to work with meshes that have vertex tangents + ## Solution + + Correctly pass `mesh.model` into `mesh2d_tangent_local_to_world` + +commit ca3e6e6797fab3e057cd4fb0f16c9708b3bc17e8 +Author: Hennadii Chernyshchyk +Date: Sat Oct 8 17:02:21 2022 +0000 + + Impl Reflect for PathBuf and OsString (#6193) + + # Objective + + `Reflect` impl is missing for `PathBuf` and `OsString`. Closes #6166. + + ## Solution + + Add implementations. + + --- + + ## Changelog + + ### Added + + `Reflect` impls for `PathBuf` and `OsString`. + +commit cf86f275a9e5e9ad7f0912a1879148a8aad6a86d +Author: Dan Kov +Date: Sat Oct 8 14:51:21 2022 +0000 + + Fix doc for Timer::percent_left (#6198) + + # Objective + + - Fix a mistake in documentation. + +commit 6b75589e2c91429eb6c35574840d47d39b2379b9 +Author: Gabriel Bourgeois +Date: Thu Oct 6 21:39:34 2022 +0000 + + Fix inconsistent children removal behavior (#6017) + + # Objective + + Fixes #6010 + + ## Solution + + As discussed in #6010, this makes it so the `Children` component is removed from the entity whenever all of its children are removed. The behavior is now consistent between all of the commands that may remove children from a parent, and this is tested via two new test functions (one for world functions and one for commands). + + Documentation was also added to `insert_children`, `push_children`, `add_child` and `remove_children` commands to make this behavior clearer for users. + + ## Changelog + + - Fixed `Children` component not getting removed from entity when all its children are moved to a new parent. + + ## Migration Guide + + - Queries with `Changed` will no longer match entities that had all of their children removed using `remove_children`. + - `RemovedComponents` will now contain entities that had all of their children remove using `remove_children`. + +commit cfba7312ef98d2166b511fce3c56f81599a56885 +Author: Zicklag +Date: Thu Oct 6 19:31:47 2022 +0000 + + Reflect Default for `ComputedVisibility` and `Handle` (#6187) + + # Objective + + - Reflecting `Default` is required for scripts to create `Reflect` types at runtime with no static type information. + - Reflecting `Default` on `Handle` and `ComputedVisibility` should allow scripts from `bevy_mod_js_scripting` to actually spawn sprites from scratch, without needing any hand-holding from the host-game. + + ## Solution + + - Derive `ReflectDefault` for `Handle` and `ComputedVisiblity`. + + --- + + ## Changelog + + > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. + + - The `Default` trait is now reflected for `Handle` and `ComputedVisibility` + +commit f00212fd48e7aa681e0c8e9238a8f07da469d591 +Author: François +Date: Thu Oct 6 13:33:30 2022 +0000 + + make Handle:: field id private, and replace with a getter (#6176) + + # Objective + + - Field `id` of `Handle` is public: https://docs.rs/bevy/latest/bevy/asset/struct.Handle.html#structfield.id + - Changing the value of this field doesn't make sense as it could mean changing the previous handle without dropping it, breaking asset cleanup detection for the old handle and the new one + + ## Solution + + - Make the field private, and add a public getter + + + Opened after discussion in #6171. Pinging @zicklag + + --- + + ## Migration Guide + + - If you were accessing the value `handle.id`, you can now do so with `handle.id()` + +commit f2106bb3ce4e1a451aa49d3dd658a94f27486c66 +Author: Alvin Philips +Date: Thu Oct 6 13:33:29 2022 +0000 + + Reduced code duplication in gamepad_viewer example (#6175) + + # Objective + + - Reduce code duplication in the `gamepad_viewer` example. + - Fixes #6164 + + ## Solution + + - Added a custom Bundle called `GamepadButtonBundle` to avoid repeating similar code throughout the example. + - Created a `new()` method on `GamepadButtonBundle`. + + + + Co-authored-by: Alvin Philips + +commit 087f1c66aaf652614c61fc912867f2225f07fe9f +Author: Emerson MX +Date: Thu Oct 6 13:14:23 2022 +0000 + + Make bevy_window and bevy_input events serializable (#6180) + + Closes #6021 + +commit 37860a09de897218e6698eaf16dcc7836525a9fb +Author: ira +Date: Wed Oct 5 22:16:26 2022 +0000 + + Add `Camera::viewport_to_world` (#6126) + + # Objective + + Add a method for getting a world space ray from a viewport position. + + Opted to add a `Ray` type to `bevy_math` instead of returning a tuple of `Vec3`'s as this is clearer and easier to document + The docs on `viewport_to_world` are okay, but I'm not super happy with them. + + ## Changelog + * Add `Camera::viewport_to_world` + * Add `Camera::ndc_to_world` + * Add `Ray` to `bevy_math` + * Some doc tweaks + + Co-authored-by: devil-ira + +commit 2362cebcae937173a6340fc0084ec0eb7499da5e +Author: Fanda Vacek +Date: Wed Oct 5 21:22:11 2022 +0000 + + More explicit help how to cycle the cameras (#6162) + + # Objective + + Scene viewer example has switch camera keys defined, but only one camera was instantiated on the scene. + + ## Solution + + More explicit help how to cycle the cameras, explaining that more cameras must be present in loaded scene. + + + + + + Co-authored-by: Fanda Vacek + +commit 720b67396f249f870cdfa68162bafee15eca3b40 +Author: François +Date: Wed Oct 5 16:34:55 2022 +0000 + + flaky test: put panicking system in a single threaded stage (#6172) + + # Objective + + - Fix #5285 + + ## Solution + + - Put the panicking system in a single threaded stage during the test + - This way only the main thread will panic, which is handled by `cargo test` + +commit 26c299bd2a139da797e335b52640a0e40addf17c +Author: Noah +Date: Wed Oct 5 13:51:32 2022 +0000 + + Update window.rs PresentMode docs to clarify which PresentMode will panic and which will fallback (#6160) + + # Objective + + - Fixes contradictory docs in Window::PresentMode partaining to PresentMode fallback behavior. Fix based on commit history showing the most recent update didn't remove old references to the gracefal fallback for Immediate and Mailbox. + - Fixes #5831 + + ## Solution + + - Updated the docs for Window::PresentMode itself and for each individual enum variant to clarify which will fallback and which will panic. + + + Co-authored-by: Noah + +commit 2a6b544a0aa3471b0abb185a367cb25b98042912 +Author: Kewei Huang +Date: Wed Oct 5 12:21:09 2022 +0000 + + Document `EntityMut::remove()` (#6168) + + # Objective + + - Fixes #5990 + + ## Solution + + - Add docs for `EntityMut::remove()` explaining its return value. + +commit 29098b7a113323a8bec5c48e79e1586f61e37d8d +Author: robtfm <50659922+robtfm@users.noreply.github.com> +Date: Wed Oct 5 12:00:07 2022 +0000 + + fix spot dir nan bug (#6167) + + # Objective + + fix error with pbr shader's spotlight direction calculation when direction.y ~= 0 + + ## Solution + + in pbr_lighting.wgsl, clamp `1-x^2-z^2` to `>= 0` so that we can safely `sqrt` it + +commit 8a268129f9efbe0b35a53622e5ff59053ace457f +Author: JoJoJet +Date: Mon Oct 3 16:57:31 2022 +0000 + + Deduplicate ambiguity reporting code (#6149) + + # Objective + + Now that #6083 has been merged, we can clean up some ugly ambiguity detection code. + + # Solution + + Deduplicate code. + +commit ac364e9e28a20a14b82c5b17fde5e262dc2c705c +Author: Sludge <96552222+SludgePhD@users.noreply.github.com> +Date: Mon Oct 3 16:37:03 2022 +0000 + + Register `Wireframe` type (#6152) + + # Objective + + The `Wireframe` type implements `Reflect`, but is never registered, making its reflection inaccessible. + + ## Solution + + Call `App::register_type::()` in the `Plugin::build` implementation of `WireframePlugin`. + + --- + + ## Changelog + + Fixed `Wireframe` type reflection not getting registered. + +commit 3aaf746675c150982322553e847275bc6a9d66bb +Author: ira +Date: Fri Sep 30 13:25:27 2022 +0000 + + Example cleanup (#6131) + + + + Co-authored-by: devil-ira + +commit 6929d95f7f848294aeb4dba8ff144dbe673f793c +Author: Cameron <51241057+maniwani@users.noreply.github.com> +Date: Fri Sep 30 11:37:33 2022 +0000 + + Replace fixed timestep in `alien_cake_addict` example with timer (#5760) + + # Objective + + Examples should use the correct tools for the job. + + ## Solution + + A fixed timestep, by design, can step multiple times consecutively in a single update. + + That property used to crash the `alien_cake_addict` example (#2525), which was "fixed" in #3411 (by just not panicking). The proper fix is to use a timer instead, since the system is supposed to spawn a cake every 5 seconds. + + --- + + A timer guarantees a minimum duration. A fixed timestep guarantees a fixed number of steps per second. + Each one works by essentially sacrificing the other's guarantee. + + You can use them together, but no other systems are timestep-based in this example, so the timer is enough. + +commit 6b8cc2652a0063c31a24df9b2aefcd33ca0a95bd +Author: Nicola Papale +Date: Wed Sep 28 21:20:29 2022 +0000 + + Document all StandardMaterial fields (#5921) + + # Objective + + Add more documentation on `StandardMaterial` and improve + consistency on existing doc. + + Co-authored-by: Nicola Papale + +commit e8e541e4b735bd5c95ae2905a671110bb6621b42 +Author: Lucidus115 +Date: Wed Sep 28 21:02:26 2022 +0000 + + fix #6062 incorrect links for render module docs (#6099) + + # Objective + + - Fixes #6062 + + ## Solution + + - Change path to `(crate::render::renderer)` from `(bevy_render::renderer)` in `crates/bevy_internal/src/lib.rs` + + --- + +commit 4e5b165fa0689f6e4bd76a9bf10c348d482f3376 +Author: Nicola Papale +Date: Wed Sep 28 20:38:43 2022 +0000 + + Add details about intel linux vulkan driver (#6103) + + # Objective + + Fixes #6073 + + # Solution + + Add a paragraph about `vulkan-intel` to the archlinux section. + +commit 0bf7f3153d94543078ef518b2a699b1f24b08dd5 +Author: Dawid Piotrowski +Date: Wed Sep 28 17:53:58 2022 +0000 + + Allow access to non-send resource through `World::resource_scope` (#6113) + + # Objective + + Relaxes the trait bound for `World::resource_scope` to allow non-send resources. Fixes #6037. + + ## Solution + + No big changes in code had to be made. Added a check so that the non-send resources won't be accessed from a different thread. + + --- + + ## Changelog + - `World::resource_scope` accepts non-send resources now + - `World::resource_scope` verifies non-send access if the resource is non-send + - Two new tests are added, one for valid use of `World::resource_scope` with a non-send resource, and one for invalid use (calling it from a different thread, resulting in panic) + + Co-authored-by: Dawid Piotrowski <41804418+Pietrek14@users.noreply.github.com> + +commit 59f872647d37cba0b085a74a2e0ad283292f598e +Author: rustui <90625190+rustui@users.noreply.github.com> +Date: Wed Sep 28 17:39:36 2022 +0000 + + StreamReceiver does not need to be mutable (#6119) + + ResMut -> Res + +commit aa32a77fdde16a34084fa7030329b526b9c129b6 +Author: Federico Rinaldi +Date: Wed Sep 28 14:09:39 2022 +0000 + + Update API docs for `Commands::get_or_spawn` to inform the user about invalid returned values (#6117) + + # Objective + + As explained by #5960, `Commands::get_or_spawn` may return a dangling `EntityCommands` that references a non-existing entities. As explained in [this comment], it may be undesirable to make the method return an `Option`. + + - Addresses #5960 + - Alternative to #5961 + + ## Solution + + This PR adds a doc comment to the method to inform the user that the returned `EntityCommands` is not guaranteed to be valid. It also adds panic doc comments on appropriate `EntityCommands` methods. + + [this comment]: https://github.com/bevyengine/bevy/pull/5961#issuecomment-1259870849 + +commit 197392a2cd2fbec4aab2dd521e22bbbe318a999c +Author: Charles +Date: Wed Sep 28 05:54:11 2022 +0000 + + use alpha mask even when unlit (#6047) + + # Objective + + - Alpha mask was previously ignored when using an unlit material. + - Fixes https://github.com/bevyengine/bevy/issues/4479 + + ## Solution + + - Extract the alpha discard to a separate function and use it when unlit is true + + ## Notes + I tried calling `alpha_discard()` before the `if` in pbr.wgsl, but I had errors related to having a `discard` at the beginning before doing the texture sampling. I'm not sure if there's a way to fix that instead of having the function being called in 2 places. + +commit 807336203903e516a8705a13316c2c2c20c0f5bb +Author: Charles +Date: Wed Sep 28 04:20:27 2022 +0000 + + add globals to mesh view bind group (#5409) + + # Objective + + - It's often really useful to have access to the time when writing shaders. + + ## Solution + + - Add a UnifformBuffer in the mesh view bind group + - This buffer contains the time, delta time and a wrapping frame count + + https://user-images.githubusercontent.com/8348954/180130314-97948c2a-2d11-423d-a9c4-fb5c9d1892c7.mp4 + + --- + + ## Changelog + + - Added a `GlobalsUniform` at position 9 of the mesh view bind group + + ## Notes + + The implementation is currently split between bevy_render and bevy_pbr because I was basing my implementation on the `ViewPlugin`. I'm not sure if that's the right way to structure it. + + I named this `globals` instead of just time because we could potentially add more things to it. + + ## References in other engines + + - Godot: + - Global time since startup, in seconds, by default resets to 0 after 3600 seconds + - Doesn't seem to have anything else + - Unreal: + - Generic time value that updates every frame. Can be paused or scaled. + - Frame count node, doesn't seem to be an equivalent for shaders: + - Unity: + - time since startup in seconds. No mention of time wrapping. Stored as a `vec4(t/20, t, t*2, t*3)` where `t` is the value in seconds + - Also has delta time, sin time and cos time + - ShaderToy: + - iTime is the time since startup in seconds. + - iFrameRate + - iTimeDelta + - iFrame frame counter + + Co-authored-by: Charles + +commit 018509c3a1b238fe4e2569357267de428ca2ad06 +Author: Charles +Date: Wed Sep 28 04:04:55 2022 +0000 + + log pipeline cache errors earlier (#6115) + + # Objective + + - Currently, errors aren't logged as soon as they are found, they are logged only on the next frame. This means your shader could have an unreported error that could have been reported on the first frame. + + ## Solution + + - Log the error as soon as they are found, don't wait until next frame + + ## Notes + + I discovered this issue because I was simply unwrapping the `Result` from `PipelinCache::get_render_pipeline()` which caused it to fail without any explanations. Admittedly, this was a bit of a user error, I shouldn't have unwrapped that, but it seems a bit strange to wait until the next time the pipeline is processed to log the error instead of just logging it as soon as possible since we already have all the info necessary. + +commit d22d310ad58ce1467b9e62db16f4fd95c33cc639 +Author: Mike +Date: Wed Sep 28 01:59:10 2022 +0000 + + Nested spawns on scope (#4466) + + # Objective + + - Add ability to create nested spawns. This is needed for stageless. The current executor spawns tasks for each system early and runs the system by communicating through a channel. In stageless we want to spawn the task late, so that archetypes can be updated right before the task is run. The executor is run on a separate task, so this enables the scope to be passed to the spawned executor. + - Fixes #4301 + + ## Solution + + - Instantiate a single threaded executor on the scope and use that instead of the LocalExecutor. This allows the scope to be Send, but still able to spawn tasks onto the main thread the scope is run on. This works because while systems can access nonsend data. The systems themselves are Send. Because of this change we lose the ability to spawn nonsend tasks on the scope, but I don't think this is being used anywhere. Users would still be able to use spawn_local on TaskPools. + - Steals the lifetime tricks the `std::thread::scope` uses to allow nested spawns, but disallow scope to be passed to tasks or threads not associated with the scope. + - Change the storage for the tasks to a `ConcurrentQueue`. This is to allow a &Scope to be passed for spawning instead of a &mut Scope. `ConcurrentQueue` was chosen because it was already in our dependency tree because `async_executor` depends on it. + - removed the optimizations for 0 and 1 spawned tasks. It did improve those cases, but made the cases of more than 1 task slower. + --- + + ## Changelog + + Add ability to nest spawns + + ```rust + fn main() { + let pool = TaskPool::new(); + pool.scope(|scope| { + scope.spawn(async move { + // calling scope.spawn from an spawn task was not possible before + scope.spawn(async move { + // do something + }); + }); + }) + } + ``` + + ## Migration Guide + + If you were using explicit lifetimes and Passing Scope you'll need to specify two lifetimes now. + + ```rust + fn scoped_function<'scope>(scope: &mut Scope<'scope, ()>) {} + // should become + fn scoped_function<'scope>(scope: &Scope<'_, 'scope, ()>) {} + ``` + + `scope.spawn_local` changed to `scope.spawn_on_scope` this should cover cases where you needed to run tasks on the local thread, but does not cover spawning Nonsend Futures. + + ## TODO + * [x] think real hard about all the lifetimes + * [x] add doc about what 'env and 'scope mean. + * [x] manually check that the single threaded task pool still works + * [x] Get updated perf numbers + * [x] check and make sure all the transmutes are necessary + * [x] move commented out test into a compile fail test + * [x] look through the tests for scope on std and see if I should add any more tests + + Co-authored-by: Michael Hsu + Co-authored-by: Carter Anderson + +commit 92c90a9bade54ecc5b26cad72d30683d7aebd654 +Author: Boxy +Date: Tue Sep 27 18:48:25 2022 +0000 + + add `Res::clone` (#4109) + + # Objective + Make `Res` cloneable + ## Solution + Add an associated fn `clone(self: &Self) -. Self` instead of `Copy + Clone` trait impls to avoid `res.clone()` failing to clone out the underlying `T` + +commit 263ab9424d741e20624c5ed92210ae263de1d2d0 +Author: Demiu +Date: Tue Sep 27 18:34:33 2022 +0000 + + Remove Sync bound from Command (#5871) + + Unless I'm mistaken it is unnecessary, Commands are never accessed from two threads simultaneously. It unnecessarily restricts Command structs + +commit 128c169503a254b373a400e246c409bd51053d29 +Author: SpecificProtagonist +Date: Tue Sep 27 18:11:40 2022 +0000 + + remove copyless (#6100) + + # Objective + Remove copyless + copyless apparently isn't needed anymore to prevent extraneous memcopies and therefore got deprecated: https://github.com/kvark/copyless/issues/22 + +commit 5875ea7db03e3f64d60b305de7f58ffb245f6b32 +Author: Peter Hebden +Date: Tue Sep 27 18:11:39 2022 +0000 + + Add additional constructors for `UiRect` to specify values for specific fields (#5988) + + # Objective + + Often one wants to create a `UiRect` with a value only specifying a single field. These ways are already available, but not the most ergonomic: + + ```rust + UiRect::new(Val::Undefined, Val::Undefined, Val::Percent(25.0), Val::Undefined) + ``` + ```rust + UiRect { + top: Val::Percent(25.0), + ..default() + } + ``` + + ## Solution + + Introduce 6 new constructors: + + - `horizontal` + - `vertical` + - `left` + - `right` + - `top` + - `bottom` + + So the above code can be written instead as: + + ```rust + UiRect::top(Val::Percent(25.0)) + ``` + + This solution is similar to the style fields `margin-left`, `padding-top`, etc. that you would see in CSS, from which bevy's UI has other inspiration. Therefore, it should still feel intuitive to users coming from CSS. + + --- + + ## Changelog + + ### Added + + - Additional constructors for `UiRect` to specify values for specific fields + +commit 5b00af01d756cc9f03f6058f2634ebd56c2a7296 +Author: Mark Schmale +Date: Tue Sep 27 18:11:38 2022 +0000 + + Make arrays behave like lists in reflection (#5987) + + # Objective + + Currently, arrays cannot indexed using the reflection path API. + This change makes them behave like lists so `x.get_path("list[0]")` will behave the same way, whether x.list is a "List" (e.g. a Vec) or an array. + + ## Solution + + When syntax is encounterd `[ ]` we check if the referenced type is either a `ReflectRef::List` or `ReflectRef::Array` (or `ReflectMut` for the mutable case). Since both provide the identical API for accessing entries, we do the same for both, although it requires code duplication as far as I can tell. + + + This was born from working on #5764, but since this seems to be an easier fix (and I am not sure if I can actually solve #5812) I figured it might be worth to split this out. + +commit 180c94cc13bf0d6c9635104edfe1005d160fa217 +Author: Martin Lysell +Date: Tue Sep 27 17:51:12 2022 +0000 + + Fix some outdated file reference comments in bevy_pbr (#6111) + + # Objective + + Simple docs/comments only PR that just fixes some outdated file references left over from the render rewrite. + + ## Solution + + - Change the references to point to the correct files + +commit deb07fe9574e3261ad7c3e9174006e6eac8f824e +Author: Charles +Date: Tue Sep 27 01:30:40 2022 +0000 + + add support for .comp glsl shaders (#6084) + + # Objective + + - Support `.comp` extension for glsl compute shaders + + ## Solution + + - Add `.comp` to the shader asset loader + +commit dc3f801239d25287dc11d7cda35b00d6e3d3dbcf +Author: Carter Anderson +Date: Mon Sep 26 23:57:07 2022 +0000 + + Exclusive Systems Now Implement `System`. Flexible Exclusive System Params (#6083) + + # Objective + + The [Stageless RFC](https://github.com/bevyengine/rfcs/pull/45) involves allowing exclusive systems to be referenced and ordered relative to parallel systems. We've agreed that unifying systems under `System` is the right move. + + This is an alternative to #4166 (see rationale in the comments I left there). Note that this builds on the learnings established there (and borrows some patterns). + + ## Solution + + This unifies parallel and exclusive systems under the shared `System` trait, removing the old `ExclusiveSystem` trait / impls. This is accomplished by adding a new `ExclusiveFunctionSystem` impl similar to `FunctionSystem`. It is backed by `ExclusiveSystemParam`, which is similar to `SystemParam`. There is a new flattened out SystemContainer api (which cuts out a lot of trait and type complexity). + + This means you can remove all cases of `exclusive_system()`: + + ```rust + // before + commands.add_system(some_system.exclusive_system()); + // after + commands.add_system(some_system); + ``` + + I've also implemented `ExclusiveSystemParam` for `&mut QueryState` and `&mut SystemState`, which makes this possible in exclusive systems: + + ```rust + fn some_exclusive_system( + world: &mut World, + transforms: &mut QueryState<&Transform>, + state: &mut SystemState<(Res
+ Release notes +

Sourced from peter-evans/create-pull-request's releases.

+
+

Create Pull Request v4.0.0

+

Breaking changes

+
    +
  • The add-paths input no longer accepts -A as a valid value. When committing all new and modified files the add-paths input should be omitted.
  • +
  • If using self-hosted runners or GitHub Enterprise Server, there are minimum requirements for v4 to run. See "What's new" below for details.
  • +
+

What's new

+
    +
  • Updated runtime to Node.js 16 +
      +
    • The action now requires a minimum version of v2.285.0 for the Actions Runner.
    • +
    • If using GitHub Enterprise Server, the action requires GHES 3.4 or later.
    • +
    +
  • +
+

What's Changed

+ +

New Contributors

+ +

Full Changelog: https://github.com/peter-evans/create-pull-request/compare/v3.14.0...v4.0.0

+

Create Pull Request v3.14.0

+

This release reverts a commit made to bump the runtime to node 16. It inadvertently caused an issue for users on GitHub Enterprise. Apologies. 🙇‍♂️

+

What's Changed

+ +

Full Changelog: https://github.com/peter-evans/create-pull-request/compare/v3.13.0...v3.14.0

+

Create Pull Request v3.13.0

+

What's Changed

+ +

New Contributors

+ +

Full Changelog: https://github.com/peter-evans/create-pull-request/compare/v3.12.1...v3.13.0

+

Create Pull Request v3.12.1

+

What's Changed

+ +

New Contributors

+ + +
+

... (truncated)

+