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 a4f7c9c364f59..6322db13e52fb 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -30,7 +30,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 bebbb39c87675..6f3f694e48db0 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -46,13 +46,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 52b146b843078..c033ea930dde7 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -91,14 +91,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 bb0d5b6105614..63d1c46ae5d2f 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -21,9 +21,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, } } @@ -77,19 +77,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 d09c0bd247c82..3c33d8f0a25fb 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -21,9 +21,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, } } @@ -77,19 +77,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 0d90a55ada4bf..e0a5e7cb507ff 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 de2539c49e6ba..68b5afcc69b37 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -17,7 +17,7 @@ fn setup(commands: &mut 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 3df110f66cd16..d32c6745a5286 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 82c3ee09d3245..2bf992505ce69 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 76bc9ec918791..b4613f13236b7 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 978aaec3663c5..509406e186a53 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 32d0a929d9073..93d46b6484f30 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 e8d37707fcf2e..664b16db576df 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 51e9e8c292014..0737afdb69ce0 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 dc72199bba8de..1faa4ceb419c4 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 51af3e855bd6b..c3eec9d677e24 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 3f8407ca6a5ca..d4d88c0276d29 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 b27ba6de82106..05fe82e893493 100644 --- a/examples/asset/hot_asset_reloading.rs +++ b/examples/asset/hot_asset_reloading.rs @@ -31,8 +31,7 @@ fn setup(commands: &mut 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 dfa34bd448a18..9885efeb20b71 100644 --- a/examples/game/alien_cake_addict.rs +++ b/examples/game/alien_cake_addict.rs @@ -109,7 +109,7 @@ fn setup_cameras(commands: &mut 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 cbc8fe9b2ca1a..983f2d759044b 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 43912ab0853fb..a58621b2eaaa2 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 6f675224a4a9e..a12a25acd85a8 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 6d0d2ca09e295..778325acded01 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 dc02029f37709..0c25563306f8f 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 383ffd04e2229..25d131bac38f7 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 34c868f128734..29fa869930b7f 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() }); }