Skip to content

Commit f61e44d

Browse files
bitshifterCameron Hart
and
Cameron Hart
committed
Update glam to 0.13.0. (#1550)
See https://github.com/bitshifter/glam-rs/blob/master/CHANGELOG.md for details on changes. Co-authored-by: Cameron Hart <[email protected]>
1 parent 0eba5f3 commit f61e44d

29 files changed

+43
-60
lines changed

crates/bevy_core/src/bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,6 @@ mod tests {
231231

232232
#[test]
233233
fn test_mat4_round_trip() {
234-
test_round_trip(Mat4::identity());
234+
test_round_trip(Mat4::IDENTITY);
235235
}
236236
}

crates/bevy_math/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ license = "MIT"
1313
keywords = ["bevy"]
1414

1515
[dependencies]
16-
glam = { version = "0.12.0", features = ["serde"] }
16+
glam = { version = "0.13.0", features = ["serde"] }
1717
bevy_reflect = { path = "../bevy_reflect", version = "0.4.0", features = ["bevy"] }

crates/bevy_reflect/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ parking_lot = "0.11.0"
2828
thiserror = "1.0"
2929
serde = "1"
3030
smallvec = { version = "1.4", features = ["serde"], optional = true }
31-
glam = { version = "0.12.0", features = ["serde"], optional = true }
31+
glam = { version = "0.13.0", features = ["serde"], optional = true }
3232

3333
[dev-dependencies]
3434
ron = "0.6.2"

crates/bevy_render/src/camera/camera.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ impl Camera {
5252
// Build a transform to convert from world to NDC using camera data
5353
let world_to_ndc: Mat4 =
5454
self.projection_matrix * camera_transform.compute_matrix().inverse();
55-
let ndc_space_coords: Vec3 = world_to_ndc.transform_point3(world_position);
55+
let ndc_space_coords: Vec3 = world_to_ndc.project_point3(world_position);
5656
// NDC z-values outside of 0 < z < 1 are behind the camera and are thus not in screen space
5757
if ndc_space_coords.z < 0.0 || ndc_space_coords.z > 1.0 {
5858
return None;
5959
}
6060
// Once in NDC space, we can discard the z element and rescale x/y to fit the screen
61-
let screen_space_coords = (ndc_space_coords.truncate() + Vec2::one()) / 2.0 * window_size;
61+
let screen_space_coords = (ndc_space_coords.truncate() + Vec2::ONE) / 2.0 * window_size;
6262
Some(screen_space_coords)
6363
}
6464
}

