Skip to main content

SkeletonPose

Struct SkeletonPose 

Source
pub struct SkeletonPose {
    pub mesh_id: SkinnedMeshHandle,
    pub skinned_index: usize,
    pub skeleton: Skeleton,
    pub joint_matrices: Vec<Mat4>,
    pub morph_weights: Vec<f32>,
    pub morph_base: Vec<f32>,
    pub proportions: ProportionLayer,
    pub updated: bool,
    pub scratch: PoseScratch,
}
Expand description

Runtime-only link between a skinned mesh and its animation state.

GraphicsSystem publishes one SkeletonPose per SkinnedMesh during init: it carries the resolved bind-pose Skeleton and the index of the mesh’s skinned draw object in the backend. AnimationSystem then ticks the matching Animation clip each frame and writes the resulting skinning matrices into joint_matrices; GraphicsSystem reads them back and uploads them to the GPU. The one-frame producer/consumer hand-off is invisible at animation rates.

A CharacterShape targeting the mesh seeds the static layers: morph_base sits under every clip’s morph track and proportions re-shapes every sampled pose before skinning.

Not authored in world files: it has no args.

Fields§

§mesh_id: SkinnedMeshHandle

The SkinnedMesh resource this pose belongs to. Used by AnimationSystem to match an Animation clip to its target.

§skinned_index: usize

Index of this mesh’s skinned draw object in the render backend.

§skeleton: Skeleton

Bind-pose joint hierarchy, used to compose skinning matrices.

§joint_matrices: Vec<Mat4>

Current skinning matrices, one per joint. Seeded to the bind pose (identity skinning) and overwritten by AnimationSystem each frame.

§morph_weights: Vec<f32>

Current morph-target weights, one per target of the mesh: the base layer plus whatever a clip’s morph track adds. Empty for a mesh with neither a base layer nor a morph clip.

§morph_base: Vec<f32>

Static morph weights from the mesh’s CharacterShape, one per target; empty without one. Clip morph tracks are added onto these.

§proportions: ProportionLayer

Per-joint proportion changes from the mesh’s CharacterShape, applied to every sampled pose before the skinning matrices are built.

§updated: bool

True while joint_matrices / morph_weights hold data the render backend has not consumed yet. Set by whoever writes the pose, cleared after upload, so an unanimated pose is uploaded exactly once.

§scratch: PoseScratch

Reusable sampling buffers owned by this pose, so the per-frame sample/blend/skinning chain allocates nothing in steady state.

Implementations§

Source§

impl SkeletonPose

Source

pub fn new( mesh_id: SkinnedMeshHandle, skinned_index: usize, skeleton: Skeleton, ) -> Self

Build a pose for mesh_id’s skinned draw object, seeded to the bind pose so the mesh renders undeformed until an animation drives it.

Source

pub fn with_shape( self, morph_base: Vec<f32>, proportions: ProportionLayer, ) -> Self

Install the static shape layers and re-seed the rest pose through them, so a mesh with no clip renders shaped.

Source

pub fn set_shape(&mut self, morph_base: Vec<f32>, proportions: ProportionLayer)

Replace the static shape layers in place and re-seed the rest pose through them; an animated pose picks the new layers up on its next sample. For editing a shape on a live pose without rebuilding it.

Source

pub fn clone_for_slot(&self, skinned_index: usize) -> Self

A fresh pose sharing this one’s skeleton and shape layers, for a runtime-spawned copy of the mesh at draw slot skinned_index.

Trait Implementations§

Source§

impl Component for SkeletonPose

Source§

const NAME: &'static str = "SkeletonPose"

The registry name a world authors this component under.
Source§

fn from_baked(_bytes: &[u8]) -> Result<Self, CnResult>

Reconstruct this component from a blob record, whose bytes are the serialized runtime component (cook already ran the asset -> component translation). The default rejects: runtime-only components are never stored in a blob, so only loadable types provide an implementation.
Source§

fn inject_locator(&mut self, _locator: PayloadLocator)

Called after construction to inject the payload locator from the blob def. Only meaningful for components with a compiled payload. The default implementation does nothing (correct for most components).
Source§

fn inject_name(&mut self, _id: AssetId)

Called after construction to inject the asset’s identity from the blob def. Only meaningful for components that look themselves up by id at runtime. The default implementation does nothing.
Source§

impl ComponentSlot for SkeletonPose

Source§

const DISCRIMINANT: u8

The component type’s stable id, used as its ComponentId.
Source§

fn slot(s: &ComponentStorage) -> &Column<Self>

Borrow this type’s column out of the storage.
Source§

fn slot_mut(s: &mut ComponentStorage) -> &mut Column<Self>

Mutably borrow this type’s column out of the storage.
Source§

impl Debug for SkeletonPose

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<SkeletonPose> for ComponentAsset

Source§

fn from(c: SkeletonPose) -> Self

Converts to this type from the input type.
Source§

impl RuntimeComponent for SkeletonPose

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.