Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace right/up/forward and counter parts with local_x/local_y and local_z #1476

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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