bevy/crates/bevy_math/src/curve
Matty Weatherley 43d5472fda
Easing curves for tuples (#16945)
# Objective

Make it so that users can ease between tuples of easeable values. 

## Solution

Use `variadics_please`'s `all_tuples_enumerated` macro to generate code
that creates these trait implementations. For two elements, the result
looks like this:
```rust
impl<T0: Ease, T1: Ease> Ease for (T0, T1) {
    fn interpolating_curve_unbounded(start: Self, end: Self) -> impl Curve<Self> {
        let curve_tuple = (
            <T0 as Ease>::interpolating_curve_unbounded(start.0, end.0),
            <T1 as Ease>::interpolating_curve_unbounded(start.1, end.1),
        );
        FunctionCurve::new(Interval::EVERYWHERE, move |t| {
            (
                curve_tuple.0.sample_unchecked(t),
                curve_tuple.1.sample_unchecked(t),
            )
        })
    }
}
```

## Testing

It compiles, and I futzed about with some manual examples, which seem to
work as expected.

---

## Showcase

Easing curves now support easing tuples of values that can themselves be
eased. For example:
```rust
// Easing between two `(Vec3, Quat)` values:
let easing_curve = EasingCurve::new(
    (vec3(0.0, 0.0, 0.0), Quat::from_rotation_z(-FRAC_PI_2)),
    (vec3(1.0, 1.0, 1.0), Quat::from_rotation_z(FRAC_PI_2)),
    EaseFunction::ExponentialInOut
);
```
2024-12-24 18:06:08 +00:00
..
derivatives Derivative access patterns for curves (#16503) 2024-12-10 20:27:37 +00:00
adaptors.rs Derivative access patterns for curves (#16503) 2024-12-10 20:27:37 +00:00
cores.rs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
easing.rs Easing curves for tuples (#16945) 2024-12-24 18:06:08 +00:00
interval.rs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
iterable.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00
mod.rs Derivative access patterns for curves (#16503) 2024-12-10 20:27:37 +00:00
sample_curves.rs Add no_std Support to bevy_math (#15810) 2024-12-03 17:14:51 +00:00