Byte Engine Docs
View on docs.rs

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

ItemKindDescription
BlendSpace1DstructThe BlendSpace1D struct stores validated scalar sample positions for allocation-free weight evaluation.
BlendSpace2DstructThe BlendSpace2D struct stores validated points and triangles for allocation-free directional blending.
BlendWeightsstructThe 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.
BlendErrorenumErrors returned when local poses cannot be blended.
BlendSpaceErrorenumErrors returned when constructing or evaluating a blend space.
blend_local_transformfnBlends two local transforms while preserving the shortest quaternion path.
blend_local_posefnBlends two complete local poses into caller-owned storage.
blend_local_posesfnBlends 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: BlendSpaceError

    Creates a blend space with finite, strictly ascending sample positions.

    Next, call Self::weights during evaluation and blend the weighted

    samples' poses with blend_local_poses.

  • fn len(&self) -> usize

    Returns the number of samples.

  • fn is_empty(&self) -> bool

    Returns whether the blend space contains no samples.

  • fn weights(&self, value: f32) -> Result<BlendWeights, BlendSpaceError>

    Related: BlendWeights, BlendSpaceError

    Returns 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
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) -> bool

    Related: 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: BlendSpaceError

    Creates 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::weights

    to find the containing triangle or the closest point on the triangulated

    boundary.

  • fn len(&self) -> usize

    Returns the number of samples.

  • fn is_empty(&self) -> bool

    Returns whether the blend space contains no samples.

  • fn weights(&self, value: [f32; 2]) -> Result<BlendWeights, BlendSpaceError>

    Related: BlendWeights, BlendSpaceError

    Returns 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
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) -> bool

    Related: 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) -> Self

    Returns 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
impl Copy for BlendWeights
impl Debug for BlendWeights
  • fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Default for 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) -> bool

    Related: 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

  • InputCount

    The pose and weight counts differ, or no poses were supplied.

  • PoseLength

    An input pose does not match the output node count.

  • InvalidWeight

    A weight is negative or non-finite.

  • ZeroWeight

    All 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) -> BlendError

    Related: 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) -> bool

    Related: 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

  • NotEnoughSamples

    The blend space has fewer samples than its topology requires.

  • NonFiniteSample

    A sample position contains a non-finite component.

  • SamplesNotStrictlyAscending

    One-dimensional sample positions are unsorted or duplicated.

  • NoTriangles

    A two-dimensional blend space has no triangles.

  • TriangleSampleOutOfRange

    A triangle references a sample outside the position list.

  • DegenerateTriangle

    A triangle uses repeated or collinear sample positions.

  • NonFiniteParameter

    The 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
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
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::LocalTransform

Defined 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.

On this page

Module blendContentsQuick ReferenceStructsBlendSpace1DImplementationsTrait Implementationsimpl ArchivePointee for BlendSpace1Dimpl<ST> CastableFrom for BlendSpace1Dimpl Clone for BlendSpace1Dimpl Debug for BlendSpace1Dimpl Downcast for BlendSpace1Dimpl DowncastSync for BlendSpace1Dimpl Instrument for BlendSpace1Dimpl LayoutRaw for BlendSpace1Dimpl<T, N1> Niching for BlendSpace1Dimpl PartialEq for BlendSpace1Dimpl Pointee for BlendSpace1Dimpl Read for BlendSpace1Dimpl StructuralPartialEq for BlendSpace1Dimpl WithSubscriber for BlendSpace1DBlendSpace2DImplementationsTrait Implementationsimpl ArchivePointee for BlendSpace2Dimpl<ST> CastableFrom for BlendSpace2Dimpl Clone for BlendSpace2Dimpl Debug for BlendSpace2Dimpl Downcast for BlendSpace2Dimpl DowncastSync for BlendSpace2Dimpl Instrument for BlendSpace2Dimpl LayoutRaw for BlendSpace2Dimpl<T, N1> Niching for BlendSpace2Dimpl PartialEq for BlendSpace2Dimpl Pointee for BlendSpace2Dimpl Read for BlendSpace2Dimpl StructuralPartialEq for BlendSpace2Dimpl WithSubscriber for BlendSpace2DBlendWeightsImplementationsTrait Implementationsimpl ArchivePointee for BlendWeightsimpl<ST> CastableFrom for BlendWeightsimpl Clone for BlendWeightsimpl Copy for BlendWeightsimpl Debug for BlendWeightsimpl Default for BlendWeightsimpl Downcast for BlendWeightsimpl DowncastSync for BlendWeightsimpl Instrument for BlendWeightsimpl LayoutRaw for BlendWeightsimpl<T, N1> Niching for BlendWeightsimpl PartialEq for BlendWeightsimpl Pointee for BlendWeightsimpl Read for BlendWeightsimpl<R> ReadPrimitive for BlendWeightsimpl StructuralPartialEq for BlendWeightsimpl WithSubscriber for BlendWeightsEnumsBlendErrorVariantsTrait Implementationsimpl ArchivePointee for BlendErrorimpl<ST> CastableFrom for BlendErrorimpl Clone for BlendErrorimpl Copy for BlendErrorimpl Debug for BlendErrorimpl Display for BlendErrorimpl Downcast for BlendErrorimpl DowncastSync for BlendErrorimpl Eq for BlendErrorimpl<K> Equivalent for BlendErrorimpl Error for BlendErrorimpl Instrument for BlendErrorimpl LayoutRaw for BlendErrorimpl<T, N1> Niching for BlendErrorimpl PartialEq for BlendErrorimpl Pointee for BlendErrorimpl Read for BlendErrorimpl StructuralPartialEq for BlendErrorimpl ToString for BlendErrorimpl WithSubscriber for BlendErrorBlendSpaceErrorVariantsTrait Implementationsimpl ArchivePointee for BlendSpaceErrorimpl<ST> CastableFrom for BlendSpaceErrorimpl Clone for BlendSpaceErrorimpl Copy for BlendSpaceErrorimpl Debug for BlendSpaceErrorimpl Display for BlendSpaceErrorimpl Downcast for BlendSpaceErrorimpl DowncastSync for BlendSpaceErrorimpl Eq for BlendSpaceErrorimpl<K> Equivalent for BlendSpaceErrorimpl Error for BlendSpaceErrorimpl Instrument for BlendSpaceErrorimpl LayoutRaw for BlendSpaceErrorimpl<T, N1> Niching for BlendSpaceErrorimpl PartialEq for BlendSpaceErrorimpl Pointee for BlendSpaceErrorimpl Read for BlendSpaceErrorimpl StructuralPartialEq for BlendSpaceErrorimpl ToString for BlendSpaceErrorimpl WithSubscriber for BlendSpaceErrorFunctionsblend_local_transformblend_local_poseblend_local_poses