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.
BlendTrianglestructThe BlendTriangle struct identifies three sample indices forming one non-degenerate 2D blend region.
BlendSpace2DstructThe BlendSpace2D struct stores validated points and triangles for allocation-free directional blending.
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:92-94

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::write_weights during evaluation and pass the weights

    to blend_local_poses.

  • fn len(&self) -> usize

    Returns the number of samples and weights required by Self::write_weights.

  • fn is_empty(&self) -> bool

    Returns whether the blend space contains no samples.

  • fn write_weights(&self, value: f32, output: &mut [f32]) -> Result<(), BlendSpaceError>

    Related: BlendSpaceError

    Writes normalized weights for a scalar parameter, clamping outside the sample range.

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 DowncastSend for BlendSpace1D
  • fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for BlendSpace1D
  • fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
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 Pointable for BlendSpace1D
  • const ALIGN: usize
  • type Init = T
  • unsafe fn init(init: <T as Pointable>::Init) -> usize
  • unsafe fn deref<'a>(ptr: usize) -> &'a T
  • unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
  • unsafe fn drop(ptr: usize)
impl Pointee for BlendSpace1D
  • type Metadata = ()
impl Read for BlendSpace1D
impl StructuralPartialEq for BlendSpace1D
impl WithSubscriber for BlendSpace1D

BlendTriangle

struct BlendTriangle([usize; 3]);

Defined in crates/byte-engine/src/animation/blend.rs:154-157

The BlendTriangle struct identifies three sample indices forming one non-degenerate 2D blend region.

Trait Implementations

impl ArchivePointee for BlendTriangle
  • type ArchivedMetadata = ()
  • fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for BlendTriangle
impl Clone for BlendTriangle
impl Copy for BlendTriangle
impl Debug for BlendTriangle
  • fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Downcast for BlendTriangle
  • 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 DowncastSend for BlendTriangle
  • fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for BlendTriangle
  • fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
impl Eq for BlendTriangle
impl<K> Equivalent for BlendTriangle
  • fn equivalent(&self, key: &K) -> bool
impl Instrument for BlendTriangle
impl LayoutRaw for BlendTriangle
  • fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for BlendTriangle
  • unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
  • fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl PartialEq for BlendTriangle
  • fn eq(&self, other: &BlendTriangle) -> bool

    Related: BlendTriangle

impl Pointable for BlendTriangle
  • const ALIGN: usize
  • type Init = T
  • unsafe fn init(init: <T as Pointable>::Init) -> usize
  • unsafe fn deref<'a>(ptr: usize) -> &'a T
  • unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
  • unsafe fn drop(ptr: usize)
impl Pointee for BlendTriangle
  • type Metadata = ()
impl Read for BlendTriangle
impl StructuralPartialEq for BlendTriangle
impl WithSubscriber for BlendTriangle

BlendSpace2D

struct BlendSpace2D {
    // [REDACTED: Private Fields]
}

Defined in crates/byte-engine/src/animation/blend.rs:161-164

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<BlendTriangle>>) -> Result<Self, BlendSpaceError>

    Related: BlendTriangle, BlendSpaceError

    Creates a triangulated blend space.

    Triangles may share edges but must not be degenerate. Next, call

    Self::write_weights to find the containing triangle or the closest

    point on the triangulated boundary.

  • fn len(&self) -> usize

    Returns the number of samples and weights required by Self::write_weights.

  • fn is_empty(&self) -> bool

    Returns whether the blend space contains no samples.

  • fn write_weights(&self, value: [f32; 2], output: &mut [f32]) -> Result<(), BlendSpaceError>

    Related: BlendSpaceError

    Writes normalized weights for a 2D parameter without allocating.

    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 DowncastSend for BlendSpace2D
  • fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for BlendSpace2D
  • fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
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 Pointable for BlendSpace2D
  • const ALIGN: usize
  • type Init = T
  • unsafe fn init(init: <T as Pointable>::Init) -> usize
  • unsafe fn deref<'a>(ptr: usize) -> &'a T
  • unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
  • unsafe fn drop(ptr: usize)
impl Pointee for BlendSpace2D
  • type Metadata = ()
