Add more transform relative vectors (#1300)

* Add more transform relative vectors (#1298)

* Add inverse of relative directions (#1298)
This commit is contained in:
RedlineTriad 2021-01-25 04:05:30 +00:00 committed by GitHub
parent 40b5bbd028
commit 7e368e0b78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View file

@ -74,11 +74,36 @@ impl GlobalTransform {
Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
}
#[inline]
pub fn right(&self) -> Vec3 {
self.rotation * Vec3::unit_x()
}
#[inline]
pub fn left(&self) -> Vec3 {
-self.right()
}
#[inline]
pub fn up(&self) -> Vec3 {
self.rotation * Vec3::unit_y()
}
#[inline]
pub fn down(&self) -> Vec3 {
-self.up()
}
#[inline]
pub fn forward(&self) -> Vec3 {
self.rotation * Vec3::unit_z()
}
#[inline]
pub fn backward(&self) -> Vec3 {
-self.forward()
}
#[inline]
/// Rotate the transform by the given rotation
pub fn rotate(&mut self, rotation: Quat) {

View file

@ -74,11 +74,36 @@ impl Transform {
Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
}
#[inline]
pub fn right(&self) -> Vec3 {
self.rotation * Vec3::unit_x()
}
#[inline]
pub fn left(&self) -> Vec3 {
-self.right()
}
#[inline]
pub fn up(&self) -> Vec3 {
self.rotation * Vec3::unit_y()
}
#[inline]
pub fn down(&self) -> Vec3 {
-self.up()
}
#[inline]
pub fn forward(&self) -> Vec3 {
self.rotation * Vec3::unit_z()
}
#[inline]
pub fn backward(&self) -> Vec3 {
-self.forward()
}
#[inline]
/// Rotate the transform by the given rotation
pub fn rotate(&mut self, rotation: Quat) {