From 7cec2c0d54ba34cd88bf0919fd8994217244b510 Mon Sep 17 00:00:00 2001 From: Greeble <166992735+greeble-dev@users.noreply.github.com> Date: Mon, 11 Aug 2025 17:16:34 +0100 Subject: [PATCH 001/227] Bump crate-ci/typos from 1.34.0 to 1.35.3 (#20514) Adopted from #20507. Bumps crate-ci/typos from 1.34.0 to 1.35.3. --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- crates/bevy_ecs/src/system/builder.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ad9a1ce76777..5ca0182abeb17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -340,7 +340,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Check for typos - uses: crate-ci/typos@v1.34.0 + uses: crate-ci/typos@v1.35.3 - name: Typos info if: failure() run: | diff --git a/crates/bevy_ecs/src/system/builder.rs b/crates/bevy_ecs/src/system/builder.rs index 523c904c1dc7b..937911ca834c1 100644 --- a/crates/bevy_ecs/src/system/builder.rs +++ b/crates/bevy_ecs/src/system/builder.rs @@ -106,7 +106,7 @@ use super::{Res, ResMut, SystemState}; /// /// The implementor must ensure that the state returned /// from [`SystemParamBuilder::build`] is valid for `P`. -/// Note that the exact safety requiremensts depend on the implementation of [`SystemParam`], +/// Note that the exact safety requirements depend on the implementation of [`SystemParam`], /// so if `Self` is not a local type then you must call [`SystemParam::init_state`] /// or another [`SystemParamBuilder::build`]. pub unsafe trait SystemParamBuilder: Sized { From 41c41bf355b3130b8243578bb68a43b81625c024 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 11 Aug 2025 18:31:03 +0200 Subject: [PATCH 002/227] Update `sysinfo` to `0.37.0` version (#20513) Some internal cleanups and also some performance improvements when retrieving processes in linux... which is not used by bevy, so mostly just updating to keep it up-to-date. :laughing: --- crates/bevy_diagnostic/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_diagnostic/Cargo.toml b/crates/bevy_diagnostic/Cargo.toml index 5abd1fe7a7fe7..de04e5ec9946b 100644 --- a/crates/bevy_diagnostic/Cargo.toml +++ b/crates/bevy_diagnostic/Cargo.toml @@ -69,14 +69,14 @@ log = { version = "0.4", default-features = false } # macOS [target.'cfg(all(target_os="macos"))'.dependencies] # Some features of sysinfo are not supported by apple. This will disable those features on apple devices -sysinfo = { version = "0.36.0", optional = true, default-features = false, features = [ +sysinfo = { version = "0.37.0", optional = true, default-features = false, features = [ "apple-app-store", "system", ] } # Only include when on linux/windows/android/freebsd [target.'cfg(any(target_os = "linux", target_os = "windows", target_os = "android", target_os = "freebsd"))'.dependencies] -sysinfo = { version = "0.36.0", optional = true, default-features = false, features = [ +sysinfo = { version = "0.37.0", optional = true, default-features = false, features = [ "system", ] } From cb34db6e987a75dbcd6c2e8a3192e7bc232abe90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Mon, 11 Aug 2025 21:34:18 +0200 Subject: [PATCH 003/227] Fix latest lints for rust beta (#20516) # Objective - Fix #19679 ## Solution - fix lints --- crates/bevy_animation/src/gltf_curves.rs | 2 +- crates/bevy_anti_aliasing/src/taa/mod.rs | 2 +- crates/bevy_image/src/basis.rs | 2 +- crates/bevy_mesh/src/mesh.rs | 4 ++-- crates/bevy_mesh/src/primitives/dim2.rs | 2 +- crates/bevy_pbr/src/meshlet/persistent_buffer.rs | 2 +- crates/bevy_pbr/src/render/morph.rs | 2 +- .../bevy_render/src/render_resource/bind_group_entries.rs | 6 ++++++ crates/bevy_tasks/src/task_pool.rs | 6 +++--- examples/app/headless.rs | 2 +- examples/async_tasks/async_compute.rs | 2 +- examples/ecs/nondeterministic_system_order.rs | 2 +- 12 files changed, 20 insertions(+), 14 deletions(-) diff --git a/crates/bevy_animation/src/gltf_curves.rs b/crates/bevy_animation/src/gltf_curves.rs index 593ca04d2e025..1493f604b6ca7 100644 --- a/crates/bevy_animation/src/gltf_curves.rs +++ b/crates/bevy_animation/src/gltf_curves.rs @@ -353,7 +353,7 @@ impl WideCubicKeyframeCurve { let values: Vec = values.into_iter().collect(); let divisor = times.len() * 3; - if values.len() % divisor != 0 { + if !values.len().is_multiple_of(divisor) { return Err(WideKeyframeCurveError::LengthMismatch { values_given: values.len(), divisor, diff --git a/crates/bevy_anti_aliasing/src/taa/mod.rs b/crates/bevy_anti_aliasing/src/taa/mod.rs index fa477daf42472..0103d3a6ca4cc 100644 --- a/crates/bevy_anti_aliasing/src/taa/mod.rs +++ b/crates/bevy_anti_aliasing/src/taa/mod.rs @@ -439,7 +439,7 @@ fn prepare_taa_history_textures( texture_descriptor.label = Some("taa_history_2_texture"); let history_2_texture = texture_cache.get(&render_device, texture_descriptor); - let textures = if frame_count.0 % 2 == 0 { + let textures = if frame_count.0.is_multiple_of(2) { TemporalAntiAliasHistoryTextures { write: history_1_texture, read: history_2_texture, diff --git a/crates/bevy_image/src/basis.rs b/crates/bevy_image/src/basis.rs index 396129e678634..c88edb1fdc7bc 100644 --- a/crates/bevy_image/src/basis.rs +++ b/crates/bevy_image/src/basis.rs @@ -45,7 +45,7 @@ pub fn basis_buffer_to_image( let image_count = transcoder.image_count(buffer); let texture_type = transcoder.basis_texture_type(buffer); - if texture_type == BasisTextureType::TextureTypeCubemapArray && image_count % 6 != 0 { + if texture_type == BasisTextureType::TextureTypeCubemapArray && !image_count.is_multiple_of(6) { return Err(TextureError::InvalidData(format!( "Basis file with cube map array texture with non-modulo 6 number of images: {image_count}", ))); diff --git a/crates/bevy_mesh/src/mesh.rs b/crates/bevy_mesh/src/mesh.rs index ea82c8a7445ae..4d85f568ffd2e 100644 --- a/crates/bevy_mesh/src/mesh.rs +++ b/crates/bevy_mesh/src/mesh.rs @@ -606,7 +606,7 @@ impl Mesh { match topology { PrimitiveTopology::TriangleList => { // Early return if the index count doesn't match - if indices.len() % 3 != 0 { + if !indices.len().is_multiple_of(3) { return Err(MeshWindingInvertError::AbruptIndicesEnd); } for chunk in indices.chunks_mut(3) { @@ -620,7 +620,7 @@ impl Mesh { } PrimitiveTopology::LineList => { // Early return if the index count doesn't match - if indices.len() % 2 != 0 { + if !indices.len().is_multiple_of(2) { return Err(MeshWindingInvertError::AbruptIndicesEnd); } indices.reverse(); diff --git a/crates/bevy_mesh/src/primitives/dim2.rs b/crates/bevy_mesh/src/primitives/dim2.rs index 172cb152074d8..19af10afcf80b 100644 --- a/crates/bevy_mesh/src/primitives/dim2.rs +++ b/crates/bevy_mesh/src/primitives/dim2.rs @@ -1111,7 +1111,7 @@ impl MeshBuilder for Capsule2dMeshBuilder { // If the vertex count is even, offset starting angle of top semicircle by half a step // to position the vertices evenly. - let start_angle = if vertex_count % 2 == 0 { + let start_angle = if vertex_count.is_multiple_of(2) { step / 2.0 } else { 0.0 diff --git a/crates/bevy_pbr/src/meshlet/persistent_buffer.rs b/crates/bevy_pbr/src/meshlet/persistent_buffer.rs index e8f4669227a0b..bae7b670b7de2 100644 --- a/crates/bevy_pbr/src/meshlet/persistent_buffer.rs +++ b/crates/bevy_pbr/src/meshlet/persistent_buffer.rs @@ -39,7 +39,7 @@ impl PersistentGpuBuffer { /// Queue an item of type T to be added to the buffer, returning the byte range within the buffer that it will be located at. pub fn queue_write(&mut self, data: T, metadata: T::Metadata) -> Range { let data_size = data.size_in_bytes() as u64; - debug_assert!(data_size % COPY_BUFFER_ALIGNMENT == 0); + debug_assert!(data_size.is_multiple_of(COPY_BUFFER_ALIGNMENT)); if let Ok(buffer_slice) = self.allocation_planner.allocate_range(data_size) { self.write_queue .push((data, metadata, buffer_slice.clone())); diff --git a/crates/bevy_pbr/src/render/morph.rs b/crates/bevy_pbr/src/render/morph.rs index b2dc90af02294..75ddb03414682 100644 --- a/crates/bevy_pbr/src/render/morph.rs +++ b/crates/bevy_pbr/src/render/morph.rs @@ -75,7 +75,7 @@ pub fn prepare_morphs( } const fn can_align(step: usize, target: usize) -> bool { - step % target == 0 || target % step == 0 + step.is_multiple_of(target) || target.is_multiple_of(step) } const WGPU_MIN_ALIGN: usize = 256; diff --git a/crates/bevy_render/src/render_resource/bind_group_entries.rs b/crates/bevy_render/src/render_resource/bind_group_entries.rs index 847bb46f498af..274aa111434f6 100644 --- a/crates/bevy_render/src/render_resource/bind_group_entries.rs +++ b/crates/bevy_render/src/render_resource/bind_group_entries.rs @@ -244,6 +244,12 @@ pub struct DynamicBindGroupEntries<'b> { entries: Vec>, } +impl<'b> Default for DynamicBindGroupEntries<'b> { + fn default() -> Self { + Self::new() + } +} + impl<'b> DynamicBindGroupEntries<'b> { pub fn sequential(entries: impl IntoBindingArray<'b, N>) -> Self { Self { diff --git a/crates/bevy_tasks/src/task_pool.rs b/crates/bevy_tasks/src/task_pool.rs index 25255a1e5d1d3..eb6f8502b3d80 100644 --- a/crates/bevy_tasks/src/task_pool.rs +++ b/crates/bevy_tasks/src/task_pool.rs @@ -384,12 +384,12 @@ impl TaskPool { unsafe { mem::transmute(external_executor) }; // SAFETY: As above, all futures must complete in this function so we can change the lifetime let scope_executor: &'env ThreadExecutor<'env> = unsafe { mem::transmute(scope_executor) }; - let spawned: ConcurrentQueue>>> = + let spawned: ConcurrentQueue>>> = ConcurrentQueue::unbounded(); // shadow the variable so that the owned value cannot be used for the rest of the function // SAFETY: As above, all futures must complete in this function so we can change the lifetime let spawned: &'env ConcurrentQueue< - FallibleTask>>, + FallibleTask>>, > = unsafe { mem::transmute(&spawned) }; let scope = Scope { @@ -628,7 +628,7 @@ pub struct Scope<'scope, 'env: 'scope, T> { executor: &'scope crate::executor::Executor<'scope>, external_executor: &'scope ThreadExecutor<'scope>, scope_executor: &'scope ThreadExecutor<'scope>, - spawned: &'scope ConcurrentQueue>>>, + spawned: &'scope ConcurrentQueue>>>, // make `Scope` invariant over 'scope and 'env scope: PhantomData<&'scope mut &'scope ()>, env: PhantomData<&'env mut &'env ()>, diff --git a/examples/app/headless.rs b/examples/app/headless.rs index 94f01eaddcb8c..5c42f041e915b 100644 --- a/examples/app/headless.rs +++ b/examples/app/headless.rs @@ -50,7 +50,7 @@ fn hello_world_system() { } fn counter(mut state: Local) { - if state.count % 60 == 0 { + if state.count.is_multiple_of(60) { println!("{}", state.count); } state.count += 1; diff --git a/examples/async_tasks/async_compute.rs b/examples/async_tasks/async_compute.rs index fffb55ced1ace..908ae6e4c41a8 100644 --- a/examples/async_tasks/async_compute.rs +++ b/examples/async_tasks/async_compute.rs @@ -123,7 +123,7 @@ fn handle_tasks( /// This system is only used to setup light and camera for the environment fn setup_env(mut commands: Commands) { // Used to center camera on spawned cubes - let offset = if NUM_CUBES % 2 == 0 { + let offset = if NUM_CUBES.is_multiple_of(2) { (NUM_CUBES / 2) as f32 - 0.5 } else { (NUM_CUBES / 2) as f32 diff --git a/examples/ecs/nondeterministic_system_order.rs b/examples/ecs/nondeterministic_system_order.rs index e5e13ffdb302a..b034aaee4101d 100644 --- a/examples/ecs/nondeterministic_system_order.rs +++ b/examples/ecs/nondeterministic_system_order.rs @@ -89,7 +89,7 @@ fn doubles_b(mut b: ResMut) { fn reads_b(b: Res) { // This invariant is always true, // because we've fixed the system order so doubling always occurs after adding. - assert!((b.0 % 2 == 0) || (b.0 == usize::MAX)); + assert!((b.0.is_multiple_of(2)) || (b.0 == usize::MAX)); } fn reads_a_and_b(a: Res, b: Res) { From 67c782552d7ace706d9178181ff1f877a7a46faa Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Tue, 12 Aug 2025 00:45:45 +0300 Subject: [PATCH 004/227] Fix rotation matrix construction from `Rot2` (#20522) # Objective Our `From` implementation for `Mat2` looks like this: ```rust impl From for Mat2 { /// Creates a [`Mat2`] rotation matrix from a [`Rot2`]. fn from(rot: Rot2) -> Self { Mat2::from_cols_array(&[rot.cos, -rot.sin, rot.sin, rot.cos]) } } ``` The resulting matrix looks like this: ```text [ cos, sin ] [ -sin, cos ] ``` Cool! Oh wait -- *checks [notes](https://en.wikipedia.org/wiki/Rotation_matrix)* -- the correct matrix is this? ```text [ cos, -sin ] [ sin, cos ] ``` Oops! ## Solution Fix the matrix signs. Now my joint's axes are oriented correctly :) ## Testing Added a simple regression test. Fails before the change, passes after. --- crates/bevy_math/src/rotation2d.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/bevy_math/src/rotation2d.rs b/crates/bevy_math/src/rotation2d.rs index 1320f6363a784..0fe7ee0c613ee 100644 --- a/crates/bevy_math/src/rotation2d.rs +++ b/crates/bevy_math/src/rotation2d.rs @@ -446,7 +446,7 @@ impl From for Rot2 { impl From for Mat2 { /// Creates a [`Mat2`] rotation matrix from a [`Rot2`]. fn from(rot: Rot2) -> Self { - Mat2::from_cols_array(&[rot.cos, -rot.sin, rot.sin, rot.cos]) + Mat2::from_cols_array(&[rot.cos, rot.sin, -rot.sin, rot.cos]) } } @@ -518,7 +518,7 @@ mod tests { use approx::assert_relative_eq; - use crate::{ops, Dir2, Rot2, Vec2}; + use crate::{ops, Dir2, Mat2, Rot2, Vec2}; #[test] fn creation() { @@ -721,4 +721,20 @@ mod tests { assert_eq!(rot1.slerp(rot2, 0.5).as_degrees(), 90.0); assert_eq!(ops::abs(rot1.slerp(rot2, 1.0).as_degrees()), 180.0); } + + #[test] + fn rotation_matrix() { + let rotation = Rot2::degrees(90.0); + let matrix: Mat2 = rotation.into(); + + // Check that the matrix is correct. + assert_relative_eq!(matrix.x_axis, Vec2::Y); + assert_relative_eq!(matrix.y_axis, Vec2::NEG_X); + + // Check that the matrix rotates vectors correctly. + assert_relative_eq!(matrix * Vec2::X, Vec2::Y); + assert_relative_eq!(matrix * Vec2::Y, Vec2::NEG_X); + assert_relative_eq!(matrix * Vec2::NEG_X, Vec2::NEG_Y); + assert_relative_eq!(matrix * Vec2::NEG_Y, Vec2::X); + } } From d8df506d2c8faefaa14ebfa6b0cbe531c7e7bdb0 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Mon, 11 Aug 2025 23:10:18 +0100 Subject: [PATCH 005/227] Rename `ComputedNodeTarget` to `ComputedUiTargetCamera` (#20519) # Objective Seems like not enough users and devs are aware of this component or what it's for, maybe a more descriptive name will help. ## Solution Rename `ComputedNodeTarget` to `ComputedUiTargetCamera`. New name chosen because the component's value is derived from `UiTargetCamera`. --- .../bevy_core_widgets/src/core_scrollbar.rs | 4 +- crates/bevy_core_widgets/src/core_slider.rs | 6 +- .../src/experimental/ghost_hierarchy.rs | 4 +- crates/bevy_ui/src/focus.rs | 5 +- crates/bevy_ui/src/layout/mod.rs | 12 ++-- crates/bevy_ui/src/lib.rs | 4 +- crates/bevy_ui/src/picking_backend.rs | 2 +- crates/bevy_ui/src/ui_node.rs | 8 +-- crates/bevy_ui/src/update.rs | 59 ++++++++++--------- crates/bevy_ui/src/widget/image.rs | 4 +- crates/bevy_ui/src/widget/text.rs | 6 +- crates/bevy_ui_render/src/box_shadow.rs | 4 +- crates/bevy_ui_render/src/debug_overlay.rs | 4 +- crates/bevy_ui_render/src/gradient.rs | 2 +- crates/bevy_ui_render/src/lib.rs | 20 +++---- .../src/ui_material_pipeline.rs | 2 +- .../src/ui_texture_slice_pipeline.rs | 2 +- examples/3d/split_screen.rs | 2 +- .../renamed_computednodetarget.md | 6 ++ 19 files changed, 84 insertions(+), 72 deletions(-) create mode 100644 release-content/migration-guides/renamed_computednodetarget.md diff --git a/crates/bevy_core_widgets/src/core_scrollbar.rs b/crates/bevy_core_widgets/src/core_scrollbar.rs index 5f5a7087483d1..cf52d7eb8c80c 100644 --- a/crates/bevy_core_widgets/src/core_scrollbar.rs +++ b/crates/bevy_core_widgets/src/core_scrollbar.rs @@ -12,7 +12,7 @@ use bevy_math::Vec2; use bevy_picking::events::{Cancel, Drag, DragEnd, DragStart, Pointer, Press}; use bevy_reflect::{prelude::ReflectDefault, Reflect}; use bevy_ui::{ - ComputedNode, ComputedNodeTarget, Node, ScrollPosition, UiGlobalTransform, UiScale, Val, + ComputedNode, ComputedUiTargetCamera, Node, ScrollPosition, UiGlobalTransform, UiScale, Val, }; /// Used to select the orientation of a scrollbar, slider, or other oriented control. @@ -104,7 +104,7 @@ fn scrollbar_on_pointer_down( mut q_scrollbar: Query<( &CoreScrollbar, &ComputedNode, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &UiGlobalTransform, )>, mut q_scroll_pos: Query<(&mut ScrollPosition, &ComputedNode), Without>, diff --git a/crates/bevy_core_widgets/src/core_slider.rs b/crates/bevy_core_widgets/src/core_slider.rs index 64570c2ed1963..6d38cf7732327 100644 --- a/crates/bevy_core_widgets/src/core_slider.rs +++ b/crates/bevy_core_widgets/src/core_slider.rs @@ -23,7 +23,9 @@ use bevy_log::warn_once; use bevy_math::ops; use bevy_picking::events::{Drag, DragEnd, DragStart, Pointer, Press}; use bevy_reflect::{prelude::ReflectDefault, Reflect}; -use bevy_ui::{ComputedNode, ComputedNodeTarget, InteractionDisabled, UiGlobalTransform, UiScale}; +use bevy_ui::{ + ComputedNode, ComputedUiTargetCamera, InteractionDisabled, UiGlobalTransform, UiScale, +}; use crate::{Callback, Notify, ValueChange}; @@ -234,7 +236,7 @@ pub(crate) fn slider_on_pointer_down( &SliderStep, Option<&SliderPrecision>, &ComputedNode, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &UiGlobalTransform, Has, )>, diff --git a/crates/bevy_ui/src/experimental/ghost_hierarchy.rs b/crates/bevy_ui/src/experimental/ghost_hierarchy.rs index 3ae45377ebeaa..79d081c6bfd4d 100644 --- a/crates/bevy_ui/src/experimental/ghost_hierarchy.rs +++ b/crates/bevy_ui/src/experimental/ghost_hierarchy.rs @@ -1,7 +1,7 @@ //! This module contains [`GhostNode`] and utilities to flatten the UI hierarchy, traversing past ghost nodes. #[cfg(feature = "ghost_nodes")] -use crate::ui_node::ComputedNodeTarget; +use crate::ui_node::ComputedUiTargetCamera; use crate::Node; #[cfg(feature = "ghost_nodes")] use bevy_camera::visibility::Visibility; @@ -21,7 +21,7 @@ use smallvec::SmallVec; #[derive(Component, Debug, Copy, Clone, Reflect)] #[cfg_attr(feature = "ghost_nodes", derive(Default))] #[reflect(Component, Debug, Clone)] -#[require(Visibility, Transform, ComputedNodeTarget)] +#[require(Visibility, Transform, ComputedUiTargetCamera)] pub struct GhostNode; #[cfg(feature = "ghost_nodes")] diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 03f022c7627af..eddb6f54add14 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -1,5 +1,6 @@ use crate::{ - ui_transform::UiGlobalTransform, ComputedNode, ComputedNodeTarget, Node, OverrideClip, UiStack, + ui_transform::UiGlobalTransform, ComputedNode, ComputedUiTargetCamera, Node, OverrideClip, + UiStack, }; use bevy_camera::{visibility::InheritedVisibility, Camera, NormalizedRenderTarget}; use bevy_ecs::{ @@ -139,7 +140,7 @@ pub struct NodeQuery { relative_cursor_position: Option<&'static mut RelativeCursorPosition>, focus_policy: Option<&'static FocusPolicy>, inherited_visibility: Option<&'static InheritedVisibility>, - target_camera: &'static ComputedNodeTarget, + target_camera: &'static ComputedUiTargetCamera, } /// The system that sets Interaction for all UI elements based on the mouse cursor activity diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 9a077acb17ea2..39d5e26e0d963 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -1,7 +1,7 @@ use crate::{ experimental::{UiChildren, UiRootNodes}, ui_transform::{UiGlobalTransform, UiTransform}, - BorderRadius, ComputedNode, ComputedNodeTarget, ContentSize, Display, LayoutConfig, Node, + BorderRadius, ComputedNode, ComputedUiTargetCamera, ContentSize, Display, LayoutConfig, Node, Outline, OverflowAxis, ScrollPosition, }; use bevy_ecs::{ @@ -77,7 +77,7 @@ pub fn ui_layout_system( Entity, Ref, Option<&mut ContentSize>, - Ref, + Ref, )>, added_node_query: Query<(), Added>, mut node_update_query: Query<( @@ -383,7 +383,7 @@ mod tests { fn setup_ui_test_app() -> App { let mut app = App::new(); - app.add_plugins(HierarchyPropagatePlugin::::new( + app.add_plugins(HierarchyPropagatePlugin::::new( PostUpdate, )); app.init_resource::(); @@ -416,7 +416,7 @@ mod tests { app.configure_sets( PostUpdate, - PropagateSet::::default() + PropagateSet::::default() .after(update_ui_context_system) .before(ui_layout_system), ); @@ -1074,13 +1074,13 @@ mod tests { .chain(), ); - app.add_plugins(HierarchyPropagatePlugin::::new( + app.add_plugins(HierarchyPropagatePlugin::::new( PostUpdate, )); app.configure_sets( PostUpdate, - PropagateSet::::default() + PropagateSet::::default() .after(update_ui_context_system) .before(ui_layout_system), ); diff --git a/crates/bevy_ui/src/lib.rs b/crates/bevy_ui/src/lib.rs index e75f1ed96cd8d..c6eefa8bb8a38 100644 --- a/crates/bevy_ui/src/lib.rs +++ b/crates/bevy_ui/src/lib.rs @@ -154,9 +154,9 @@ impl Plugin for UiPlugin { ) .configure_sets( PostUpdate, - PropagateSet::::default().in_set(UiSystems::Propagate), + PropagateSet::::default().in_set(UiSystems::Propagate), ) - .add_plugins(HierarchyPropagatePlugin::::new( + .add_plugins(HierarchyPropagatePlugin::::new( PostUpdate, )) .add_systems( diff --git a/crates/bevy_ui/src/picking_backend.rs b/crates/bevy_ui/src/picking_backend.rs index ffd961acd3777..e944dd3dd3229 100644 --- a/crates/bevy_ui/src/picking_backend.rs +++ b/crates/bevy_ui/src/picking_backend.rs @@ -92,7 +92,7 @@ pub struct NodeQuery { transform: &'static UiGlobalTransform, pickable: Option<&'static Pickable>, inherited_visibility: Option<&'static InheritedVisibility>, - target_camera: &'static ComputedNodeTarget, + target_camera: &'static ComputedUiTargetCamera, } /// Computes the UI node entities under each pointer. diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 7c55265691233..9306edbeeda64 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -380,7 +380,7 @@ impl From for ScrollPosition { #[derive(Component, Clone, PartialEq, Debug, Reflect)] #[require( ComputedNode, - ComputedNodeTarget, + ComputedUiTargetCamera, UiTransform, BackgroundColor, BorderColor, @@ -2802,13 +2802,13 @@ impl<'w, 's> DefaultUiCamera<'w, 's> { /// Derived information about the camera target for this UI node. #[derive(Component, Clone, Copy, Debug, Reflect, PartialEq)] #[reflect(Component, Default, PartialEq, Clone)] -pub struct ComputedNodeTarget { +pub struct ComputedUiTargetCamera { pub(crate) camera: Entity, pub(crate) scale_factor: f32, pub(crate) physical_size: UVec2, } -impl Default for ComputedNodeTarget { +impl Default for ComputedUiTargetCamera { fn default() -> Self { Self { camera: Entity::PLACEHOLDER, @@ -2818,7 +2818,7 @@ impl Default for ComputedNodeTarget { } } -impl ComputedNodeTarget { +impl ComputedUiTargetCamera { pub fn camera(&self) -> Option { Some(self.camera).filter(|&entity| entity != Entity::PLACEHOLDER) } diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index 1978f6b3a4a18..0dd7c3871463b 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -3,8 +3,8 @@ use crate::{ experimental::{UiChildren, UiRootNodes}, ui_transform::UiGlobalTransform, - CalculatedClip, ComputedNodeTarget, DefaultUiCamera, Display, Node, OverflowAxis, OverrideClip, - UiScale, UiTargetCamera, + CalculatedClip, ComputedUiTargetCamera, DefaultUiCamera, Display, Node, OverflowAxis, + OverrideClip, UiScale, UiTargetCamera, }; use super::ComputedNode; @@ -164,7 +164,7 @@ pub fn update_ui_context_system( commands .entity(root_entity) - .insert(Propagate(ComputedNodeTarget { + .insert(Propagate(ComputedUiTargetCamera { camera, scale_factor, physical_size, @@ -199,7 +199,7 @@ mod tests { use bevy_window::WindowScaleFactorChanged; use crate::update::update_ui_context_system; - use crate::ComputedNodeTarget; + use crate::ComputedUiTargetCamera; use crate::IsDefaultUiCamera; use crate::Node; use crate::UiScale; @@ -217,11 +217,14 @@ mod tests { app.init_resource::>>(); app.init_resource::>(); app.init_resource::(); - app.add_plugins(HierarchyPropagatePlugin::::new( + app.add_plugins(HierarchyPropagatePlugin::::new( PostUpdate, )); - app.configure_sets(PostUpdate, PropagateSet::::default()); + app.configure_sets( + PostUpdate, + PropagateSet::::default(), + ); app.add_systems( bevy_app::Update, @@ -256,8 +259,8 @@ mod tests { let world = app.world_mut(); assert_eq!( - *world.get::(uinode).unwrap(), - ComputedNodeTarget { + *world.get::(uinode).unwrap(), + ComputedUiTargetCamera { camera, physical_size, scale_factor, @@ -320,8 +323,8 @@ mod tests { (uinode2c, camera2, scale2, size2), ] { assert_eq!( - *world.get::(uinode).unwrap(), - ComputedNodeTarget { + *world.get::(uinode).unwrap(), + ComputedUiTargetCamera { camera, scale_factor, physical_size, @@ -375,7 +378,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .scale_factor, scale1 @@ -383,7 +386,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .physical_size, size1 @@ -391,7 +394,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .camera() .unwrap(), @@ -405,7 +408,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .scale_factor, scale2 @@ -413,7 +416,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .physical_size, size2 @@ -421,7 +424,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .camera() .unwrap(), @@ -476,7 +479,7 @@ mod tests { assert_eq!( world - .get::(uinode1) + .get::(uinode1) .unwrap() .scale_factor(), scale1 @@ -484,7 +487,7 @@ mod tests { assert_eq!( world - .get::(uinode1) + .get::(uinode1) .unwrap() .physical_size(), size1 @@ -492,7 +495,7 @@ mod tests { assert_eq!( world - .get::(uinode1) + .get::(uinode1) .unwrap() .camera() .unwrap(), @@ -501,7 +504,7 @@ mod tests { assert_eq!( world - .get::(uinode2) + .get::(uinode2) .unwrap() .camera() .unwrap(), @@ -516,7 +519,7 @@ mod tests { assert_eq!( world - .get::(uinode1) + .get::(uinode1) .unwrap() .scale_factor(), scale2 @@ -524,7 +527,7 @@ mod tests { assert_eq!( world - .get::(uinode1) + .get::(uinode1) .unwrap() .physical_size(), size2 @@ -532,7 +535,7 @@ mod tests { assert_eq!( world - .get::(uinode1) + .get::(uinode1) .unwrap() .camera() .unwrap(), @@ -541,7 +544,7 @@ mod tests { assert_eq!( world - .get::(uinode2) + .get::(uinode2) .unwrap() .camera() .unwrap(), @@ -580,7 +583,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .scale_factor, scale @@ -588,7 +591,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .physical_size, size @@ -596,7 +599,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .camera() .unwrap(), @@ -610,7 +613,7 @@ mod tests { assert_eq!( world - .get::(uinode) + .get::(uinode) .unwrap() .scale_factor(), 2. diff --git a/crates/bevy_ui/src/widget/image.rs b/crates/bevy_ui/src/widget/image.rs index 9a743595b86b1..6f0ed85ab7cc0 100644 --- a/crates/bevy_ui/src/widget/image.rs +++ b/crates/bevy_ui/src/widget/image.rs @@ -1,4 +1,4 @@ -use crate::{ComputedNodeTarget, ContentSize, Measure, MeasureArgs, Node, NodeMeasure}; +use crate::{ComputedUiTargetCamera, ContentSize, Measure, MeasureArgs, Node, NodeMeasure}; use bevy_asset::{Assets, Handle}; use bevy_color::Color; use bevy_ecs::prelude::*; @@ -261,7 +261,7 @@ pub fn update_image_content_size_system( &mut ContentSize, Ref, &mut ImageNodeSize, - Ref, + Ref, ), UpdateImageFilter, >, diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index 1544a5ff7a976..8063578b11311 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -1,5 +1,5 @@ use crate::{ - ComputedNode, ComputedNodeTarget, ContentSize, FixedMeasure, Measure, MeasureArgs, Node, + ComputedNode, ComputedUiTargetCamera, ContentSize, FixedMeasure, Measure, MeasureArgs, Node, NodeMeasure, }; use bevy_asset::Assets; @@ -262,7 +262,7 @@ fn create_text_measure<'a>( /// A `Measure` is used by the UI's layout algorithm to determine the appropriate amount of space /// to provide for the text given the fonts, the text itself and the constraints of the layout. /// -/// * Measures are regenerated on changes to either [`ComputedTextBlock`] or [`ComputedNodeTarget`]. +/// * Measures are regenerated on changes to either [`ComputedTextBlock`] or [`ComputedUiTargetCamera`]. /// * Changes that only modify the colors of a `Text` do not require a new `Measure`. This system /// is only able to detect that a `Text` component has changed and will regenerate the `Measure` on /// color changes. This can be expensive, particularly for large blocks of text, and the [`bypass_change_detection`](bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection) @@ -276,7 +276,7 @@ pub fn measure_text_system( &mut ContentSize, &mut TextNodeFlags, &mut ComputedTextBlock, - Ref, + Ref, ), With, >, diff --git a/crates/bevy_ui_render/src/box_shadow.rs b/crates/bevy_ui_render/src/box_shadow.rs index 42bd8c93583b4..2b7b9e679e135 100644 --- a/crates/bevy_ui_render/src/box_shadow.rs +++ b/crates/bevy_ui_render/src/box_shadow.rs @@ -28,7 +28,7 @@ use bevy_render::{ use bevy_render::{RenderApp, RenderStartup}; use bevy_shader::{Shader, ShaderDefVal}; use bevy_ui::{ - BoxShadow, CalculatedClip, ComputedNode, ComputedNodeTarget, ResolvedBorderRadius, + BoxShadow, CalculatedClip, ComputedNode, ComputedUiTargetCamera, ResolvedBorderRadius, UiGlobalTransform, Val, }; use bevy_utils::default; @@ -223,7 +223,7 @@ pub fn extract_shadows( &InheritedVisibility, &BoxShadow, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, )>, >, camera_map: Extract, diff --git a/crates/bevy_ui_render/src/debug_overlay.rs b/crates/bevy_ui_render/src/debug_overlay.rs index 6c277b55cd124..e5d1d7db80b0e 100644 --- a/crates/bevy_ui_render/src/debug_overlay.rs +++ b/crates/bevy_ui_render/src/debug_overlay.rs @@ -21,7 +21,7 @@ use bevy_sprite::BorderRect; use bevy_ui::ui_transform::UiGlobalTransform; use bevy_ui::CalculatedClip; use bevy_ui::ComputedNode; -use bevy_ui::ComputedNodeTarget; +use bevy_ui::ComputedUiTargetCamera; use bevy_ui::UiStack; /// Configuration for the UI debug overlay @@ -65,7 +65,7 @@ pub fn extract_debug_overlay( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, )>, >, ui_stack: Extract>, diff --git a/crates/bevy_ui_render/src/gradient.rs b/crates/bevy_ui_render/src/gradient.rs index cc8442f8c9517..93fb500779114 100644 --- a/crates/bevy_ui_render/src/gradient.rs +++ b/crates/bevy_ui_render/src/gradient.rs @@ -352,7 +352,7 @@ pub fn extract_gradients( Query<( Entity, &ComputedNode, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, diff --git a/crates/bevy_ui_render/src/lib.rs b/crates/bevy_ui_render/src/lib.rs index 068335645d082..70d2f42089248 100644 --- a/crates/bevy_ui_render/src/lib.rs +++ b/crates/bevy_ui_render/src/lib.rs @@ -25,8 +25,8 @@ use bevy_reflect::Reflect; use bevy_shader::load_shader_library; use bevy_ui::widget::{ImageNode, TextShadow, ViewportNode}; use bevy_ui::{ - BackgroundColor, BorderColor, CalculatedClip, ComputedNode, ComputedNodeTarget, Display, Node, - Outline, ResolvedBorderRadius, UiGlobalTransform, + BackgroundColor, BorderColor, CalculatedClip, ComputedNode, ComputedUiTargetCamera, Display, + Node, Outline, ResolvedBorderRadius, UiGlobalTransform, }; use bevy_app::prelude::*; @@ -327,7 +327,7 @@ pub struct UiCameraMapper<'w, 's> { impl<'w, 's> UiCameraMapper<'w, 's> { /// Returns the render entity corresponding to the given `UiTargetCamera` or the default camera if `None`. - pub fn map(&mut self, computed_target: &ComputedNodeTarget) -> Option { + pub fn map(&mut self, computed_target: &ComputedUiTargetCamera) -> Option { let camera_entity = computed_target.camera()?; if self.camera_entity != camera_entity { let new_render_camera_entity = self.mapping.get(camera_entity).ok()?; @@ -438,7 +438,7 @@ pub fn extract_uinode_background_colors( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &BackgroundColor, )>, >, @@ -497,7 +497,7 @@ pub fn extract_uinode_images( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &ImageNode, )>, >, @@ -581,7 +581,7 @@ pub fn extract_uinode_borders( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, AnyOf<(&BorderColor, &Outline)>, )>, >, @@ -843,7 +843,7 @@ pub fn extract_viewport_nodes( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &ViewportNode, )>, >, @@ -906,7 +906,7 @@ pub fn extract_text_sections( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &ComputedTextBlock, &TextLayoutInfo, )>, @@ -1001,7 +1001,7 @@ pub fn extract_text_shadows( Entity, &ComputedNode, &UiGlobalTransform, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &InheritedVisibility, Option<&CalculatedClip>, &TextLayoutInfo, @@ -1083,7 +1083,7 @@ pub fn extract_text_background_colors( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &TextLayoutInfo, )>, >, diff --git a/crates/bevy_ui_render/src/ui_material_pipeline.rs b/crates/bevy_ui_render/src/ui_material_pipeline.rs index da6397806c33f..7b098f7ee8786 100644 --- a/crates/bevy_ui_render/src/ui_material_pipeline.rs +++ b/crates/bevy_ui_render/src/ui_material_pipeline.rs @@ -337,7 +337,7 @@ pub fn extract_ui_material_nodes( &MaterialNode, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, )>, >, camera_map: Extract, diff --git a/crates/bevy_ui_render/src/ui_texture_slice_pipeline.rs b/crates/bevy_ui_render/src/ui_texture_slice_pipeline.rs index fe3879f2d7422..62000c5cd8cbb 100644 --- a/crates/bevy_ui_render/src/ui_texture_slice_pipeline.rs +++ b/crates/bevy_ui_render/src/ui_texture_slice_pipeline.rs @@ -229,7 +229,7 @@ pub fn extract_ui_texture_slices( &UiGlobalTransform, &InheritedVisibility, Option<&CalculatedClip>, - &ComputedNodeTarget, + &ComputedUiTargetCamera, &ImageNode, )>, >, diff --git a/examples/3d/split_screen.rs b/examples/3d/split_screen.rs index 0613da825eff6..ed939e97b2a30 100644 --- a/examples/3d/split_screen.rs +++ b/examples/3d/split_screen.rs @@ -183,7 +183,7 @@ fn set_camera_viewports( fn button_system( interaction_query: Query< - (&Interaction, &ComputedNodeTarget, &RotateCamera), + (&Interaction, &ComputedUiTargetCamera, &RotateCamera), (Changed, With