diff --git a/crates/bevy_animation/Cargo.toml b/crates/bevy_animation/Cargo.toml
index 1614d98f54..6fb9fb9f59 100644
--- a/crates/bevy_animation/Cargo.toml
+++ b/crates/bevy_animation/Cargo.toml
@@ -39,6 +39,7 @@ derive_more = { version = "1", default-features = false, features = [
"from",
"display",
] }
+either = "1.13"
thread_local = "1"
uuid = { version = "1.7", features = ["v4"] }
smallvec = "1"
diff --git a/crates/bevy_animation/src/gltf_curves.rs b/crates/bevy_animation/src/gltf_curves.rs
index 74d86fd03b..8d3b6cc248 100644
--- a/crates/bevy_animation/src/gltf_curves.rs
+++ b/crates/bevy_animation/src/gltf_curves.rs
@@ -6,6 +6,7 @@ use bevy_math::{
};
use bevy_reflect::Reflect;
use derive_more::derive::{Display, Error, From};
+use either::Either;
/// A keyframe-defined curve that "interpolates" by stepping at `t = 1.0` to the next keyframe.
#[derive(Debug, Clone, Reflect)]
@@ -189,11 +190,11 @@ where
match self.core.sample_interp(t) {
InterpolationDatum::Exact(v)
| InterpolationDatum::LeftTail(v)
- | InterpolationDatum::RightTail(v) => TwoIterators::Left(v.iter().copied()),
+ | InterpolationDatum::RightTail(v) => Either::Left(v.iter().copied()),
InterpolationDatum::Between(u, v, s) => {
let interpolated = u.iter().zip(v.iter()).map(move |(x, y)| x.lerp(*y, s));
- TwoIterators::Right(interpolated)
+ Either::Right(interpolated)
}
}
}
@@ -243,14 +244,14 @@ where
match self.core.sample_interp(t) {
InterpolationDatum::Exact(v)
| InterpolationDatum::LeftTail(v)
- | InterpolationDatum::RightTail(v) => TwoIterators::Left(v.iter().cloned()),
+ | InterpolationDatum::RightTail(v) => Either::Left(v.iter().cloned()),
InterpolationDatum::Between(u, v, s) => {
let interpolated =
u.iter()
.zip(v.iter())
.map(move |(x, y)| if s >= 1.0 { y.clone() } else { x.clone() });
- TwoIterators::Right(interpolated)
+ Either::Right(interpolated)
}
}
}
@@ -302,10 +303,10 @@ where
// Pick out the part of this that actually represents the position (instead of tangents),
// which is the middle third.
let width = self.core.width();
- TwoIterators::Left(v[width..(width * 2)].iter().copied())
+ Either::Left(v[width..(width * 2)].iter().copied())
}
- InterpolationDatum::Between((t0, u), (t1, v), s) => TwoIterators::Right(
+ InterpolationDatum::Between((t0, u), (t1, v), s) => Either::Right(
cubic_spline_interpolate_slices(self.core.width() / 3, u, v, s, t1 - t0),
),
}
@@ -392,26 +393,6 @@ pub enum WeightsCurve {
// HELPERS //
//---------//
-enum TwoIterators {
- Left(A),
- Right(B),
-}
-
-impl Iterator for TwoIterators
-where
- A: Iterator- ,
- B: Iterator
- ,
-{
- type Item = T;
-
- fn next(&mut self) -> Option {
- match self {
- TwoIterators::Left(a) => a.next(),
- TwoIterators::Right(b) => b.next(),
- }
- }
-}
-
/// Helper function for cubic spline interpolation.
fn cubic_spline_interpolation(
value_start: T,