Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions crates/bevy_animation/src/animation_curves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
//! - [`TranslationCurve`], which uses `Vec3` output to animate [`Transform::translation`]
//! - [`RotationCurve`], which uses `Quat` output to animate [`Transform::rotation`]
//! - [`ScaleCurve`], which uses `Vec3` output to animate [`Transform::scale`]
//! - [`TransformCurve`], which uses `Transform` output to animate the entire `Transform`
//!
//! ## Animatable properties
//!
Expand Down Expand Up @@ -370,45 +369,6 @@ where
}
}

/// This type allows a [curve] valued in `Transform` to become an [`AnimationCurve`] that animates
/// a transform.
///
/// This exists primarily as a convenience to animate entities using the entire transform at once
/// instead of splitting it into pieces and animating each part (translation, rotation, scale).
///
/// [curve]: Curve
#[derive(Debug, Clone, Reflect, FromReflect)]
#[reflect(from_reflect = false)]
pub struct TransformCurve<C>(pub C);

impl<C> AnimationCurve for TransformCurve<C>
where
C: AnimationCompatibleCurve<Transform>,
{
fn clone_value(&self) -> Box<dyn AnimationCurve> {
Box::new(self.clone())
}

fn domain(&self) -> Interval {
self.0.domain()
}

fn apply<'a>(
&self,
t: f32,
transform: Option<Mut<'a, Transform>>,
_entity: AnimationEntityMut<'a>,
weight: f32,
) -> Result<(), AnimationEvaluationError> {
let mut component = transform.ok_or_else(|| {
AnimationEvaluationError::ComponentNotPresent(TypeId::of::<Transform>())
})?;
let new_value = self.0.sample_clamped(t);
*component = <Transform as Animatable>::interpolate(&component, &new_value, weight);
Ok(())
}
}

/// This type allows an [`IterableCurve`] valued in `f32` to be used as an [`AnimationCurve`]
/// that animates [morph weights].
///
Expand Down