Skip to content

Commit

Permalink
Replace right/up/forward and counter parts with local_x/local_y and l…
Browse files Browse the repository at this point in the history
…ocal_z (#1476)
  • Loading branch information
NiklasEi committed Feb 19, 2021
1 parent c2a427f commit 884dc46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 36 deletions.
24 changes: 6 additions & 18 deletions crates/bevy_transform/src/components/global_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,35 +75,23 @@ impl GlobalTransform {
}

#[inline]
pub fn right(&self) -> Vec3 {
/// Get the unit vector in the local x direction
pub fn local_x(&self) -> Vec3 {
self.rotation * Vec3::unit_x()
}

#[inline]
pub fn left(&self) -> Vec3 {
-self.right()
}

#[inline]
pub fn up(&self) -> Vec3 {
/// Get the unit vector in the local y direction
pub fn local_y(&self) -> Vec3 {
self.rotation * Vec3::unit_y()
}

#[inline]
pub fn down(&self) -> Vec3 {
-self.up()
}

#[inline]
pub fn forward(&self) -> Vec3 {
/// Get the unit vector in the local z direction
pub fn local_z(&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) {
Expand Down
24 changes: 6 additions & 18 deletions crates/bevy_transform/src/components/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,35 +75,23 @@ impl Transform {
}

#[inline]
pub fn right(&self) -> Vec3 {
/// Get the unit vector in the local x direction
pub fn local_x(&self) -> Vec3 {
self.rotation * Vec3::unit_x()
}

#[inline]
pub fn left(&self) -> Vec3 {
-self.right()
}

#[inline]
pub fn up(&self) -> Vec3 {
/// Get the unit vector in the local y direction
pub fn local_y(&self) -> Vec3 {
self.rotation * Vec3::unit_y()
}

#[inline]
pub fn down(&self) -> Vec3 {
-self.up()
}

#[inline]
pub fn forward(&self) -> Vec3 {
/// Get the unit vector in the local z direction
pub fn local_z(&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) {
Expand Down

0 comments on commit 884dc46

Please sign in to comment.