pub struct SkinningPlugin { /* private fields */ }Expand description
Handle to the GPU skinning deformer.
Returned by SkinningPlugin::install. Holds the assigned
DeformerId plus a marker set tracking which meshes have had weights
attached, so Self::is_skinned_mesh can answer without going through
the registry. Clone-cheap: the marker set is shared.
Implementations§
Source§impl SkinningPlugin
impl SkinningPlugin
Sourcepub fn install(
resources: &mut DeviceResources,
device: &Device,
) -> ViewportResult<Self>
pub fn install( resources: &mut DeviceResources, device: &Device, ) -> ViewportResult<Self>
Register the skinning deformer with the renderer.
Call once at startup before uploading any skin data. Composes the LBS body into the mesh shader family and validates the result through wgpu’s error scope.
§Errors
Propagates the registry error if shader composition or validation fails (extremely unlikely for the shipped body, which is covered by unit tests).
Sourcepub fn deformer_id(&self) -> DeformerId
pub fn deformer_id(&self) -> DeformerId
The DeformerId assigned to skinning on install.
Sourcepub fn attach_weights(
&self,
resources: &mut DeviceResources,
device: &Device,
mesh_id: MeshId,
weights: &SkinWeights,
)
pub fn attach_weights( &self, resources: &mut DeviceResources, device: &Device, mesh_id: MeshId, weights: &SkinWeights, )
Attach per-vertex skin weights to an uploaded mesh.
Marks the mesh as skinnable and packs the weights into the deformer’s per-mesh slot. Calling again on the same mesh replaces the prior weights buffer.
Sourcepub fn begin_upload_weights(
&self,
resources: &mut DeviceResources,
device: &Device,
mesh_id: MeshId,
weights: SkinWeights,
) -> JobId
pub fn begin_upload_weights( &self, resources: &mut DeviceResources, device: &Device, mesh_id: MeshId, weights: SkinWeights, ) -> JobId
Start an asynchronous skin-weights upload.
Returns a JobId immediately. The packed weight stream is computed on
a worker thread; buffer creation runs on the main thread during the
next process_uploads call after the worker finishes.
Sourcepub fn attach_palette(
&self,
resources: &mut DeviceResources,
device: &Device,
queue: &Queue,
mesh_id: MeshId,
instance_id: u32,
palette: &[Mat4],
) -> bool
pub fn attach_palette( &self, resources: &mut DeviceResources, device: &Device, queue: &Queue, mesh_id: MeshId, instance_id: u32, palette: &[Mat4], ) -> bool
Upload the joint palette for one instance of a skinned mesh.
instance_id lets multiple skinned instances of one bind-pose mesh
coexist. For single-instance meshes pass 0. Returns false if
Self::attach_weights has not been called for mesh_id.
palette[i] is the object-space skinning matrix for joint i
produced by [crate::JointMatrices::compute]: the joint’s
skeleton-local transform multiplied by its inverse bind. The mesh’s
object.model is applied separately at draw time, so the palette
composes with the scene node transform rather than replacing it.
Sourcepub fn is_skinned_mesh(&self, mesh_id: MeshId) -> bool
pub fn is_skinned_mesh(&self, mesh_id: MeshId) -> bool
Whether mesh_id has been marked as skinnable via
Self::attach_weights.
Sourcepub fn detach_weights(
&self,
resources: &mut DeviceResources,
device: &Device,
mesh_id: MeshId,
) -> bool
pub fn detach_weights( &self, resources: &mut DeviceResources, device: &Device, mesh_id: MeshId, ) -> bool
Detach the skin weights attached to mesh_id and unmark it as skinnable.
Reverses attach_weights: reclaims the per-mesh
weight buffer and drops the mesh from the skinnable set, so it renders as
a static mesh afterward (the deformer branch gates off once its slot has
no data). Returns true if weights were removed, false if the mesh had
none. Any joint palettes attached for the mesh become inert; reclaim them
with detach_palette or by freeing the mesh.
Sourcepub fn detach_palette(
&self,
resources: &mut DeviceResources,
device: &Device,
queue: &Queue,
mesh_id: MeshId,
instance_id: u32,
) -> bool
pub fn detach_palette( &self, resources: &mut DeviceResources, device: &Device, queue: &Queue, mesh_id: MeshId, instance_id: u32, ) -> bool
Detach the joint palette for one instance of a skinned mesh.
Reverses attach_palette for a single
(mesh_id, instance_id) pair, reclaiming that palette buffer. Returns
true if a palette was removed, false if none was attached. Leaves the
mesh’s weight slot and skinnable marker in place.
Sourcepub fn uninstall(self, resources: &mut DeviceResources, device: &Device)
pub fn uninstall(self, resources: &mut DeviceResources, device: &Device)
Tear down every per-mesh skin buffer attached through this handle.
Detaches the weight slot of every mesh marked skinnable and clears the
marker set, reclaiming that GPU memory. Consumes the handle: its
lifecycle is install -> attach_weights / attach_palette (or the
begin_upload_weights / event forms) -> uninstall.
The deformer body itself stays registered for the session: DeformerId
is an append-only registry slot, so a later install
returns the same id at no cost. Per-instance palettes are keyed by
(mesh, instance) and are not tracked here; reclaim them with
detach_palette or by freeing the meshes before
uninstalling if their buffers must go immediately.
Trait Implementations§
Source§impl Clone for SkinningPlugin
impl Clone for SkinningPlugin
Source§fn clone(&self) -> SkinningPlugin
fn clone(&self) -> SkinningPlugin
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SkinningPlugin
impl RefUnwindSafe for SkinningPlugin
impl Send for SkinningPlugin
impl Sync for SkinningPlugin
impl Unpin for SkinningPlugin
impl UnsafeUnpin for SkinningPlugin
impl UnwindSafe for SkinningPlugin
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.