Skip to content

Commit

Permalink
Fix Lerp implementation for integers (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 authored Oct 25, 2021
1 parent 59ed974 commit 82add18
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/sycamore/src/motion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ macro_rules! impl_lerp_for_int {
($i: path) => {
impl Lerp for $i {
fn lerp(&self, other: &Self, scalar: f32) -> Self {
((self + (other - self)) as f32 * scalar).round() as $i
(*self as f32 + (other - self) as f32 * scalar).round() as $i
}
}
};
Expand All @@ -44,12 +44,14 @@ impl_lerp_for_int!(i16);
impl_lerp_for_int!(i32);
impl_lerp_for_int!(i64);
impl_lerp_for_int!(i128);
impl_lerp_for_int!(isize);

impl_lerp_for_int!(u8);
impl_lerp_for_int!(u16);
impl_lerp_for_int!(u32);
impl_lerp_for_int!(u64);
impl_lerp_for_int!(u128);
impl_lerp_for_int!(usize);

impl<T: Lerp + Clone, const N: usize> Lerp for [T; N] {
fn lerp(&self, other: &Self, scalar: f32) -> Self {
Expand Down

0 comments on commit 82add18

Please sign in to comment.