blend
Generated Rust API reference for byte_engine.
byte_engine / animation / blend
Module blend
Allocation-free local-pose and blend-space utilities.
Contents
Quick Reference
| Item | Kind | Description |
|---|---|---|
BlendSpace1D | struct | The BlendSpace1D struct stores validated scalar sample positions for allocation-free weight evaluation. |
BlendSpace2D | struct | The BlendSpace2D struct stores validated points and triangles for allocation-free directional blending. |
BlendWeights | struct | The BlendWeights struct holds the samples a blend space weighs above zero for one parameter, at most three, in ascending sample order, so a blend samples only those and mixes them in a stable order. |
BlendError | enum | Errors returned when local poses cannot be blended. |
BlendSpaceError | enum | Errors returned when constructing or evaluating a blend space. |
blend_local_transform | fn | Blends two local transforms while preserving the shortest quaternion path. |
blend_local_pose | fn | Blends two complete local poses into caller-owned storage. |
blend_local_poses | fn | Blends any number of complete local poses with normalized non-negative weights. |
Structs
BlendSpace1D
struct BlendSpace1D {
// [REDACTED: Private Fields]
}Defined in crates/byte-engine/src/animation/blend.rs:89-91
The BlendSpace1D struct stores validated scalar sample positions for allocation-free weight evaluation.
Implementations
-
fn new(positions: impl Into<Vec<f32>>) -> Result<Self, BlendSpaceError>Related:
BlendSpaceErrorCreates a blend space with finite, strictly ascending sample positions.
Next, call
Self::weightsduring evaluation and blend the weightedsamples' poses with
blend_local_poses. -
fn len(&self) -> usizeReturns the number of samples.
-
fn is_empty(&self) -> boolReturns whether the blend space contains no samples.
-
fn weights(&self, value: f32) -> Result<BlendWeights, BlendSpaceError>Related:
BlendWeights,BlendSpaceErrorReturns the normalized weights for a scalar parameter, clamping outside the sample range.
At most the two samples around the parameter weigh above zero.
Trait Implementations
impl ArchivePointee for BlendSpace1D
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for BlendSpace1D
impl Clone for BlendSpace1D
-
fn clone(&self) -> BlendSpace1DRelated:
BlendSpace1D
impl Debug for BlendSpace1D
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Downcast for BlendSpace1D
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSync for BlendSpace1D
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl Instrument for BlendSpace1D
impl LayoutRaw for BlendSpace1D
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for BlendSpace1D
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for BlendSpace1D
-
fn eq(&self, other: &BlendSpace1D) -> boolRelated:
BlendSpace1D
impl Pointee for BlendSpace1D
-
type Metadata = ()
impl Read for BlendSpace1D
impl StructuralPartialEq for BlendSpace1D
impl WithSubscriber for BlendSpace1D
BlendSpace2D
struct BlendSpace2D {
// [REDACTED: Private Fields]
}Defined in crates/byte-engine/src/animation/blend.rs:144-148
The BlendSpace2D struct stores validated points and triangles for allocation-free directional blending.
Implementations
-
fn new(positions: impl Into<Vec<[f32; 2]>>, triangles: impl Into<Vec<[usize; 3]>>) -> Result<Self, BlendSpaceError>Related:
BlendSpaceErrorCreates a triangulated blend space.
Each triangle lists three sample indices in order around it. Triangles may
share edges but must not be degenerate. Next, call
Self::weightsto find the containing triangle or the closest point on the triangulated
boundary.
-
fn len(&self) -> usizeReturns the number of samples.
-
fn is_empty(&self) -> boolReturns whether the blend space contains no samples.
-
fn weights(&self, value: [f32; 2]) -> Result<BlendWeights, BlendSpaceError>Related:
BlendWeights,BlendSpaceErrorReturns the normalized weights for a 2D parameter without allocating.
At most the three samples of one triangle weigh above zero. Values outside the triangulated region clamp to
the closest point on any triangle, which provides stable behavior at directional blend-space edges.
Trait Implementations
impl ArchivePointee for BlendSpace2D
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for BlendSpace2D
impl Clone for BlendSpace2D
-
fn clone(&self) -> BlendSpace2DRelated:
BlendSpace2D
impl Debug for BlendSpace2D
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Downcast for BlendSpace2D
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSync for BlendSpace2D
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl Instrument for BlendSpace2D
impl LayoutRaw for BlendSpace2D
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for BlendSpace2D
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for BlendSpace2D
-
fn eq(&self, other: &BlendSpace2D) -> boolRelated:
BlendSpace2D
impl Pointee for BlendSpace2D
-
type Metadata = ()
impl Read for BlendSpace2D
impl StructuralPartialEq for BlendSpace2D
impl WithSubscriber for BlendSpace2D
BlendWeights
struct BlendWeights {
// [REDACTED: Private Fields]
}Defined in crates/byte-engine/src/animation/blend.rs:230-233
The BlendWeights struct holds the samples a blend space weighs above zero for one parameter, at most three, in
ascending sample order, so a blend samples only those and mixes them in a stable order.
Get it from BlendSpace1D::weights or BlendSpace2D::weights, then sample each weighted clip and mix the
poses with blend_local_poses in the order Self::iter gives.
Implementations
-
const MAX: usize -
fn single(sample: usize) -> SelfReturns the weights of a blend that plays one sample alone.
-
fn iter(&self) -> impl ExactSizeIterator<Item = (usize, f32)> + '_Returns each weighted sample and its weight, in ascending sample order.
Trait Implementations
impl ArchivePointee for BlendWeights
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for BlendWeights
impl Clone for BlendWeights
-
fn clone(&self) -> BlendWeightsRelated:
BlendWeights
impl Copy for BlendWeights
impl Debug for BlendWeights
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Default for BlendWeights
-
fn default() -> BlendWeightsRelated:
BlendWeights
impl Downcast for BlendWeights
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSync for BlendWeights
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl Instrument for BlendWeights
impl LayoutRaw for BlendWeights
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for BlendWeights
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for BlendWeights
-
fn eq(&self, other: &BlendWeights) -> boolRelated:
BlendWeights
impl Pointee for BlendWeights
-
type Metadata = ()
impl Read for BlendWeights
impl<R> ReadPrimitive for BlendWeights
impl StructuralPartialEq for BlendWeights
impl WithSubscriber for BlendWeights
Enums
BlendError
enum BlendError {
InputCount {
poses: usize,
weights: usize,
},
PoseLength {
expected: usize,
actual: usize,
},
InvalidWeight,
ZeroWeight,
}Defined in crates/byte-engine/src/animation/blend.rs:268-287
Errors returned when local poses cannot be blended.
Variants
-
InputCountThe pose and weight counts differ, or no poses were supplied.
-
PoseLengthAn input pose does not match the output node count.
-
InvalidWeightA weight is negative or non-finite.
-
ZeroWeightAll supplied weights are zero.
Trait Implementations
impl ArchivePointee for BlendError
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for BlendError
impl Clone for BlendError
-
fn clone(&self) -> BlendErrorRelated:
BlendError
impl Copy for BlendError
impl Debug for BlendError
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Display for BlendError
-
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
impl Downcast for BlendError
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSync for BlendError
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl Eq for BlendError
impl<K> Equivalent for BlendError
-
fn equivalent(&self, key: &K) -> bool
impl Error for BlendError
impl Instrument for BlendError
impl LayoutRaw for BlendError
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for BlendError
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for BlendError
-
fn eq(&self, other: &BlendError) -> boolRelated:
BlendError
impl Pointee for BlendError
-
type Metadata = ()
impl Read for BlendError
impl StructuralPartialEq for BlendError
impl ToString for BlendError
-
fn to_string(&self) -> String
impl WithSubscriber for BlendError
BlendSpaceError
enum BlendSpaceError {
NotEnoughSamples {
minimum: usize,
},
NonFiniteSample,
SamplesNotStrictlyAscending,
NoTriangles,
TriangleSampleOutOfRange {
triangle: usize,
},
DegenerateTriangle {
triangle: usize,
},
NonFiniteParameter,
}Defined in crates/byte-engine/src/animation/blend.rs:316-340
Errors returned when constructing or evaluating a blend space.
Variants
-
NotEnoughSamplesThe blend space has fewer samples than its topology requires.
-
NonFiniteSampleA sample position contains a non-finite component.
-
SamplesNotStrictlyAscendingOne-dimensional sample positions are unsorted or duplicated.
-
NoTrianglesA two-dimensional blend space has no triangles.
-
TriangleSampleOutOfRangeA triangle references a sample outside the position list.
-
DegenerateTriangleA triangle uses repeated or collinear sample positions.
-
NonFiniteParameterThe evaluation parameter contains a non-finite component.
Trait Implementations
impl ArchivePointee for BlendSpaceError
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for BlendSpaceError
impl Clone for BlendSpaceError
-
fn clone(&self) -> BlendSpaceErrorRelated:
BlendSpaceError
impl Copy for BlendSpaceError
impl Debug for BlendSpaceError
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Display for BlendSpaceError
-
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
impl Downcast for BlendSpaceError
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl DowncastSync for BlendSpaceError
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl Eq for BlendSpaceError
impl<K> Equivalent for BlendSpaceError
-
fn equivalent(&self, key: &K) -> bool
impl Error for BlendSpaceError
impl Instrument for BlendSpaceError
impl LayoutRaw for BlendSpaceError
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for BlendSpaceError
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for BlendSpaceError
-
fn eq(&self, other: &BlendSpaceError) -> boolRelated:
BlendSpaceError
impl Pointee for BlendSpaceError
-
type Metadata = ()
impl Read for BlendSpaceError
impl StructuralPartialEq for BlendSpaceError
impl ToString for BlendSpaceError
-
fn to_string(&self) -> String
impl WithSubscriber for BlendSpaceError
Functions
blend_local_transform
fn blend_local_transform(left: resource_management::resources::skeleton::LocalTransform, right: resource_management::resources::skeleton::LocalTransform, factor: f32) -> resource_management::resources::skeleton::LocalTransformDefined in crates/byte-engine/src/animation/blend.rs:7-14
Blends two local transforms while preserving the shortest quaternion path.
blend_local_pose
fn blend_local_pose(left: &[resource_management::resources::skeleton::LocalTransform], right: &[resource_management::resources::skeleton::LocalTransform], factor: f32, output: &mut [resource_management::resources::skeleton::LocalTransform]) -> Result<(), BlendError>Defined in crates/byte-engine/src/animation/blend.rs:17-28
Blends two complete local poses into caller-owned storage.
blend_local_poses
fn blend_local_poses(poses: &[&[resource_management::resources::skeleton::LocalTransform]], weights: &[f32], output: &mut [resource_management::resources::skeleton::LocalTransform]) -> Result<(), BlendError>Defined in crates/byte-engine/src/animation/blend.rs:34-85
Blends any number of complete local poses with normalized non-negative weights.
Quaternion components use the first positively weighted pose as their hemisphere reference. This keeps antipodal representations from cancelling.