impl Read for BlendSpace2D
impl StructuralPartialEq for BlendSpace2D
impl WithSubscriber for BlendSpace2D

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:260-279

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 DowncastSend for BlendError
  • fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for BlendError
  • fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
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 Pointable for BlendError
  • const ALIGN: usize
  • type Init = T
  • unsafe fn init(init: <T as Pointable>::Init) -> usize
  • unsafe fn deref<'a>(ptr: usize) -> &'a T
  • unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
  • unsafe fn drop(ptr: usize)
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,
    },
    OutputLength {
        expected: usize,
        actual: usize,
    },
    NonFiniteParameter,
}

Defined in crates/byte-engine/src/animation/blend.rs:308-339

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.

  • OutputLength

    The output slice cannot hold one weight per sample.

  • 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 DowncastSend for BlendSpaceError
  • fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
impl DowncastSync for BlendSpaceError
  • fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
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 Pointable for BlendSpaceError
  • const ALIGN: usize
  • type Init = T
  • unsafe fn init(init: <T as Pointable>::Init) -> usize
  • unsafe fn deref<'a>(ptr: usize) -> &'a T
  • unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
  • unsafe fn drop(ptr: usize)
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:8-15

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:18-29

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:35-88

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 DowncastSend for BlendSpace1Dimpl DowncastSync for BlendSpace1Dimpl Instrument for BlendSpace1Dimpl LayoutRaw for BlendSpace1Dimpl<T, N1> Niching for BlendSpace1Dimpl PartialEq for BlendSpace1Dimpl Pointable for BlendSpace1Dimpl Pointee for BlendSpace1Dimpl Read for BlendSpace1Dimpl StructuralPartialEq for BlendSpace1Dimpl WithSubscriber for BlendSpace1DBlendTriangleTrait Implementationsimpl ArchivePointee for BlendTriangleimpl<ST> CastableFrom for BlendTriangleimpl Clone for BlendTriangleimpl Copy for BlendTriangleimpl Debug for BlendTriangleimpl Downcast for BlendTriangleimpl DowncastSend for BlendTriangleimpl DowncastSync for BlendTriangleimpl Eq for BlendTriangleimpl<K> Equivalent for BlendTriangleimpl Instrument for BlendTriangleimpl LayoutRaw for BlendTriangleimpl<T, N1> Niching for BlendTriangleimpl PartialEq for BlendTriangleimpl Pointable for BlendTriangleimpl Pointee for BlendTriangleimpl Read for BlendTriangleimpl StructuralPartialEq for BlendTriangleimpl WithSubscriber for BlendTriangleBlendSpace2DImplementationsTrait Implementationsimpl ArchivePointee for BlendSpace2Dimpl<ST> CastableFrom for BlendSpace2Dimpl Clone for BlendSpace2Dimpl Debug for BlendSpace2Dimpl Downcast for BlendSpace2Dimpl DowncastSend for BlendSpace2Dimpl DowncastSync for BlendSpace2Dimpl Instrument for BlendSpace2Dimpl LayoutRaw for BlendSpace2Dimpl<T, N1> Niching for BlendSpace2Dimpl PartialEq for BlendSpace2Dimpl Pointable for BlendSpace2Dimpl Pointee for BlendSpace2Dimpl Read for BlendSpace2Dimpl StructuralPartialEq for BlendSpace2Dimpl WithSubscriber for BlendSpace2DEnumsBlendErrorVariantsTrait Implementationsimpl ArchivePointee for BlendErrorimpl<ST> CastableFrom for BlendErrorimpl Clone for BlendErrorimpl Copy for BlendErrorimpl Debug for BlendErrorimpl Display for BlendErrorimpl Downcast for BlendErrorimpl DowncastSend 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 Pointable 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 DowncastSend 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 Pointable for BlendSpaceErrorimpl Pointee for BlendSpaceErrorimpl Read for BlendSpaceErrorimpl StructuralPartialEq for BlendSpaceErrorimpl ToString for BlendSpaceErrorimpl WithSubscriber for BlendSpaceErrorFunctionsblend_local_transformblend_local_poseblend_local_poses