Skip to content

Commit

Permalink
Add inline hints
Browse files Browse the repository at this point in the history
  • Loading branch information
valaphee committed Jan 23, 2024
1 parent 1ea80ce commit 561124e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub enum Interpolation {
}

impl Interpolation {
#[inline(always)]
fn interpolate<T: Interpolatable>(
self,
lerp: f32,
Expand Down Expand Up @@ -165,6 +166,7 @@ impl Interpolation {
}
}

#[inline(always)]
fn step_size(self) -> usize {
match self {
Interpolation::Linear | Interpolation::Step => 1,
Expand All @@ -177,19 +179,22 @@ trait Interpolatable: Sized + Copy + Mul<f32, Output = Self> + Add<Self, Output
fn _lerp(self, rhs: Self, t: f32) -> Self;
}

impl Interpolatable for Vec3 {
impl Interpolatable for f32 {
#[inline(always)]
fn _lerp(self, rhs: Self, t: f32) -> Self {
self.lerp(rhs, t)
}
}

impl Interpolatable for f32 {
impl Interpolatable for Vec3 {
#[inline(always)]
fn _lerp(self, rhs: Self, t: f32) -> Self {
self.lerp(rhs, t)
}
}

impl Interpolatable for Quat {
#[inline(always)]
fn _lerp(self, rhs: Self, t: f32) -> Self {
self.slerp(rhs, t)
}
Expand Down

0 comments on commit 561124e

Please sign in to comment.