pub struct SkeletonPose {
pub mesh_id: SkinnedMeshHandle,
pub skinned_index: usize,
pub skeleton: Skeleton,
pub joint_matrices: Vec<[[f32; 4]; 4]>,
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: SkinnedMeshHandleThe SkinnedMesh resource this pose belongs to. Used by
AnimationSystem to match an Animation clip to its target.
skinned_index: usizeIndex of this mesh’s skinned draw object in the render backend.
skeleton: SkeletonBind-pose joint hierarchy, used to compose skinning matrices.
joint_matrices: Vec<[[f32; 4]; 4]>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: ProportionLayerPer-joint proportion changes from the mesh’s CharacterShape, applied
to every sampled pose before the skinning matrices are built.
updated: boolTrue 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: PoseScratchReusable sampling buffers owned by this pose, so the per-frame sample/blend/skinning chain allocates nothing in steady state.
Implementations§
Source§impl SkeletonPose
impl SkeletonPose
Sourcepub fn new(
mesh_id: SkinnedMeshHandle,
skinned_index: usize,
skeleton: Skeleton,
) -> SkeletonPose
pub fn new( mesh_id: SkinnedMeshHandle, skinned_index: usize, skeleton: Skeleton, ) -> SkeletonPose
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.
Sourcepub fn with_shape(
self,
morph_base: Vec<f32>,
proportions: ProportionLayer,
) -> SkeletonPose
pub fn with_shape( self, morph_base: Vec<f32>, proportions: ProportionLayer, ) -> SkeletonPose
Install the static shape layers and re-seed the rest pose through them, so a mesh with no clip renders shaped.
Sourcepub fn set_shape(&mut self, morph_base: Vec<f32>, proportions: ProportionLayer)
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.
Sourcepub fn clone_for_slot(&self, skinned_index: usize) -> SkeletonPose
pub fn clone_for_slot(&self, skinned_index: usize) -> SkeletonPose
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
impl Component for SkeletonPose
Source§const NAME: &'static str = "SkeletonPose"
const NAME: &'static str = "SkeletonPose"
Source§fn from_baked(_bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(_bytes: &[u8]) -> Result<Self, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Source§impl ComponentSlot for SkeletonPose
impl ComponentSlot for SkeletonPose
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§fn slot(s: &ComponentStorage) -> &Column<SkeletonPose>
fn slot(s: &ComponentStorage) -> &Column<SkeletonPose>
Source§fn slot_mut(s: &mut ComponentStorage) -> &mut Column<SkeletonPose>
fn slot_mut(s: &mut ComponentStorage) -> &mut Column<SkeletonPose>
Source§impl Debug for SkeletonPose
impl Debug for SkeletonPose
Source§impl From<SkeletonPose> for ComponentAsset
impl From<SkeletonPose> for ComponentAsset
Source§fn from(c: SkeletonPose) -> ComponentAsset
fn from(c: SkeletonPose) -> ComponentAsset
impl RuntimeComponent for SkeletonPose
Auto Trait Implementations§
impl Freeze for SkeletonPose
impl RefUnwindSafe for SkeletonPose
impl Send for SkeletonPose
impl Sync for SkeletonPose
impl Unpin for SkeletonPose
impl UnsafeUnpin for SkeletonPose
impl UnwindSafe for SkeletonPose
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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