Skip to content

Commit 884dc46

Browse files
authored
Replace right/up/forward and counter parts with local_x/local_y and local_z (bevyengine#1476)
1 parent c2a427f commit 884dc46

File tree

2 files changed

+12
-36
lines changed

2 files changed

+12
-36
lines changed

crates/bevy_transform/src/components/global_transform.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,23 @@ impl GlobalTransform {
7575
}
7676

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

8283
#[inline]
83-
pub fn left(&self) -> Vec3 {
84-
-self.right()
85-
}
86-
87-
#[inline]
88-
pub fn up(&self) -> Vec3 {
84+
/// Get the unit vector in the local y direction
85+
pub fn local_y(&self) -> Vec3 {
8986
self.rotation * Vec3::unit_y()
9087
}
9188

9289
#[inline]
93-
pub fn down(&self) -> Vec3 {
94-
-self.up()
95-
}
96-
97-
#[inline]
98-
pub fn forward(&self) -> Vec3 {
90+
/// Get the unit vector in the local z direction
91+
pub fn local_z(&self) -> Vec3 {
9992
self.rotation * Vec3::unit_z()
10093
}
10194

102-
#[inline]
103-
pub fn backward(&self) -> Vec3 {
104-
-self.forward()
105-
}
106-
10795
#[inline]
10896
/// Rotate the transform by the given rotation
10997
pub fn rotate(&mut self, rotation: Quat) {

crates/bevy_transform/src/components/transform.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,23 @@ impl Transform {
7575
}
7676

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

8283
#[inline]
83-
pub fn left(&self) -> Vec3 {
84-
-self.right()
85-
}
86-
87-
#[inline]
88-
pub fn up(&self) -> Vec3 {
84+
/// Get the unit vector in the local y direction
85+
pub fn local_y(&self) -> Vec3 {
8986
self.rotation * Vec3::unit_y()
9087
}
9188

9289
#[inline]
93-
pub fn down(&self) -> Vec3 {
94-
-self.up()
95-
}
96-
97-
#[inline]
98-
pub fn forward(&self) -> Vec3 {
90+
/// Get the unit vector in the local z direction
91+
pub fn local_z(&self) -> Vec3 {
9992
self.rotation * Vec3::unit_z()
10093
}
10194

102-
#[inline]
103-
pub fn backward(&self) -> Vec3 {
104-
-self.forward()
105-
}
106-
10795
#[inline]
10896
/// Rotate the transform by the given rotation
10997
pub fn rotate(&mut self, rotation: Quat) {

0 commit comments

Comments
 (0)