From 8fbb5435bd95d300e3eb76bc2cd8d606095b5a50 Mon Sep 17 00:00:00 2001 From: CGMossa Date: Sun, 3 Jul 2022 19:55:33 +0000 Subject: [PATCH] Updated `glam` to `0.21`. (#5142) Removed `const_vec2`/`const_vec3` and replaced with equivalent `.from_array`. # Objective Fixes #5112 ## Solution - `encase` needs to update to `glam` as well. See teoxoy/encase#4 on progress on that. - `hexasphere` also needs to be updated, see OptimisticPeach/hexasphere#12. --- benches/Cargo.toml | 2 +- crates/bevy_encase_derive/Cargo.toml | 2 +- crates/bevy_input/src/touch.rs | 20 +++++++-------- crates/bevy_math/Cargo.toml | 2 +- crates/bevy_mikktspace/Cargo.toml | 2 +- crates/bevy_pbr/src/light.rs | 12 ++++----- crates/bevy_pbr/src/render/light.rs | 25 ++++++++----------- crates/bevy_reflect/Cargo.toml | 2 +- crates/bevy_reflect/src/lib.rs | 2 +- crates/bevy_render/Cargo.toml | 4 +-- crates/bevy_render/src/color/mod.rs | 6 +++-- crates/bevy_render/src/mesh/mesh/mod.rs | 4 +-- crates/bevy_render/src/mesh/shape/capsule.rs | 2 +- crates/bevy_render/src/render_resource/mod.rs | 2 +- crates/bevy_render/src/texture/image.rs | 2 +- .../bevy_sprite/src/mesh2d/color_material.rs | 2 +- crates/bevy_sprite/src/render/mod.rs | 18 ++++++------- crates/bevy_text/src/font_atlas_set.rs | 2 +- crates/bevy_text/src/pipeline.rs | 2 +- .../src/components/global_transform.rs | 4 +-- .../src/components/transform.rs | 4 +-- crates/bevy_ui/src/render/mod.rs | 10 ++++---- examples/2d/rotation.rs | 8 ++---- examples/games/breakout.rs | 12 ++++----- examples/stress_tests/many_lights.rs | 2 +- 25 files changed, 71 insertions(+), 82 deletions(-) diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 6ba2ad92809fe..16b56eca8cf09 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -7,7 +7,7 @@ publish = false license = "MIT OR Apache-2.0" [dev-dependencies] -glam = "0.20" +glam = "0.21" rand = "0.8" rand_chacha = "0.3" criterion = { version = "0.3", features = ["html_reports"] } diff --git a/crates/bevy_encase_derive/Cargo.toml b/crates/bevy_encase_derive/Cargo.toml index 16e518a573a1d..567edcb88396d 100644 --- a/crates/bevy_encase_derive/Cargo.toml +++ b/crates/bevy_encase_derive/Cargo.toml @@ -13,4 +13,4 @@ proc-macro = true [dependencies] bevy_macro_utils = { path = "../bevy_macro_utils", version = "0.8.0-dev" } -encase_derive_impl = "0.2" +encase_derive_impl = "0.3.0" diff --git a/crates/bevy_input/src/touch.rs b/crates/bevy_input/src/touch.rs index 7333ac2d3eacc..704f7c675a4e6 100644 --- a/crates/bevy_input/src/touch.rs +++ b/crates/bevy_input/src/touch.rs @@ -350,11 +350,11 @@ mod test { let touch_event = Touch { id: 4, - start_position: Vec2::new(0.0, 0.0), + start_position: Vec2::ZERO, start_force: None, - previous_position: Vec2::new(0.0, 0.0), + previous_position: Vec2::ZERO, previous_force: None, - position: Vec2::new(0.0, 0.0), + position: Vec2::ZERO, force: None, }; @@ -383,7 +383,7 @@ mod test { let touch_event = TouchInput { phase: TouchPhase::Started, - position: Vec2::new(4.0, 4.0), + position: Vec2::splat(4.0), force: None, id: 4, }; @@ -398,7 +398,7 @@ mod test { let moved_touch_event = TouchInput { phase: TouchPhase::Moved, - position: Vec2::new(5.0, 5.0), + position: Vec2::splat(5.0), force: None, id: touch_event.id, }; @@ -419,7 +419,7 @@ mod test { let cancel_touch_event = TouchInput { phase: TouchPhase::Cancelled, - position: Vec2::new(1.0, 1.0), + position: Vec2::ONE, force: None, id: touch_event.id, }; @@ -434,7 +434,7 @@ mod test { let end_touch_event = TouchInput { phase: TouchPhase::Ended, - position: Vec2::new(4.0, 4.0), + position: Vec2::splat(4.0), force: None, id: 4, }; @@ -456,7 +456,7 @@ mod test { let touch_event = TouchInput { phase: TouchPhase::Started, - position: Vec2::new(4.0, 4.0), + position: Vec2::splat(4.0), force: None, id: 4, }; @@ -478,7 +478,7 @@ mod test { let touch_event = TouchInput { phase: TouchPhase::Ended, - position: Vec2::new(4.0, 4.0), + position: Vec2::splat(4.0), force: None, id: 4, }; @@ -500,7 +500,7 @@ mod test { let touch_event = TouchInput { phase: TouchPhase::Cancelled, - position: Vec2::new(4.0, 4.0), + position: Vec2::splat(4.0), force: None, id: 4, }; diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml index 7282150298258..79dc9e0deda33 100644 --- a/crates/bevy_math/Cargo.toml +++ b/crates/bevy_math/Cargo.toml @@ -9,4 +9,4 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [dependencies] -glam = { version = "0.20.0", features = ["serde", "bytemuck"] } +glam = { version = "0.21", features = ["serde", "bytemuck"] } diff --git a/crates/bevy_mikktspace/Cargo.toml b/crates/bevy_mikktspace/Cargo.toml index c456b3008850f..88276f2caae1f 100644 --- a/crates/bevy_mikktspace/Cargo.toml +++ b/crates/bevy_mikktspace/Cargo.toml @@ -11,7 +11,7 @@ license = "Zlib AND (MIT OR Apache-2.0)" keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"] [dependencies] -glam = "0.20.0" +glam = "0.21" [[example]] name = "generate" diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index 575c926b4ce40..e5eb283c7db05 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -1,9 +1,7 @@ use std::collections::HashSet; use bevy_ecs::prelude::*; -use bevy_math::{ - const_vec2, Mat4, UVec2, UVec3, Vec2, Vec3, Vec3A, Vec3Swizzles, Vec4, Vec4Swizzles, -}; +use bevy_math::{Mat4, UVec2, UVec3, Vec2, Vec3, Vec3A, Vec3Swizzles, Vec4, Vec4Swizzles}; use bevy_reflect::prelude::*; use bevy_render::{ camera::{Camera, CameraProjection, OrthographicProjection}, @@ -497,8 +495,8 @@ fn ndc_position_to_cluster( .clamp(UVec3::ZERO, cluster_dimensions - UVec3::ONE) } -const VEC2_HALF: Vec2 = const_vec2!([0.5, 0.5]); -const VEC2_HALF_NEGATIVE_Y: Vec2 = const_vec2!([0.5, -0.5]); +const VEC2_HALF: Vec2 = Vec2::splat(0.5); +const VEC2_HALF_NEGATIVE_Y: Vec2 = Vec2::new(0.5, -0.5); // Calculate bounds for the light using a view space aabb. // Returns a (Vec3, Vec3) containing min and max with @@ -587,8 +585,8 @@ fn cluster_space_light_aabb( ) } -const NDC_MIN: Vec2 = const_vec2!([-1.0, -1.0]); -const NDC_MAX: Vec2 = const_vec2!([1.0, 1.0]); +const NDC_MIN: Vec2 = Vec2::NEG_ONE; +const NDC_MAX: Vec2 = Vec2::ONE; // Sort point lights with shadows enabled first, then by a stable key so that the index // can be used to limit the number of point light shadows to render based on the device and diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 2509cff2554e2..ab21a62758b5d 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -9,7 +9,7 @@ use bevy_ecs::{ prelude::*, system::{lifetimeless::*, SystemParamItem}, }; -use bevy_math::{const_vec3, Mat4, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles}; +use bevy_math::{Mat4, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4, Vec4Swizzles}; use bevy_render::{ camera::{Camera, CameraProjection}, color::Color, @@ -501,11 +501,6 @@ pub fn extract_lights( pub(crate) const POINT_LIGHT_NEAR_Z: f32 = 0.1f32; -// Can't do `Vec3::Y * -1.0` because mul isn't const -const NEGATIVE_X: Vec3 = const_vec3!([-1.0, 0.0, 0.0]); -const NEGATIVE_Y: Vec3 = const_vec3!([0.0, -1.0, 0.0]); -const NEGATIVE_Z: Vec3 = const_vec3!([0.0, 0.0, -1.0]); - pub(crate) struct CubeMapFace { pub(crate) target: Vec3, pub(crate) up: Vec3, @@ -515,33 +510,33 @@ pub(crate) struct CubeMapFace { pub(crate) const CUBE_MAP_FACES: [CubeMapFace; 6] = [ // 0 GL_TEXTURE_CUBE_MAP_POSITIVE_X CubeMapFace { - target: NEGATIVE_X, - up: NEGATIVE_Y, + target: Vec3::NEG_X, + up: Vec3::NEG_Y, }, // 1 GL_TEXTURE_CUBE_MAP_NEGATIVE_X CubeMapFace { target: Vec3::X, - up: NEGATIVE_Y, + up: Vec3::NEG_Y, }, // 2 GL_TEXTURE_CUBE_MAP_POSITIVE_Y CubeMapFace { - target: NEGATIVE_Y, + target: Vec3::NEG_Y, up: Vec3::Z, }, // 3 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y CubeMapFace { target: Vec3::Y, - up: NEGATIVE_Z, + up: Vec3::NEG_Z, }, // 4 GL_TEXTURE_CUBE_MAP_POSITIVE_Z CubeMapFace { - target: NEGATIVE_Z, - up: NEGATIVE_Y, + target: Vec3::NEG_Z, + up: Vec3::NEG_Y, }, // 5 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z CubeMapFace { target: Vec3::Z, - up: NEGATIVE_Y, + up: Vec3::NEG_Y, }, ]; @@ -1016,7 +1011,7 @@ struct GpuClusterLightIndexListsUniform { // NOTE: Assert at compile time that GpuClusterLightIndexListsUniform // fits within the maximum uniform buffer binding size -const _: () = assert!(GpuClusterLightIndexListsUniform::SIZE.get() <= 16384); +const _: () = assert!(GpuClusterLightIndexListsUniform::SHADER_SIZE.get() <= 16384); impl Default for GpuClusterLightIndexListsUniform { fn default() -> Self { diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index e520f45b6c515..bc2af4179d945 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -25,7 +25,7 @@ thiserror = "1.0" once_cell = "1.11" serde = "1" smallvec = { version = "1.6", features = ["serde", "union", "const_generics"], optional = true } -glam = { version = "0.20.0", features = ["serde"], optional = true } +glam = { version = "0.21", features = ["serde"], optional = true } [dev-dependencies] ron = "0.7.0" diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 8c2927d8f359d..927aafe4cc834 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -922,7 +922,7 @@ bevy_reflect::tests::should_reflect_debug::Test { assert_eq!( result, - r#"{"type":"glam::vec3::Vec3","struct":{"x":{"type":"f32","value":12.0},"y":{"type":"f32","value":3.0},"z":{"type":"f32","value":-6.9}}}"# + r#"{"type":"glam::f32::vec3::Vec3","struct":{"x":{"type":"f32","value":12.0},"y":{"type":"f32","value":3.0},"z":{"type":"f32","value":-6.9}}}"# ); } diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 879dbbbf9af9d..9d0f6e11973a3 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -59,7 +59,7 @@ thiserror = "1.0" futures-lite = "1.4.0" anyhow = "1.0" hex = "0.4.2" -hexasphere = "7.0.0" +hexasphere = "7.2" parking_lot = "0.11.0" regex = "1.5" copyless = "0.1.5" @@ -70,4 +70,4 @@ flate2 = { version = "1.0.22", optional = true } ruzstd = { version = "0.2.4", optional = true } # For transcoding of UASTC/ETC1S universal formats, and for .basis file support basis-universal = { version = "0.2.0", optional = true } -encase = { version = "0.2", features = ["glam"] } +encase = { version = "0.3", features = ["glam"] } diff --git a/crates/bevy_render/src/color/mod.rs b/crates/bevy_render/src/color/mod.rs index 77bf75bb81769..6bc355f1eeb83 100644 --- a/crates/bevy_render/src/color/mod.rs +++ b/crates/bevy_render/src/color/mod.rs @@ -1153,7 +1153,9 @@ impl encase::ShaderType for Color { type ExtraMetadata = (); const METADATA: encase::private::Metadata = { - let size = encase::private::SizeValue::from(::SIZE).mul(4); + let size = + encase::private::SizeValue::from(::SHADER_SIZE) + .mul(4); let alignment = encase::private::AlignmentValue::from_next_power_of_two_size(size); encase::private::Metadata { @@ -1214,7 +1216,7 @@ impl encase::private::CreateFrom for Color { } } -impl encase::Size for Color {} +impl encase::ShaderSize for Color {} #[derive(Debug, Error)] pub enum HexColorError { diff --git a/crates/bevy_render/src/mesh/mesh/mod.rs b/crates/bevy_render/src/mesh/mesh/mod.rs index 3193ebb5d1a09..b4fecc066ddb6 100644 --- a/crates/bevy_render/src/mesh/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mesh/mod.rs @@ -505,8 +505,8 @@ struct MeshAttributeData { values: VertexAttributeValues, } -const VEC3_MIN: Vec3 = const_vec3!([std::f32::MIN, std::f32::MIN, std::f32::MIN]); -const VEC3_MAX: Vec3 = const_vec3!([std::f32::MAX, std::f32::MAX, std::f32::MAX]); +const VEC3_MIN: Vec3 = Vec3::splat(std::f32::MIN); +const VEC3_MAX: Vec3 = Vec3::splat(std::f32::MAX); fn face_normal(a: [f32; 3], b: [f32; 3], c: [f32; 3]) -> [f32; 3] { let (a, b, c) = (Vec3::from(a), Vec3::from(b), Vec3::from(c)); diff --git a/crates/bevy_render/src/mesh/shape/capsule.rs b/crates/bevy_render/src/mesh/shape/capsule.rs index 06965c09fbef5..71ceb1627bd65 100644 --- a/crates/bevy_render/src/mesh/shape/capsule.rs +++ b/crates/bevy_render/src/mesh/shape/capsule.rs @@ -118,7 +118,7 @@ impl From for Mesh { // North. vs[j] = Vec3::new(0.0, summit, 0.0); vts[j] = Vec2::new(s_texture_polar, 1.0); - vns[j] = Vec3::new(0.0, 1.0, 0.0); + vns[j] = Vec3::Y; // South. let idx = vert_offset_south_cap + j; diff --git a/crates/bevy_render/src/render_resource/mod.rs b/crates/bevy_render/src/render_resource/mod.rs index c09566f71604b..a0206b1c7f233 100644 --- a/crates/bevy_render/src/render_resource/mod.rs +++ b/crates/bevy_render/src/render_resource/mod.rs @@ -49,6 +49,6 @@ pub mod encase { pub use encase::*; } -pub use self::encase::{ShaderType, Size as ShaderSize}; +pub use self::encase::{ShaderSize, ShaderType}; pub use naga::ShaderStage; diff --git a/crates/bevy_render/src/texture/image.rs b/crates/bevy_render/src/texture/image.rs index 336e647d28382..589e8667497b8 100644 --- a/crates/bevy_render/src/texture/image.rs +++ b/crates/bevy_render/src/texture/image.rs @@ -798,6 +798,6 @@ mod test { #[test] fn image_default_size() { let image = Image::default(); - assert_eq!(Vec2::new(1.0, 1.0), image.size()); + assert_eq!(Vec2::ONE, image.size()); } } diff --git a/crates/bevy_sprite/src/mesh2d/color_material.rs b/crates/bevy_sprite/src/mesh2d/color_material.rs index 0721b1a0a607d..daa83be3afa01 100644 --- a/crates/bevy_sprite/src/mesh2d/color_material.rs +++ b/crates/bevy_sprite/src/mesh2d/color_material.rs @@ -143,7 +143,7 @@ impl RenderAsset for ColorMaterial { flags: flags.bits(), }; - let byte_buffer = [0u8; ColorMaterialUniformData::SIZE.get() as usize]; + let byte_buffer = [0u8; ColorMaterialUniformData::SHADER_SIZE.get() as usize]; let mut buffer = encase::UniformBuffer::new(byte_buffer); buffer.write(&value).unwrap(); diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 2c51bb8f5ad47..1c3d39dbeaf59 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -10,7 +10,7 @@ use bevy_ecs::{ prelude::*, system::{lifetimeless::*, SystemParamItem}, }; -use bevy_math::{const_vec2, Vec2}; +use bevy_math::Vec2; use bevy_reflect::Uuid; use bevy_render::{ color::Color, @@ -307,17 +307,17 @@ impl Default for SpriteMeta { const QUAD_INDICES: [usize; 6] = [0, 2, 3, 0, 1, 2]; const QUAD_VERTEX_POSITIONS: [Vec2; 4] = [ - const_vec2!([-0.5, -0.5]), - const_vec2!([0.5, -0.5]), - const_vec2!([0.5, 0.5]), - const_vec2!([-0.5, 0.5]), + Vec2::new(-0.5, -0.5), + Vec2::new(0.5, -0.5), + Vec2::new(0.5, 0.5), + Vec2::new(-0.5, 0.5), ]; const QUAD_UVS: [Vec2; 4] = [ - const_vec2!([0., 1.]), - const_vec2!([1., 1.]), - const_vec2!([1., 0.]), - const_vec2!([0., 0.]), + Vec2::new(0., 1.), + Vec2::new(1., 1.), + Vec2::new(1., 0.), + Vec2::new(0., 0.), ]; #[derive(Component, Eq, PartialEq, Copy, Clone)] diff --git a/crates/bevy_text/src/font_atlas_set.rs b/crates/bevy_text/src/font_atlas_set.rs index 4549f474bf515..655ad7ccf3755 100644 --- a/crates/bevy_text/src/font_atlas_set.rs +++ b/crates/bevy_text/src/font_atlas_set.rs @@ -62,7 +62,7 @@ impl FontAtlasSet { vec![FontAtlas::new( textures, texture_atlases, - Vec2::new(512.0, 512.0), + Vec2::splat(512.0), )] }); let glyph_texture = Font::get_outlined_glyph_texture(outlined_glyph); diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index 60196fe2787ce..bd7b0007cb82e 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -92,7 +92,7 @@ impl TextPipeline { id, TextLayoutInfo { glyphs: Vec::new(), - size: Vec2::new(0., 0.), + size: Vec2::ZERO, }, ); return Ok(()); diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index be1d75cfcb46b..e687beab8cbf9 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -1,6 +1,6 @@ use super::Transform; use bevy_ecs::{component::Component, reflect::ReflectComponent}; -use bevy_math::{const_vec3, Affine3A, Mat3, Mat4, Quat, Vec3}; +use bevy_math::{Affine3A, Mat3, Mat4, Quat, Vec3}; use bevy_reflect::prelude::*; use std::ops::Mul; @@ -39,7 +39,7 @@ impl GlobalTransform { #[doc(hidden)] #[inline] pub const fn from_xyz(x: f32, y: f32, z: f32) -> Self { - Self::from_translation(const_vec3!([x, y, z])) + Self::from_translation(Vec3::new(x, y, z)) } /// Creates a new identity [`GlobalTransform`], with no translation, rotation, and a scale of 1 diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index a26793391dc5e..3ef0c9280facd 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -1,6 +1,6 @@ use super::GlobalTransform; use bevy_ecs::{component::Component, reflect::ReflectComponent}; -use bevy_math::{const_vec3, Mat3, Mat4, Quat, Vec3}; +use bevy_math::{Mat3, Mat4, Quat, Vec3}; use bevy_reflect::prelude::*; use bevy_reflect::Reflect; use std::ops::Mul; @@ -43,7 +43,7 @@ impl Transform { /// `z`-value. #[inline] pub const fn from_xyz(x: f32, y: f32, z: f32) -> Self { - Self::from_translation(const_vec3!([x, y, z])) + Self::from_translation(Vec3::new(x, y, z)) } /// Creates a new identity [`Transform`], with no translation, rotation, and a scale of 1 on diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 598dd10eaa866..43469a71efcb3 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -9,7 +9,7 @@ use crate::{prelude::CameraUi, CalculatedClip, Node, UiColor, UiImage}; use bevy_app::prelude::*; use bevy_asset::{load_internal_asset, AssetEvent, Assets, Handle, HandleUntyped}; use bevy_ecs::prelude::*; -use bevy_math::{const_vec3, Mat4, Vec2, Vec3, Vec4Swizzles}; +use bevy_math::{Mat4, Vec2, Vec3, Vec4Swizzles}; use bevy_reflect::TypeUuid; use bevy_render::{ camera::{Camera, CameraProjection, DepthCalculation, OrthographicProjection, WindowOrigin}, @@ -353,10 +353,10 @@ impl Default for UiMeta { } const QUAD_VERTEX_POSITIONS: [Vec3; 4] = [ - const_vec3!([-0.5, -0.5, 0.0]), - const_vec3!([0.5, -0.5, 0.0]), - const_vec3!([0.5, 0.5, 0.0]), - const_vec3!([-0.5, 0.5, 0.0]), + Vec3::new(-0.5, -0.5, 0.0), + Vec3::new(0.5, -0.5, 0.0), + Vec3::new(0.5, 0.5, 0.0), + Vec3::new(-0.5, 0.5, 0.0), ]; const QUAD_INDICES: [usize; 6] = [0, 2, 3, 0, 1, 2]; diff --git a/examples/2d/rotation.rs b/examples/2d/rotation.rs index 846befa857f8a..191ee57573cc1 100644 --- a/examples/2d/rotation.rs +++ b/examples/2d/rotation.rs @@ -1,13 +1,9 @@ //! Demonstrates rotating entities in 2D using quaternions. -use bevy::{ - math::{const_vec2, Vec3Swizzles}, - prelude::*, - time::FixedTimestep, -}; +use bevy::{math::Vec3Swizzles, prelude::*, time::FixedTimestep}; const TIME_STEP: f32 = 1.0 / 60.0; -const BOUNDS: Vec2 = const_vec2!([1200.0, 640.0]); +const BOUNDS: Vec2 = Vec2::new(1200.0, 640.0); fn main() { App::new() diff --git a/examples/games/breakout.rs b/examples/games/breakout.rs index 92391e43775df..c67e2f004e052 100644 --- a/examples/games/breakout.rs +++ b/examples/games/breakout.rs @@ -1,7 +1,6 @@ //! A simplified implementation of the classic game "Breakout". use bevy::{ - math::{const_vec2, const_vec3}, prelude::*, sprite::collide_aabb::{collide, Collision}, time::FixedTimestep, @@ -12,18 +11,17 @@ const TIME_STEP: f32 = 1.0 / 60.0; // These constants are defined in `Transform` units. // Using the default 2D camera they correspond 1:1 with screen pixels. -// The `const_vec3!` macros are needed as functions that operate on floats cannot be constant in Rust. -const PADDLE_SIZE: Vec3 = const_vec3!([120.0, 20.0, 0.0]); +const PADDLE_SIZE: Vec3 = Vec3::new(120.0, 20.0, 0.0); const GAP_BETWEEN_PADDLE_AND_FLOOR: f32 = 60.0; const PADDLE_SPEED: f32 = 500.0; // How close can the paddle get to the wall const PADDLE_PADDING: f32 = 10.0; // We set the z-value of the ball to 1 so it renders on top in the case of overlapping sprites. -const BALL_STARTING_POSITION: Vec3 = const_vec3!([0.0, -50.0, 1.0]); -const BALL_SIZE: Vec3 = const_vec3!([30.0, 30.0, 0.0]); +const BALL_STARTING_POSITION: Vec3 = Vec3::new(0.0, -50.0, 1.0); +const BALL_SIZE: Vec3 = Vec3::new(30.0, 30.0, 0.0); const BALL_SPEED: f32 = 400.0; -const INITIAL_BALL_DIRECTION: Vec2 = const_vec2!([0.5, -0.5]); +const INITIAL_BALL_DIRECTION: Vec2 = Vec2::new(0.5, -0.5); const WALL_THICKNESS: f32 = 10.0; // x coordinates @@ -33,7 +31,7 @@ const RIGHT_WALL: f32 = 450.; const BOTTOM_WALL: f32 = -300.; const TOP_WALL: f32 = 300.; -const BRICK_SIZE: Vec2 = const_vec2!([100., 30.]); +const BRICK_SIZE: Vec2 = Vec2::new(100., 30.); // These values are exact const GAP_BETWEEN_PADDLE_AND_BRICKS: f32 = 270.0; const GAP_BETWEEN_BRICKS: f32 = 5.0; diff --git a/examples/stress_tests/many_lights.rs b/examples/stress_tests/many_lights.rs index 3a6c75b107dee..f215081eb8fe3 100644 --- a/examples/stress_tests/many_lights.rs +++ b/examples/stress_tests/many_lights.rs @@ -45,7 +45,7 @@ fn setup( subdivisions: 9, })), material: materials.add(StandardMaterial::from(Color::WHITE)), - transform: Transform::from_scale(Vec3::splat(-1.0)), + transform: Transform::from_scale(Vec3::NEG_ONE), ..default() });