crates/bevy_render/src/mesh/shape/torus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl From<Torus> for Mesh {
4848
let z = theta.sin() * (torus.radius + torus.ring_radius * phi.cos());
4949
let y = torus.ring_radius * phi.sin();
5050

51-
let normal = segment_pos.cross(Vec3::unit_y()).normalize();
51+
let normal = segment_pos.cross(Vec3::Y).normalize();
5252

5353
positions.push([x, y, z]);
5454
normals.push(normal.into());

crates/bevy_text/src/text2d.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ pub fn draw_text2d_system(
9696
if let Some(text_glyphs) = text_pipeline.get_glyphs(&entity) {
9797
let position = global_transform.translation
9898
+ match text.alignment.vertical {
99-
VerticalAlign::Top => Vec3::zero(),
99+
VerticalAlign::Top => Vec3::ZERO,
100100
VerticalAlign::Center => Vec3::new(0.0, -height * 0.5, 0.0),
101101
VerticalAlign::Bottom => Vec3::new(0.0, -height, 0.0),
102102
}
103103
+ match text.alignment.horizontal {
104104
HorizontalAlign::Left => Vec3::new(-width, 0.0, 0.0),
105105
HorizontalAlign::Center => Vec3::new(-width * 0.5, 0.0, 0.0),
106-
HorizontalAlign::Right => Vec3::zero(),
106+
HorizontalAlign::Right => Vec3::ZERO,
107107
};
108108

109109
let mut drawable_text = DrawableText {

crates/bevy_transform/src/components/global_transform.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ impl GlobalTransform {
2222
#[inline]
2323
pub fn identity() -> Self {
2424
GlobalTransform {
25-
translation: Vec3::zero(),
26-
rotation: Quat::identity(),
27-
scale: Vec3::one(),
25+
translation: Vec3::ZERO,
26+
rotation: Quat::IDENTITY,
27+
scale: Vec3::ONE,
2828
}
2929
}
3030

@@ -78,19 +78,19 @@ impl GlobalTransform {
7878
#[inline]
7979
/// Get the unit vector in the local x direction
8080
pub fn local_x(&self) -> Vec3 {
81-
self.rotation * Vec3::unit_x()
81+
self.rotation * Vec3::X
8282
}
8383

8484
#[inline]
8585
/// Get the unit vector in the local y direction
8686
pub fn local_y(&self) -> Vec3 {
87-
self.rotation * Vec3::unit_y()
87+
self.rotation * Vec3::Y
8888
}
8989

9090
#[inline]
9191
/// Get the unit vector in the local z direction
9292
pub fn local_z(&self) -> Vec3 {
93-
self.rotation * Vec3::unit_z()
93+
self.rotation * Vec3::Z
9494
}
9595

9696
#[inline]

crates/bevy_transform/src/components/transform.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ impl Transform {
2222
#[inline]
2323
pub fn identity() -> Self {
2424
Transform {
25-
translation: Vec3::zero(),
26-
rotation: Quat::identity(),
27-
scale: Vec3::one(),
25+
translation: Vec3::ZERO,
26+
rotation: Quat::IDENTITY,
27+
scale: Vec3::ONE,
2828
}
2929
}
3030

@@ -78,19 +78,19 @@ impl Transform {
7878
#[inline]
7979
/// Get the unit vector in the local x direction
8080
pub fn local_x(&self) -> Vec3 {
81-
self.rotation * Vec3::unit_x()
81+
self.rotation * Vec3::X
8282
}
8383

8484
#[inline]
8585
/// Get the unit vector in the local y direction
8686
pub fn local_y(&self) -> Vec3 {
87-
self.rotation * Vec3::unit_y()
87+
self.rotation * Vec3::Y
8888
}
8989

9090
#[inline]
9191
/// Get the unit vector in the local z direction
9292
pub fn local_z(&self) -> Vec3 {
93-
self.rotation * Vec3::unit_z()
93+
self.rotation * Vec3::Z
9494
}
9595

9696
#[inline]

examples/3d/3d_scene.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ fn setup(
3636
})
3737
// camera
3838
.spawn(PerspectiveCameraBundle {
39-
transform: Transform::from_xyz(-2.0, 2.5, 5.0)
40-
.looking_at(Vec3::default(), Vec3::unit_y()),
39+
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y),
4140
..Default::default()
4241
});
4342
}

examples/3d/load_gltf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
1717
})
1818
.spawn(PerspectiveCameraBundle {
1919
transform: Transform::from_xyz(0.7, 0.7, 1.0)
20-
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()),
20+
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
2121
..Default::default()
2222
});
2323
}

examples/3d/msaa.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ fn setup(
3232
})
3333
// camera
3434
.spawn(PerspectiveCameraBundle {
35-
transform: Transform::from_xyz(-3.0, 3.0, 5.0)
36-
.looking_at(Vec3::default(), Vec3::unit_y()),
35+
transform: Transform::from_xyz(-3.0, 3.0, 5.0).looking_at(Vec3::default(), Vec3::Y),
3736
..Default::default()
3837
});
3938
}

examples/3d/orthographic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn setup(
1717
// set up the camera
1818
let mut camera = OrthographicCameraBundle::new_3d();
1919
camera.orthographic_projection.scale = 3.0;
20-
camera.transform = Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::zero(), Vec3::unit_y());
20+
camera.transform = Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y);
2121

