diff --git a/crates/bevy_app/src/ci_testing.rs b/crates/bevy_app/src/ci_testing.rs index 21e22bec04e9a..dc8865a166696 100644 --- a/crates/bevy_app/src/ci_testing.rs +++ b/crates/bevy_app/src/ci_testing.rs @@ -1,7 +1,6 @@ -use serde::Deserialize; - -use crate::{app::AppExit, AppBuilder}; +use crate::app::{App, AppExit}; use bevy_ecs::system::IntoSystem; +use serde::Deserialize; /// Configuration for automated testing on CI #[derive(Deserialize)] @@ -23,16 +22,15 @@ fn ci_testing_exit_after( *current_frame += 1; } -pub(crate) fn setup_app(app_builder: &mut AppBuilder) -> &mut AppBuilder { +pub(crate) fn setup_app(app: &mut App) -> &mut App { let filename = std::env::var("CI_TESTING_CONFIG").unwrap_or_else(|_| "ci_testing_config.ron".to_string()); let config: CiTestingConfig = ron::from_str( &std::fs::read_to_string(filename).expect("error reading CI testing configuration file"), ) .expect("error deserializing CI testing configuration file"); - app_builder - .insert_resource(config) + app.insert_resource(config) .add_system(ci_testing_exit_after.system()); - app_builder + app } diff --git a/crates/bevy_core/src/time/timer.rs b/crates/bevy_core/src/time/timer.rs index 290d73e7c197f..329fcbeb1b94e 100644 --- a/crates/bevy_core/src/time/timer.rs +++ b/crates/bevy_core/src/time/timer.rs @@ -375,10 +375,10 @@ mod tests { t.tick(Duration::from_secs_f32(0.25)); assert_eq!(t.elapsed_secs(), 0.25); assert_eq!(t.duration(), Duration::from_secs_f32(10.0)); - assert_eq!(t.finished(), false); - assert_eq!(t.just_finished(), false); + assert!(!t.finished()); + assert!(!t.just_finished()); assert_eq!(t.times_finished(), 0); - assert_eq!(t.repeating(), false); + assert!(!t.repeating()); assert_eq!(t.percent(), 0.025); assert_eq!(t.percent_left(), 0.975); // Ticking while paused changes nothing @@ -386,26 +386,26 @@ mod tests { t.tick(Duration::from_secs_f32(500.0)); assert_eq!(t.elapsed_secs(), 0.25); assert_eq!(t.duration(), Duration::from_secs_f32(10.0)); - assert_eq!(t.finished(), false); - assert_eq!(t.just_finished(), false); + assert!(!t.finished()); + assert!(!t.just_finished()); assert_eq!(t.times_finished(), 0); - assert_eq!(t.repeating(), false); + assert!(!t.repeating()); assert_eq!(t.percent(), 0.025); assert_eq!(t.percent_left(), 0.975); // Tick past the end and make sure elapsed doesn't go past 0.0 and other things update t.unpause(); t.tick(Duration::from_secs_f32(500.0)); assert_eq!(t.elapsed_secs(), 10.0); - assert_eq!(t.finished(), true); - assert_eq!(t.just_finished(), true); + assert!(t.finished()); + assert!(t.just_finished()); assert_eq!(t.times_finished(), 1); assert_eq!(t.percent(), 1.0); assert_eq!(t.percent_left(), 0.0); // Continuing to tick when finished should only change just_finished t.tick(Duration::from_secs_f32(1.0)); assert_eq!(t.elapsed_secs(), 10.0); - assert_eq!(t.finished(), true); - assert_eq!(t.just_finished(), false); + assert!(t.finished()); + assert!(!t.just_finished()); assert_eq!(t.times_finished(), 0); assert_eq!(t.percent(), 1.0); assert_eq!(t.percent_left(), 0.0); @@ -418,25 +418,25 @@ mod tests { t.tick(Duration::from_secs_f32(0.75)); assert_eq!(t.elapsed_secs(), 0.75); assert_eq!(t.duration(), Duration::from_secs_f32(2.0)); - assert_eq!(t.finished(), false); - assert_eq!(t.just_finished(), false); + assert!(!t.finished()); + assert!(!t.just_finished()); assert_eq!(t.times_finished(), 0); - assert_eq!(t.repeating(), true); + assert!(t.repeating()); assert_eq!(t.percent(), 0.375); assert_eq!(t.percent_left(), 0.625); // Tick past the end and make sure elapsed wraps t.tick(Duration::from_secs_f32(1.5)); assert_eq!(t.elapsed_secs(), 0.25); - assert_eq!(t.finished(), true); - assert_eq!(t.just_finished(), true); + assert!(t.finished()); + assert!(t.just_finished()); assert_eq!(t.times_finished(), 1); assert_eq!(t.percent(), 0.125); assert_eq!(t.percent_left(), 0.875); // Continuing to tick should turn off both finished & just_finished for repeating timers t.tick(Duration::from_secs_f32(1.0)); assert_eq!(t.elapsed_secs(), 1.25); - assert_eq!(t.finished(), false); - assert_eq!(t.just_finished(), false); + assert!(!t.finished()); + assert!(!t.just_finished()); assert_eq!(t.times_finished(), 0); assert_eq!(t.percent(), 0.625); assert_eq!(t.percent_left(), 0.375); diff --git a/crates/bevy_dylib/src/lib.rs b/crates/bevy_dylib/src/lib.rs index 9cea45597b66e..b39929bea6c71 100644 --- a/crates/bevy_dylib/src/lib.rs +++ b/crates/bevy_dylib/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::single_component_path_imports)] + //! Forces dynamic linking of Bevy. //! //! Dynamically linking Bevy makes the "link" step much faster. This can be achieved by adding @@ -8,5 +10,4 @@ // Force linking of the main bevy crate #[allow(unused_imports)] -#[allow(clippy::single_component_path_imports)] use bevy_internal; diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index 7160ed6acc3c2..7be98eac0e621 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -428,6 +428,11 @@ impl Entities { /// Allocates space for entities previously reserved with `reserve_entity` or /// `reserve_entities`, then initializes each one using the supplied function. + /// + /// # Safety + /// Flush _must_ set the entity location to the correct ArchetypeId for the given Entity + /// each time init is called. This _can_ be ArchetypeId::invalid(), provided the Entity has + /// not been assigned to an Archetype. pub unsafe fn flush(&mut self, mut init: impl FnMut(Entity, &mut EntityLocation)) { let free_cursor = self.free_cursor.get_mut(); let current_free_cursor = *free_cursor; diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 2dc7716a54b72..c05dfc7f80b3c 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -324,7 +324,7 @@ mod tests { run_system(&mut world, sys.system()); // ensure the system actually ran - assert_eq!(*world.get_resource::().unwrap(), true); + assert!(*world.get_resource::().unwrap()); } #[test] @@ -353,7 +353,7 @@ mod tests { } run_system(&mut world, validate_removed.system()); - assert_eq!(*world.get_resource::().unwrap(), true, "system ran"); + assert!(*world.get_resource::().unwrap(), "system ran"); } #[test] @@ -371,7 +371,7 @@ mod tests { ); // ensure the system actually ran - assert_eq!(*world.get_resource::().unwrap(), true); + assert!(*world.get_resource::().unwrap()); } #[test] fn world_collections_system() { @@ -414,7 +414,7 @@ mod tests { run_system(&mut world, sys.system()); // ensure the system actually ran - assert_eq!(*world.get_resource::().unwrap(), true); + assert!(*world.get_resource::().unwrap()); } #[test] diff --git a/crates/bevy_render/src/camera/visible_entities.rs b/crates/bevy_render/src/camera/visible_entities.rs index 1fd0a9da460bc..46b7f3b31867a 100644 --- a/crates/bevy_render/src/camera/visible_entities.rs +++ b/crates/bevy_render/src/camera/visible_entities.rs @@ -167,14 +167,12 @@ mod rendering_mask_tests { "default masks match each other" ); - assert_eq!( - RenderLayers::layer(0).intersects(&RenderLayers::layer(1)), - false, + assert!( + !RenderLayers::layer(0).intersects(&RenderLayers::layer(1)), "masks with differing layers do not match" ); - assert_eq!( - RenderLayers(0).intersects(&RenderLayers(0)), - false, + assert!( + !RenderLayers(0).intersects(&RenderLayers(0)), "empty masks don't match" ); assert_eq!( diff --git a/crates/bevy_tasks/src/countdown_event.rs b/crates/bevy_tasks/src/countdown_event.rs index 84f5b7213a4c0..9f672fe16ba0b 100644 --- a/crates/bevy_tasks/src/countdown_event.rs +++ b/crates/bevy_tasks/src/countdown_event.rs @@ -125,10 +125,7 @@ mod tests { let listener3 = event.listen(); // Verify that we are still blocked - assert_eq!( - false, - listener2.wait_timeout(instant::Duration::from_millis(10)) - ); + assert!(!listener2.wait_timeout(instant::Duration::from_millis(10))); // Notify all and verify the remaining listener is notified event.notify(std::usize::MAX); diff --git a/crates/bevy_transform/src/hierarchy/hierarchy.rs b/crates/bevy_transform/src/hierarchy/hierarchy.rs index 2bbbd946bd4c3..338a6e12733c2 100644 --- a/crates/bevy_transform/src/hierarchy/hierarchy.rs +++ b/crates/bevy_transform/src/hierarchy/hierarchy.rs @@ -123,9 +123,8 @@ mod tests { { let children = world.get::(grandparent_entity).unwrap(); - assert_eq!( - children.iter().any(|&i| i == parent_entity), - false, + assert!( + !children.iter().any(|&i| i == parent_entity), "grandparent should no longer know about its child which has been removed" ); } diff --git a/crates/bevy_wgpu/Cargo.toml b/crates/bevy_wgpu/Cargo.toml index 66940cb55a17b..30b4581e99a10 100644 --- a/crates/bevy_wgpu/Cargo.toml +++ b/crates/bevy_wgpu/Cargo.toml @@ -29,7 +29,7 @@ bevy_winit = { path = "../bevy_winit", optional = true, version = "0.5.0" } bevy_utils = { path = "../bevy_utils", version = "0.5.0" } # other -wgpu = "0.8" +wgpu = "0.9" futures-lite = "1.4.0" crossbeam-channel = "0.5.0" crossbeam-utils = "0.8.1" diff --git a/crates/bevy_window/src/raw_window_handle.rs b/crates/bevy_window/src/raw_window_handle.rs index 2393975490f9d..76f1411261c80 100644 --- a/crates/bevy_window/src/raw_window_handle.rs +++ b/crates/bevy_window/src/raw_window_handle.rs @@ -15,7 +15,7 @@ impl RawWindowHandleWrapper { /// have constraints on where/how this handle can be used. For example, some platforms don't support doing window /// operations off of the main thread. The caller must ensure the [`RawWindowHandle`] is only used in valid contexts. pub unsafe fn get_handle(&self) -> HasRawWindowHandleWrapper { - HasRawWindowHandleWrapper(self.0.clone()) + HasRawWindowHandleWrapper(self.0) } } @@ -32,6 +32,6 @@ pub struct HasRawWindowHandleWrapper(RawWindowHandle); // SAFE: the caller has validated that this is a valid context to get RawWindowHandle unsafe impl HasRawWindowHandle for HasRawWindowHandleWrapper { fn raw_window_handle(&self) -> RawWindowHandle { - self.0.clone() + self.0 } } diff --git a/crates/crevice/crevice-derive/src/lib.rs b/crates/crevice/crevice-derive/src/lib.rs index ee7bfe1d3434c..a4fbac11ae8e4 100644 --- a/crates/crevice/crevice-derive/src/lib.rs +++ b/crates/crevice/crevice-derive/src/lib.rs @@ -246,11 +246,7 @@ impl EmitOptions { // For testing purposes, we can optionally generate type layout // information using the type-layout crate. - let type_layout_derive = if cfg!(feature = "test_type_layout") { - quote!(#[derive(::type_layout::TypeLayout)]) - } else { - quote!() - }; + let type_layout_derive = quote!(); quote! { #[allow(non_snake_case)] diff --git a/crates/crevice/src/lib.rs b/crates/crevice/src/lib.rs index 89b7d4fddbeed..076f2c7ce4d78 100644 --- a/crates/crevice/src/lib.rs +++ b/crates/crevice/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::all)] + /*! [![GitHub CI Status](https://github.com/LPGhatguy/crevice/workflows/CI/badge.svg)](https://github.com/LPGhatguy/crevice/actions) [![crevice on crates.io](https://img.shields.io/crates/v/crevice.svg)](https://crates.io/crates/crevice) diff --git a/examples/2d/sprite.rs b/examples/2d/sprite.rs index b71d3b6407f12..1c5e9c8a7c6a5 100644 --- a/examples/2d/sprite.rs +++ b/examples/2d/sprite.rs @@ -9,7 +9,7 @@ fn main() { fn setup( mut commands: Commands, - asset_server: Res, + _asset_server: Res, // mut materials: ResMut>, ) { // let texture_handle = asset_server.load("branding/icon.png"); diff --git a/examples/3d/3d_scene_pipelined.rs b/examples/3d/3d_scene_pipelined.rs index 4f3fe65eb1cea..fc11b15ea5e47 100644 --- a/examples/3d/3d_scene_pipelined.rs +++ b/examples/3d/3d_scene_pipelined.rs @@ -3,12 +3,12 @@ use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, ecs::prelude::*, input::Input, - math::Vec3, + math::{Quat, Vec3}, pbr2::{ - AmbientLight, DirectionalLight, DirectionalLightBundle, OmniLight, OmniLightBundle, - PbrBundle, StandardMaterial, + AmbientLight, DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, + PointLightBundle, StandardMaterial, }, - prelude::{App, Assets, KeyCode, Transform}, + prelude::{App, Assets, BuildChildren, KeyCode, Transform}, render2::{ camera::{OrthographicProjection, PerspectiveCameraBundle}, color::Color, @@ -50,6 +50,32 @@ fn setup( }), ..Default::default() }); + + let mut transform = Transform::from_xyz(2.5, 2.5, 0.0); + transform.rotate(Quat::from_rotation_z(std::f32::consts::FRAC_PI_2)); + commands.spawn_bundle(PbrBundle { + mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })), + transform, + material: materials.add(StandardMaterial { + base_color: Color::INDIGO, + perceptual_roughness: 1.0, + ..Default::default() + }), + ..Default::default() + }); + + let mut transform = Transform::from_xyz(0.0, 2.5, -2.5); + transform.rotate(Quat::from_rotation_x(std::f32::consts::FRAC_PI_2)); + commands.spawn_bundle(PbrBundle { + mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })), + transform, + material: materials.add(StandardMaterial { + base_color: Color::INDIGO, + perceptual_roughness: 1.0, + ..Default::default() + }), + ..Default::default() + }); // cube commands .spawn_bundle(PbrBundle { @@ -77,26 +103,94 @@ fn setup( ..Default::default() }) .insert(Movable); + + // light + commands + .spawn_bundle(PointLightBundle { + // transform: Transform::from_xyz(5.0, 8.0, 2.0), + transform: Transform::from_xyz(1.0, 2.0, 0.0), + point_light: PointLight { + color: Color::RED, + ..Default::default() + }, + ..Default::default() + }) + .with_children(|builder| { + builder.spawn_bundle(PbrBundle { + mesh: meshes.add(Mesh::from(shape::UVSphere { + radius: 0.1, + ..Default::default() + })), + material: materials.add(StandardMaterial { + base_color: Color::RED, + emissive: Color::rgba_linear(100.0, 0.0, 0.0, 0.0), + ..Default::default() + }), + ..Default::default() + }); + }); + // light - commands.spawn_bundle(OmniLightBundle { - omni_light: OmniLight { - color: Color::RED, + commands + .spawn_bundle(PointLightBundle { + // transform: Transform::from_xyz(5.0, 8.0, 2.0), + transform: Transform::from_xyz(-1.0, 2.0, 0.0), + point_light: PointLight { + color: Color::GREEN, + ..Default::default() + }, ..Default::default() - }, - transform: Transform::from_xyz(5.0, 8.0, 2.0), - ..Default::default() - }); - commands.spawn_bundle(OmniLightBundle { - omni_light: OmniLight { - color: Color::GREEN, + }) + .with_children(|builder| { + builder.spawn_bundle(PbrBundle { + mesh: meshes.add(Mesh::from(shape::UVSphere { + radius: 0.1, + ..Default::default() + })), + material: materials.add(StandardMaterial { + base_color: Color::GREEN, + emissive: Color::rgba_linear(0.0, 100.0, 0.0, 0.0), + ..Default::default() + }), + ..Default::default() + }); + }); + + // light + commands + .spawn_bundle(PointLightBundle { + // transform: Transform::from_xyz(5.0, 8.0, 2.0), + transform: Transform::from_xyz(0.0, 4.0, 0.0), + point_light: PointLight { + color: Color::BLUE, + ..Default::default() + }, ..Default::default() - }, - transform: Transform::from_xyz(5.0, 8.0, -2.0), + }) + .with_children(|builder| { + builder.spawn_bundle(PbrBundle { + mesh: meshes.add(Mesh::from(shape::UVSphere { + radius: 0.1, + ..Default::default() + })), + material: materials.add(StandardMaterial { + base_color: Color::BLUE, + emissive: Color::rgba_linear(0.0, 0.0, 100.0, 0.0), + ..Default::default() + }), + ..Default::default() + }); + }); + + // camera + commands.spawn_bundle(PerspectiveCameraBundle { + transform: Transform::from_xyz(-2.0, 5.0, 7.5) + .looking_at(Vec3::new(0.0, 2.0, 0.0), Vec3::Y), ..Default::default() }); - const HALF_SIZE: f32 = 5.0; + const HALF_SIZE: f32 = 10.0; let mut directional_light = DirectionalLight::default(); - directional_light.color = Color::BLUE; + directional_light.color = Color::WHITE; directional_light.shadow_projection = OrthographicProjection { left: -HALF_SIZE, right: HALF_SIZE, diff --git a/examples/3d/pbr_pipelined.rs b/examples/3d/pbr_pipelined.rs index 2aa96016291a5..470326cab3e9d 100644 --- a/examples/3d/pbr_pipelined.rs +++ b/examples/3d/pbr_pipelined.rs @@ -1,7 +1,7 @@ use bevy::{ ecs::prelude::*, math::Vec3, - pbr2::{OmniLight, OmniLightBundle, PbrBundle, StandardMaterial}, + pbr2::{PbrBundle, PointLight, PointLightBundle, StandardMaterial}, prelude::{App, Assets, Transform}, render2::{ camera::{OrthographicCameraBundle, OrthographicProjection}, @@ -64,9 +64,9 @@ fn setup( ..Default::default() }); // light - commands.spawn_bundle(OmniLightBundle { + commands.spawn_bundle(PointLightBundle { transform: Transform::from_translation(Vec3::new(50.0, 50.0, 50.0)), - omni_light: OmniLight { + point_light: PointLight { intensity: 50000., range: 100., ..Default::default() diff --git a/examples/tools/bevymark_pipelined.rs b/examples/tools/bevymark_pipelined.rs index 4789853fe30e1..b2e80850e381e 100644 --- a/examples/tools/bevymark_pipelined.rs +++ b/examples/tools/bevymark_pipelined.rs @@ -13,7 +13,7 @@ use bevy::{ use rand::Rng; const BIRDS_PER_SECOND: u32 = 10000; -const BASE_COLOR: Color = Color::rgb(5.0, 5.0, 5.0); +const _BASE_COLOR: Color = Color::rgb(5.0, 5.0, 5.0); const GRAVITY: f32 = -9.8 * 100.0; const MAX_VELOCITY: f32 = 750.; const BIRD_SCALE: f32 = 0.15; @@ -66,8 +66,8 @@ struct BirdTexture(Handle); fn setup( mut commands: Commands, - window: Res, - mut counter: ResMut, + _window: Res, + _counter: ResMut, asset_server: Res, ) { // spawn_birds(&mut commands, &window, &mut counter, 10); @@ -129,7 +129,7 @@ fn setup( #[allow(clippy::too_many_arguments)] fn mouse_handler( mut commands: Commands, - asset_server: Res, + _asset_server: Res, time: Res