diff --git a/crates/bevy_core/src/bytes.rs b/crates/bevy_core/src/bytes.rs index efcbdf26fb40e..495cc64c41ca3 100644 --- a/crates/bevy_core/src/bytes.rs +++ b/crates/bevy_core/src/bytes.rs @@ -231,6 +231,6 @@ mod tests { #[test] fn test_mat4_round_trip() { - test_round_trip(Mat4::identity()); + test_round_trip(Mat4::IDENTITY); } } diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml index 499a418d81ba4..57dba897ba2f5 100644 --- a/crates/bevy_math/Cargo.toml +++ b/crates/bevy_math/Cargo.toml @@ -13,5 +13,5 @@ license = "MIT" keywords = ["bevy"] [dependencies] -glam = { version = "0.12.0", features = ["serde"] } +glam = { version = "0.13.0", features = ["serde"] } bevy_reflect = { path = "../bevy_reflect", version = "0.4.0", features = ["bevy"] } diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index d48e78918e70e..764818f55b968 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -28,7 +28,7 @@ parking_lot = "0.11.0" thiserror = "1.0" serde = "1" smallvec = { version = "1.4", features = ["serde"], optional = true } -glam = { version = "0.12.0", features = ["serde"], optional = true } +glam = { version = "0.13.0", features = ["serde"], optional = true } [dev-dependencies] ron = "0.6.2" diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 90762c1423c46..34e7c515cebf4 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -52,13 +52,13 @@ impl Camera { // Build a transform to convert from world to NDC using camera data let world_to_ndc: Mat4 = self.projection_matrix * camera_transform.compute_matrix().inverse(); - let ndc_space_coords: Vec3 = world_to_ndc.transform_point3(world_position); + let ndc_space_coords: Vec3 = world_to_ndc.project_point3(world_position); // NDC z-values outside of 0 < z < 1 are behind the camera and are thus not in screen space if ndc_space_coords.z < 0.0 || ndc_space_coords.z > 1.0 { return None; } // Once in NDC space, we can discard the z element and rescale x/y to fit the screen - let screen_space_coords = (ndc_space_coords.truncate() + Vec2::one()) / 2.0 * window_size; + let screen_space_coords = (ndc_space_coords.truncate() + Vec2::ONE) / 2.0 * window_size; Some(screen_space_coords) } } diff --git a/crates/bevy_render/src/mesh/shape/torus.rs b/crates/bevy_render/src/mesh/shape/torus.rs index 830e9738a56a4..e1eedbdeb1e8c 100644 --- a/crates/bevy_render/src/mesh/shape/torus.rs +++ b/crates/bevy_render/src/mesh/shape/torus.rs @@ -48,7 +48,7 @@ impl From for Mesh { let z = theta.sin() * (torus.radius + torus.ring_radius * phi.cos()); let y = torus.ring_radius * phi.sin(); - let normal = segment_pos.cross(Vec3::unit_y()).normalize(); + let normal = segment_pos.cross(Vec3::Y).normalize(); positions.push([x, y, z]); normals.push(normal.into()); diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 5c9112181f5e3..bfa5a3efbae5e 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -96,14 +96,14 @@ pub fn draw_text2d_system( if let Some(text_glyphs) = text_pipeline.get_glyphs(&entity) { let position = global_transform.translation + match text.alignment.vertical { - VerticalAlign::Top => Vec3::zero(), + VerticalAlign::Top => Vec3::ZERO, VerticalAlign::Center => Vec3::new(0.0, -height * 0.5, 0.0), VerticalAlign::Bottom => Vec3::new(0.0, -height, 0.0), } + match text.alignment.horizontal { HorizontalAlign::Left => Vec3::new(-width, 0.0, 0.0), HorizontalAlign::Center => Vec3::new(-width * 0.5, 0.0, 0.0), - HorizontalAlign::Right => Vec3::zero(), + HorizontalAlign::Right => Vec3::ZERO, }; let mut drawable_text = DrawableText { diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index b232b45f4e5a6..803136cd783a5 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -22,9 +22,9 @@ impl GlobalTransform { #[inline] pub fn identity() -> Self { GlobalTransform { - translation: Vec3::zero(), - rotation: Quat::identity(), - scale: Vec3::one(), + translation: Vec3::ZERO, + rotation: Quat::IDENTITY, + scale: Vec3::ONE, } } @@ -78,19 +78,19 @@ impl GlobalTransform { #[inline] /// Get the unit vector in the local x direction pub fn local_x(&self) -> Vec3 { - self.rotation * Vec3::unit_x() + self.rotation * Vec3::X } #[inline] /// Get the unit vector in the local y direction pub fn local_y(&self) -> Vec3 { - self.rotation * Vec3::unit_y() + self.rotation * Vec3::Y } #[inline] /// Get the unit vector in the local z direction pub fn local_z(&self) -> Vec3 { - self.rotation * Vec3::unit_z() + self.rotation * Vec3::Z } #[inline] diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index 731ef35cacafa..67335c5aa460a 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -22,9 +22,9 @@ impl Transform { #[inline] pub fn identity() -> Self { Transform { - translation: Vec3::zero(), - rotation: Quat::identity(), - scale: Vec3::one(), + translation: Vec3::ZERO, + rotation: Quat::IDENTITY, + scale: Vec3::ONE, } } @@ -78,19 +78,19 @@ impl Transform { #[inline] /// Get the unit vector in the local x direction pub fn local_x(&self) -> Vec3 { - self.rotation * Vec3::unit_x() + self.rotation * Vec3::X } #[inline] /// Get the unit vector in the local y direction pub fn local_y(&self) -> Vec3 { - self.rotation * Vec3::unit_y() + self.rotation * Vec3::Y } #[inline] /// Get the unit vector in the local z direction pub fn local_z(&self) -> Vec3 { - self.rotation * Vec3::unit_z() + self.rotation * Vec3::Z } #[inline] diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index 7567dc4cc9538..63af512e73727 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -36,8 +36,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs index 71e1631627938..67ae293af337c 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -17,7 +17,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }) .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(0.7, 0.7, 1.0) - .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()), + .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), ..Default::default() }); } diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index d0c97441f049b..61180e25974dd 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -32,8 +32,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(-3.0, 3.0, 5.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(-3.0, 3.0, 5.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/3d/orthographic.rs b/examples/3d/orthographic.rs index c609b5d024030..caaaf42a16bf4 100644 --- a/examples/3d/orthographic.rs +++ b/examples/3d/orthographic.rs @@ -17,7 +17,7 @@ fn setup( // set up the camera let mut camera = OrthographicCameraBundle::new_3d(); camera.orthographic_projection.scale = 3.0; - camera.transform = Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::zero(), Vec3::unit_y()); + camera.transform = Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y); // add entities to the world commands diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index 11cc023bf3ee0..3f170c54fe2ad 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -58,8 +58,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(5.0, 10.0, 10.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/3d/spawner.rs b/examples/3d/spawner.rs index 1433abb984ed3..4bce18b3eadde 100644 --- a/examples/3d/spawner.rs +++ b/examples/3d/spawner.rs @@ -44,8 +44,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(0.0, 15.0, 150.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(0.0, 15.0, 150.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index 008ee92a748b1..c7220c2a2c9b9 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -96,8 +96,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(3.0, 5.0, 8.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(3.0, 5.0, 8.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/3d/update_gltf_scene.rs b/examples/3d/update_gltf_scene.rs index fd04e60e3bd50..c1716110a6c2e 100644 --- a/examples/3d/update_gltf_scene.rs +++ b/examples/3d/update_gltf_scene.rs @@ -31,7 +31,7 @@ fn setup( }) .spawn(PerspectiveCameraBundle { transform: Transform::from_xyz(1.05, 0.9, 1.5) - .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()), + .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), ..Default::default() }); diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index be0b554dae124..797ca0d31224a 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -52,8 +52,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/3d/z_sort_debug.rs b/examples/3d/z_sort_debug.rs index 0abc3000947db..c870925e610ef 100644 --- a/examples/3d/z_sort_debug.rs +++ b/examples/3d/z_sort_debug.rs @@ -83,8 +83,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(5.0, 10.0, 10.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/android/android.rs b/examples/android/android.rs index b04045497f0c4..a24881c6656f4 100644 --- a/examples/android/android.rs +++ b/examples/android/android.rs @@ -38,8 +38,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 25fe86c2597b1..519052f2f2bb5 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -71,8 +71,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(0.0, 3.0, 10.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(0.0, 3.0, 10.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/asset/hot_asset_reloading.rs b/examples/asset/hot_asset_reloading.rs index e80d365296c71..bb9148c8f5352 100644 --- a/examples/asset/hot_asset_reloading.rs +++ b/examples/asset/hot_asset_reloading.rs @@ -31,8 +31,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(2.0, 2.0, 6.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(2.0, 2.0, 6.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/game/alien_cake_addict.rs b/examples/game/alien_cake_addict.rs index 1d1d306169aec..3c50a992a6b4a 100644 --- a/examples/game/alien_cake_addict.rs +++ b/examples/game/alien_cake_addict.rs @@ -109,7 +109,7 @@ fn setup_cameras(mut commands: Commands, mut game: ResMut) { 2.0 * BOARD_SIZE_J as f32 / 3.0, BOARD_SIZE_J as f32 / 2.0 - 0.5, ) - .looking_at(game.camera_is_focus, Vec3::unit_y()), + .looking_at(game.camera_is_focus, Vec3::Y), ..Default::default() }) .spawn(UiCameraBundle::default()); @@ -301,7 +301,7 @@ fn focus_camera( // look at that new camera's actual focus for (mut transform, camera) in transforms.q0_mut().iter_mut() { if camera.name == Some(CAMERA_3D.to_string()) { - *transform = transform.looking_at(game.camera_is_focus, Vec3::unit_y()); + *transform = transform.looking_at(game.camera_is_focus, Vec3::Y); } } } diff --git a/examples/ios/src/lib.rs b/examples/ios/src/lib.rs index 0f7aa3090e004..eb11c9a56bbee 100644 --- a/examples/ios/src/lib.rs +++ b/examples/ios/src/lib.rs @@ -53,8 +53,7 @@ fn setup( }) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/shader/array_texture.rs b/examples/shader/array_texture.rs index cd639971fdb32..3dbbe9ed81a41 100644 --- a/examples/shader/array_texture.rs +++ b/examples/shader/array_texture.rs @@ -110,7 +110,7 @@ fn setup( .unwrap(); commands.spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/shader/hot_shader_reloading.rs b/examples/shader/hot_shader_reloading.rs index e878ded13b1c5..28e1937c591ad 100644 --- a/examples/shader/hot_shader_reloading.rs +++ b/examples/shader/hot_shader_reloading.rs @@ -73,8 +73,7 @@ fn setup( .with(material) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(3.0, 5.0, -8.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/shader/mesh_custom_attribute.rs b/examples/shader/mesh_custom_attribute.rs index d681feb30be0c..42bac14cf63fd 100644 --- a/examples/shader/mesh_custom_attribute.rs +++ b/examples/shader/mesh_custom_attribute.rs @@ -138,8 +138,7 @@ fn setup( .with(material) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(3.0, 5.0, -8.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/shader/shader_custom_material.rs b/examples/shader/shader_custom_material.rs index 92eb9383d033b..b5d2323c90da6 100644 --- a/examples/shader/shader_custom_material.rs +++ b/examples/shader/shader_custom_material.rs @@ -94,8 +94,7 @@ fn setup( .with(material) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(3.0, 5.0, -8.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/shader/shader_defs.rs b/examples/shader/shader_defs.rs index 9b1ee60bba56d..f14241f3c4264 100644 --- a/examples/shader/shader_defs.rs +++ b/examples/shader/shader_defs.rs @@ -125,8 +125,7 @@ fn setup( .with(blue_material) // camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(3.0, 5.0, -8.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); } diff --git a/examples/window/multiple_windows.rs b/examples/window/multiple_windows.rs index 52e36d921a067..923b41f51f421 100644 --- a/examples/window/multiple_windows.rs +++ b/examples/window/multiple_windows.rs @@ -190,8 +190,7 @@ fn setup_pipeline( }) // main camera .spawn(PerspectiveCameraBundle { - transform: Transform::from_xyz(0.0, 0.0, 6.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(0.0, 0.0, 6.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }) // second window camera @@ -201,8 +200,7 @@ fn setup_pipeline( window: window_id, ..Default::default() }, - transform: Transform::from_xyz(6.0, 0.0, 0.0) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(6.0, 0.0, 0.0).looking_at(Vec3::default(), Vec3::Y), ..Default::default() }); }