2222
// add entities to the world
2323
commands

examples/3d/parenting.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ fn setup(
5858
})
5959
// camera
6060
.spawn(PerspectiveCameraBundle {
61-
transform: Transform::from_xyz(5.0, 10.0, 10.0)
62-
.looking_at(Vec3::default(), Vec3::unit_y()),
61+
transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::default(), Vec3::Y),
6362
..Default::default()
6463
});
6564
}

examples/3d/spawner.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ fn setup(
4444
})
4545
// camera
4646
.spawn(PerspectiveCameraBundle {
47-
transform: Transform::from_xyz(0.0, 15.0, 150.0)
48-
.looking_at(Vec3::default(), Vec3::unit_y()),
47+
transform: Transform::from_xyz(0.0, 15.0, 150.0).looking_at(Vec3::default(), Vec3::Y),
4948
..Default::default()
5049
});
5150

examples/3d/texture.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ fn setup(
9696
})
9797
// camera
9898
.spawn(PerspectiveCameraBundle {
99-
transform: Transform::from_xyz(3.0, 5.0, 8.0)
100-
.looking_at(Vec3::default(), Vec3::unit_y()),
99+
transform: Transform::from_xyz(3.0, 5.0, 8.0).looking_at(Vec3::default(), Vec3::Y),
101100
..Default::default()
102101
});
103102
}

examples/3d/update_gltf_scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn setup(
3131
})
3232
.spawn(PerspectiveCameraBundle {
3333
transform: Transform::from_xyz(1.05, 0.9, 1.5)
34-
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()),
34+
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
3535
..Default::default()
3636
});
3737

examples/3d/wireframe.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ fn setup(
5252
})
5353
// camera
5454
.spawn(PerspectiveCameraBundle {
55-
transform: Transform::from_xyz(-2.0, 2.5, 5.0)
56-
.looking_at(Vec3::default(), Vec3::unit_y()),
55+
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y),
5756
..Default::default()
5857
});
5958
}

examples/3d/z_sort_debug.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ fn setup(
8383
})
8484
// camera
8585
.spawn(PerspectiveCameraBundle {
86-
transform: Transform::from_xyz(5.0, 10.0, 10.0)
87-
.looking_at(Vec3::default(), Vec3::unit_y()),
86+
transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::default(), Vec3::Y),
8887
..Default::default()
8988
});
9089
}

examples/android/android.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ fn setup(
3838
})
3939
// camera
4040
.spawn(PerspectiveCameraBundle {
41-
transform: Transform::from_xyz(-2.0, 2.5, 5.0)
42-
.looking_at(Vec3::default(), Vec3::unit_y()),
41+
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y),
4342
..Default::default()
4443
});
4544
}

examples/asset/asset_loading.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ fn setup(
7171
})
7272
// camera
7373
.spawn(PerspectiveCameraBundle {
74-
transform: Transform::from_xyz(0.0, 3.0, 10.0)
75-
.looking_at(Vec3::default(), Vec3::unit_y()),
74+
transform: Transform::from_xyz(0.0, 3.0, 10.0).looking_at(Vec3::default(), Vec3::Y),
7675
..Default::default()
7776
});
7877
}

examples/asset/hot_asset_reloading.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
3131
})
3232
// camera
3333
.spawn(PerspectiveCameraBundle {
34-
transform: Transform::from_xyz(2.0, 2.0, 6.0)
35-
.looking_at(Vec3::default(), Vec3::unit_y()),
34+
transform: Transform::from_xyz(2.0, 2.0, 6.0).looking_at(Vec3::default(), Vec3::Y),
3635
..Default::default()
3736
});
3837
}

