Skip to content

Commit

Permalink
Add methods to return the inner value for direction types
Browse files Browse the repository at this point in the history
Add `vec2` method for Dir2
Add `vec3` method for Dir3
Add `vec3a` method for Dir3A
  • Loading branch information
Multirious committed Mar 16, 2024
1 parent 1323de7 commit 2e234e1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/bevy_math/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ impl Dir2 {
pub fn from_xy(x: f32, y: f32) -> Result<Self, InvalidDirectionError> {
Self::new(Vec2::new(x, y))
}

/// Returning the inner [`Vec2`]
pub fn vec2(&self) -> Vec2 {
self.0
}
}

impl TryFrom<Vec2> for Dir2 {
Expand Down Expand Up @@ -287,6 +292,11 @@ impl Dir3 {
pub fn from_xyz(x: f32, y: f32, z: f32) -> Result<Self, InvalidDirectionError> {
Self::new(Vec3::new(x, y, z))
}

/// Returning the inner [`Vec3`]
pub fn vec3(&self) -> Vec3 {
self.0
}
}

impl TryFrom<Vec3> for Dir3 {
Expand Down Expand Up @@ -447,6 +457,11 @@ impl Dir3A {
pub fn from_xyz(x: f32, y: f32, z: f32) -> Result<Self, InvalidDirectionError> {
Self::new(Vec3A::new(x, y, z))
}

/// Returning the inner [`Vec3A`]
pub fn vec3a(&self) -> Vec3A {
self.0
}
}

impl TryFrom<Vec3A> for Dir3A {
Expand Down

0 comments on commit 2e234e1

Please sign in to comment.