Add more transform relative vectors (#1300)
* Add more transform relative vectors (#1298) * Add inverse of relative directions (#1298)
This commit is contained in:
parent
40b5bbd028
commit
7e368e0b78
@ -74,11 +74,36 @@ impl GlobalTransform {
|
|||||||
Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
|
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]
|
#[inline]
|
||||||
pub fn forward(&self) -> Vec3 {
|
pub fn forward(&self) -> Vec3 {
|
||||||
self.rotation * Vec3::unit_z()
|
self.rotation * Vec3::unit_z()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn backward(&self) -> Vec3 {
|
||||||
|
-self.forward()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Rotate the transform by the given rotation
|
/// Rotate the transform by the given rotation
|
||||||
pub fn rotate(&mut self, rotation: Quat) {
|
pub fn rotate(&mut self, rotation: Quat) {
|
||||||
|
|||||||
@ -74,11 +74,36 @@ impl Transform {
|
|||||||
Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
|
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]
|
#[inline]
|
||||||
pub fn forward(&self) -> Vec3 {
|
pub fn forward(&self) -> Vec3 {
|
||||||
self.rotation * Vec3::unit_z()
|
self.rotation * Vec3::unit_z()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn backward(&self) -> Vec3 {
|
||||||
|
-self.forward()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Rotate the transform by the given rotation
|
/// Rotate the transform by the given rotation
|
||||||
pub fn rotate(&mut self, rotation: Quat) {
|
pub fn rotate(&mut self, rotation: Quat) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user