examples/game/alien_cake_addict.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn setup_cameras(mut commands: Commands, mut game: ResMut<Game>) {
109109
2.0 * BOARD_SIZE_J as f32 / 3.0,
110110
BOARD_SIZE_J as f32 / 2.0 - 0.5,
111111
)
112-
.looking_at(game.camera_is_focus, Vec3::unit_y()),
112+
.looking_at(game.camera_is_focus, Vec3::Y),
113113
..Default::default()
114114
})
115115
.spawn(UiCameraBundle::default());
@@ -301,7 +301,7 @@ fn focus_camera(
301301
// look at that new camera's actual focus
302302
for (mut transform, camera) in transforms.q0_mut().iter_mut() {
303303
if camera.name == Some(CAMERA_3D.to_string()) {
304-
*transform = transform.looking_at(game.camera_is_focus, Vec3::unit_y());
304+
*transform = transform.looking_at(game.camera_is_focus, Vec3::Y);
305305
}
306306
}
307307
}

examples/ios/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ fn setup(
5353
})
5454
// camera
5555
.spawn(PerspectiveCameraBundle {
56-
transform: Transform::from_xyz(-2.0, 2.5, 5.0)
57-
.looking_at(Vec3::default(), Vec3::unit_y()),
56+
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::default(), Vec3::Y),
5857
..Default::default()
5958
});
6059
}

examples/shader/array_texture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn setup(
110110
.unwrap();
111111

112112
commands.spawn(PerspectiveCameraBundle {
113-
transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::default(), Vec3::unit_y()),
113+
transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::default(), Vec3::Y),
114114
..Default::default()
115115
});
116116
}

examples/shader/hot_shader_reloading.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ fn setup(
7373
.with(material)
7474
// camera
7575
.spawn(PerspectiveCameraBundle {
76-
transform: Transform::from_xyz(3.0, 5.0, -8.0)
77-
.looking_at(Vec3::default(), Vec3::unit_y()),
76+
transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y),
7877
..Default::default()
7978
});
8079
}

examples/shader/mesh_custom_attribute.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ fn setup(
138138
.with(material)
139139
// camera
140140
.spawn(PerspectiveCameraBundle {
141-
transform: Transform::from_xyz(3.0, 5.0, -8.0)
142-
.looking_at(Vec3::default(), Vec3::unit_y()),
141+
transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y),
143142
..Default::default()
144143
});
145144
}

examples/shader/shader_custom_material.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ fn setup(
9494
.with(material)
9595
// camera
9696
.spawn(PerspectiveCameraBundle {
97-
transform: Transform::from_xyz(3.0, 5.0, -8.0)
98-
.looking_at(Vec3::default(), Vec3::unit_y()),
97+
transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y),
9998
..Default::default()
10099
});
101100
}

examples/shader/shader_defs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ fn setup(
125125
.with(blue_material)
126126
// camera
127127
.spawn(PerspectiveCameraBundle {
128-
transform: Transform::from_xyz(3.0, 5.0, -8.0)
129-
.looking_at(Vec3::default(), Vec3::unit_y()),
128+
transform: Transform::from_xyz(3.0, 5.0, -8.0).looking_at(Vec3::default(), Vec3::Y),
130129
..Default::default()
131130
});
132131
}

examples/window/multiple_windows.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ fn setup_pipeline(
190190
})
191191
// main camera
192192
.spawn(PerspectiveCameraBundle {
193-
transform: Transform::from_xyz(0.0, 0.0, 6.0)
194-
.looking_at(Vec3::default(), Vec3::unit_y()),
193+
transform: Transform::from_xyz(0.0, 0.0, 6.0).looking_at(Vec3::default(), Vec3::Y),
195194
..Default::default()
196195
})
197196
// second window camera
@@ -201,8 +200,7 @@ fn setup_pipeline(
201200
window: window_id,
202201
..Default::default()
203202
},
204-
transform: Transform::from_xyz(6.0, 0.0, 0.0)
205-
.looking_at(Vec3::default(), Vec3::unit_y()),
203+
transform: Transform::from_xyz(6.0, 0.0, 0.0).looking_at(Vec3::default(), Vec3::Y),
206204
..Default::default()
207205
});
208206
}

0 commit comments

Comments
 (0)