pub enum GenericValue<D: DataSystem> {
Uniform(D),
Animated(D::Animated),
}Expand description
A value that can be either uniform or animated over time.
This is the generic version of Value that works with any
DataSystem. Use this when you have a custom data type system.
For the built-in types, use Value which is an alias for
GenericValue<Data>.
Variants§
Uniform(D)
A constant value that does not change over time.
Animated(D::Animated)
A value that changes over time with keyframe interpolation.
Implementations§
Source§impl<D: DataSystem> GenericValue<D>
impl<D: DataSystem> GenericValue<D>
Sourcepub fn animated<I>(samples: I) -> Result<Self>where
I: IntoIterator<Item = (Time, D)>,
pub fn animated<I>(samples: I) -> Result<Self>where
I: IntoIterator<Item = (Time, D)>,
Creates an animated value from time-value pairs.
All samples must have the same data type. Vector samples are padded to match the length of the longest vector in the set.
Sourcepub fn add_sample(&mut self, time: Time, value: D) -> Result<()>
pub fn add_sample(&mut self, time: Time, value: D) -> Result<()>
Adds a sample at a specific time.
If the value is uniform, it becomes animated with the new sample.
Sourcepub fn remove_at(&mut self, time: &Time) -> Option<D>
pub fn remove_at(&mut self, time: &Time) -> Option<D>
Removes a sample at a specific time.
Returns the removed value if it existed. For uniform values, this is a
no-op and returns None. The last sample in an animated value cannot
be removed (returns None). Use remove_at_or_to_uniform
to degrade to uniform instead.
Sourcepub fn remove_sample(&mut self, time: &Time) -> Option<D>
👎Deprecated since 0.2.2: renamed to remove_at
pub fn remove_sample(&mut self, time: &Time) -> Option<D>
renamed to remove_at
Deprecated alias for remove_at.
Sourcepub fn remove_at_or_to_uniform(&mut self, time: &Time) -> Option<D>
pub fn remove_at_or_to_uniform(&mut self, time: &Time) -> Option<D>
Remove a sample, converting to uniform if it was the last keyframe.
If the value is uniform, returns None. If the removed sample was
the last keyframe, the value degrades from GenericValue::Animated
to GenericValue::Uniform with that keyframe’s value and returns
None (the data is preserved, not lost). Otherwise returns the
removed value.
Sourcepub fn sample_at(&self, time: Time) -> Option<D>
pub fn sample_at(&self, time: Time) -> Option<D>
Samples the value at an exact time without interpolation.
Returns the exact value if it exists at the given time, or None if
no sample exists at that time for animated values.
Sourcepub fn interpolate(&self, time: Time) -> D
pub fn interpolate(&self, time: Time) -> D
Interpolates the value at the given time.
For uniform values, returns the constant value. For animated values, interpolates between surrounding keyframes.
Sourcepub fn is_animated(&self) -> bool
pub fn is_animated(&self) -> bool
Returns true if the value is animated (has multiple keyframes).
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Returns the number of time samples.
Sourcepub fn discriminant(&self) -> D::DataType
pub fn discriminant(&self) -> D::DataType
Returns the data type discriminant for this value.
Sourcepub fn variant_name(&self) -> &'static str
pub fn variant_name(&self) -> &'static str
Returns a human-readable type name for this value.
Sourcepub fn merge_with<F>(
&self,
other: &GenericValue<D>,
combiner: F,
) -> Result<GenericValue<D>>
pub fn merge_with<F>( &self, other: &GenericValue<D>, combiner: F, ) -> Result<GenericValue<D>>
Merges this value with another using a combiner function.
For uniform values, applies the combiner once. For animated values, samples both at the union of all keyframe times and applies the combiner at each time.
Sourcepub fn hash_with_shutter<H: Hasher>(&self, state: &mut H, shutter: &Shutter)
pub fn hash_with_shutter<H: Hasher>(&self, state: &mut H, shutter: &Shutter)
Hashes the value with shutter context for animation-aware caching.
For animated values, samples at standardized points within the shutter range and hashes the interpolated values.
Trait Implementations§
Source§impl<D: Clone + DataSystem> Clone for GenericValue<D>
impl<D: Clone + DataSystem> Clone for GenericValue<D>
Source§fn clone(&self) -> GenericValue<D>
fn clone(&self) -> GenericValue<D>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<D: Debug + DataSystem> Debug for GenericValue<D>
impl<D: Debug + DataSystem> Debug for GenericValue<D>
Source§impl<D: DataSystem> From<D> for GenericValue<D>
impl<D: DataSystem> From<D> for GenericValue<D>
Source§impl<D: Hash + DataSystem> Hash for GenericValue<D>
impl<D: Hash + DataSystem> Hash for GenericValue<D>
Source§impl<D: PartialEq + DataSystem> PartialEq for GenericValue<D>
impl<D: PartialEq + DataSystem> PartialEq for GenericValue<D>
impl<D: DataSystem> Eq for GenericValue<D>
impl<D: DataSystem> StructuralPartialEq for GenericValue<D>
Auto Trait Implementations§
impl<D> Freeze for GenericValue<D>
impl<D> RefUnwindSafe for GenericValue<D>
impl<D> Send for GenericValue<D>
impl<D> Sync for GenericValue<D>
impl<D> Unpin for GenericValue<D>
impl<D> UnsafeUnpin for GenericValue<D>
impl<D> UnwindSafe for GenericValue<D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more