Remove face_toward.rs
(#4277)
# Objective - Part of the splitting process of #3503. ## Solution - Remove the `face_toward.rs` file containing the `FaceToward` trait. ## Reasons - It is unused inside of `bevy`. - The method `Mat4::face_toward` of the trait is identical to `Mat4::look_at_rh` (see https://docs.rs/glam/latest/glam/f32/struct.Mat4.html#method.look_at_rh). - Discussion in #3503. ## Changelog ### Removed - The `FaceToward` trait got removed. ## Migration Guide - The `FaceToward` trait got removed. To migrate you just have to change every occurrence of `Mat4::face_toward` to `Mat4::look_at_rh`.
This commit is contained in:
parent
449a1d223c
commit
f90da74e32
@ -1,41 +0,0 @@
|
|||||||
use crate::{Mat4, Vec3};
|
|
||||||
|
|
||||||
/// Generates a translation / rotation matrix that faces a given target
|
|
||||||
pub trait FaceToward {
|
|
||||||
/// Generates a translation / rotation matrix that faces a given target
|
|
||||||
fn face_toward(eye: Vec3, center: Vec3, up: Vec3) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FaceToward for Mat4 {
|
|
||||||
fn face_toward(eye: Vec3, center: Vec3, up: Vec3) -> Self {
|
|
||||||
let forward = (eye - center).normalize();
|
|
||||||
let right = up.cross(forward).normalize();
|
|
||||||
let up = forward.cross(right);
|
|
||||||
Mat4::from_cols(
|
|
||||||
right.extend(0.0),
|
|
||||||
up.extend(0.0),
|
|
||||||
forward.extend(0.0),
|
|
||||||
eye.extend(1.0),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
#[test]
|
|
||||||
fn face_toward_mat4() {
|
|
||||||
use crate::{FaceToward, Mat4, Vec3, Vec4};
|
|
||||||
|
|
||||||
// Completely arbitrary arguments
|
|
||||||
let matrix = Mat4::face_toward(
|
|
||||||
Vec3::new(50.0, 60.0, 0.0),
|
|
||||||
Vec3::new(0.0, 0.0, 0.0),
|
|
||||||
Vec3::new(0.0, 1.0, 0.0),
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(matrix.x_axis, Vec4::new(0.0, 0.0, -1.0, -0.0));
|
|
||||||
assert_eq!(matrix.y_axis, Vec4::new(-0.7682213, 0.6401844, 0.0, 0.0));
|
|
||||||
assert_eq!(matrix.z_axis, Vec4::new(0.6401844, 0.7682213, 0.0, 0.0));
|
|
||||||
assert_eq!(matrix.w_axis, Vec4::new(50.0, 60.0, 0.0, 1.0));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,12 @@
|
|||||||
mod face_toward;
|
|
||||||
mod geometry;
|
mod geometry;
|
||||||
|
|
||||||
pub use face_toward::*;
|
|
||||||
pub use geometry::*;
|
pub use geometry::*;
|
||||||
pub use glam::*;
|
pub use glam::*;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
BVec2, BVec3, BVec4, EulerRot, FaceToward, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, Rect,
|
BVec2, BVec3, BVec4, EulerRot, IVec2, IVec3, IVec4, Mat3, Mat4, Quat, Rect, Size, UVec2,
|
||||||
Size, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4,
|
UVec3, UVec4, Vec2, Vec3, Vec4,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user