Skip to content

Commit

Permalink
Fix math types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondolf committed Feb 12, 2024
1 parent 6ac31ca commit 06f79fc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,31 +334,37 @@ impl Position {
impl From<GlobalTransform> for Position {
#[cfg(feature = "2d")]
fn from(value: GlobalTransform) -> Self {
Self::from_xy(value.translation().x, value.translation().y)
Self::from_xy(
value.translation().adjust_precision().x,
value.translation().adjust_precision().y,
)
}

#[cfg(feature = "3d")]
fn from(value: GlobalTransform) -> Self {
Self::from_xyz(
value.translation().x,
value.translation().y,
value.translation().z,
value.translation().adjust_precision().x,
value.translation().adjust_precision().y,
value.translation().adjust_precision().z,
)
}
}

impl From<&GlobalTransform> for Position {
#[cfg(feature = "2d")]
fn from(value: &GlobalTransform) -> Self {
Self::from_xy(value.translation().x, value.translation().y)
Self::from_xy(
value.translation().adjust_precision().x,
value.translation().adjust_precision().y,
)
}

#[cfg(feature = "3d")]
fn from(value: &GlobalTransform) -> Self {
Self::from_xyz(
value.translation().x,
value.translation().y,
value.translation().z,
value.translation().adjust_precision().x,
value.translation().adjust_precision().y,
value.translation().adjust_precision().z,
)
}
}
Expand Down

0 comments on commit 06f79fc

Please sign in to comment.