Add synonyms for transform relative vectors (#1667)
Fixes #1663. I think the directions are correct (same as [here](https://docs.godotengine.org/en/stable/classes/class_vector3.html?highlight=forward#constants)), but please double check because I might have mixed them up. Co-authored-by: guimcaballero <guim.caballero@gmail.com> Co-authored-by: Guim Caballero <guim.caballero@gmail.com>
This commit is contained in:
parent
6ce57c85d6
commit
b060e16f62
@ -118,18 +118,54 @@ impl GlobalTransform {
|
||||
self.rotation * Vec3::X
|
||||
}
|
||||
|
||||
/// Equivalent to -local_x()
|
||||
#[inline]
|
||||
pub fn left(&self) -> Vec3 {
|
||||
-self.local_x()
|
||||
}
|
||||
|
||||
/// Equivalent to local_x()
|
||||
#[inline]
|
||||
pub fn right(&self) -> Vec3 {
|
||||
self.local_x()
|
||||
}
|
||||
|
||||
/// Get the unit vector in the local y direction
|
||||
#[inline]
|
||||
pub fn local_y(&self) -> Vec3 {
|
||||
self.rotation * Vec3::Y
|
||||
}
|
||||
|
||||
/// Equivalent to local_y()
|
||||
#[inline]
|
||||
pub fn up(&self) -> Vec3 {
|
||||
self.local_y()
|
||||
}
|
||||
|
||||
/// Equivalent to -local_y()
|
||||
#[inline]
|
||||
pub fn down(&self) -> Vec3 {
|
||||
-self.local_y()
|
||||
}
|
||||
|
||||
/// Get the unit vector in the local z direction
|
||||
#[inline]
|
||||
pub fn local_z(&self) -> Vec3 {
|
||||
self.rotation * Vec3::Z
|
||||
}
|
||||
|
||||
/// Equivalent to -local_z()
|
||||
#[inline]
|
||||
pub fn forward(&self) -> Vec3 {
|
||||
-self.local_z()
|
||||
}
|
||||
|
||||
/// Equivalent to local_z()
|
||||
#[inline]
|
||||
pub fn back(&self) -> Vec3 {
|
||||
self.local_z()
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
pub fn rotate(&mut self, rotation: Quat) {
|
||||
|
||||
@ -130,18 +130,54 @@ impl Transform {
|
||||
self.rotation * Vec3::X
|
||||
}
|
||||
|
||||
/// Equivalent to -local_x()
|
||||
#[inline]
|
||||
pub fn left(&self) -> Vec3 {
|
||||
-self.local_x()
|
||||
}
|
||||
|
||||
/// Equivalent to local_x()
|
||||
#[inline]
|
||||
pub fn right(&self) -> Vec3 {
|
||||
self.local_x()
|
||||
}
|
||||
|
||||
/// Get the unit vector in the local y direction.
|
||||
#[inline]
|
||||
pub fn local_y(&self) -> Vec3 {
|
||||
self.rotation * Vec3::Y
|
||||
}
|
||||
|
||||
/// Equivalent to local_y()
|
||||
#[inline]
|
||||
pub fn up(&self) -> Vec3 {
|
||||
self.local_y()
|
||||
}
|
||||
|
||||
/// Equivalent to -local_y()
|
||||
#[inline]
|
||||
pub fn down(&self) -> Vec3 {
|
||||
-self.local_y()
|
||||
}
|
||||
|
||||
/// Get the unit vector in the local z direction.
|
||||
#[inline]
|
||||
pub fn local_z(&self) -> Vec3 {
|
||||
self.rotation * Vec3::Z
|
||||
}
|
||||
|
||||
/// Equivalent to -local_z()
|
||||
#[inline]
|
||||
pub fn forward(&self) -> Vec3 {
|
||||
-self.local_z()
|
||||
}
|
||||
|
||||
/// Equivalent to local_z()
|
||||
#[inline]
|
||||
pub fn back(&self) -> Vec3 {
|
||||
self.local_z()
|
||||
}
|
||||
|
||||
/// Rotates the transform by the given rotation.
|
||||
#[inline]
|
||||
pub fn rotate(&mut self, rotation: Quat) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user