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 <c_hart@wargaming.net>
This commit is contained in:
Cameron Hart 2021-03-06 19:39:16 +00:00
parent 0eba5f38b9
commit f61e44db28
29 changed files with 43 additions and 60 deletions

View File

@ -231,6 +231,6 @@ mod tests {
#[test]
fn test_mat4_round_trip() {
test_round_trip(Mat4::identity());
test_round_trip(Mat4::IDENTITY);
}
}

View File

@ -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"] }

View File

@ -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"

View File

@ -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)
}
}

View File

@ -48,7 +48,7 @@ impl From<Torus> 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());

View File

@ -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 {

View File

@ -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]

View File

@ -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]

View File

@ -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()
});
}

View File

@ -17,7 +17,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
})
.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()
});
}

View File

@ -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()
});
}

View File

@ -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

View File

@ -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()
});
}

View File

@ -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()
});

View File

@ -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()
});
}

View File

@ -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()
});

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -31,8 +31,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
})
// 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()
});
}

View File

@ -109,7 +109,7 @@ fn setup_cameras(mut commands: Commands, mut game: ResMut<Game>) {
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);
}
}
}

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -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()
});
}

View File

@ -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()
});
}