pub struct IncrementalMorphCache { /* private fields */ }Expand description
Caches the weighted contribution of each morph target so that a full summation is only needed once; subsequent updates recompute only the targets that changed.
Implementations§
Source§impl IncrementalMorphCache
impl IncrementalMorphCache
Sourcepub fn new(vertex_count: usize) -> Self
pub fn new(vertex_count: usize) -> Self
Create a new empty cache for a mesh with vertex_count vertices.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Return the vertex count this cache was created for.
Sourcepub fn target_count(&self) -> usize
pub fn target_count(&self) -> usize
Number of cached target contributions.
Sourcepub fn update_target(
&mut self,
name: &str,
deltas: &[(u32, f32, f32, f32)],
weight: f32,
vertex_count: usize,
)
pub fn update_target( &mut self, name: &str, deltas: &[(u32, f32, f32, f32)], weight: f32, vertex_count: usize, )
Update (or insert) the cached contribution for target name.
deltas is a slice of (vertex_id, dx, dy, dz) sparse deltas and
weight is the scalar weight to multiply them by. The contribution
buffer is zeroed first, then the weighted deltas are scattered in.
Sourcepub fn remove_target(&mut self, name: &str)
pub fn remove_target(&mut self, name: &str)
Remove a target’s contribution from the cache.
Sourcepub fn rebuild_mesh(&self, base_positions: &[f32]) -> Vec<f32>
pub fn rebuild_mesh(&self, base_positions: &[f32]) -> Vec<f32>
Full rebuild: base_positions + sum(all contributions).
base_positions is a flat [x0, y0, z0, x1, y1, z1, ...] array of
length vertex_count * 3. Returns a new flat position buffer of the
same layout.
Sourcepub fn rebuild_incremental(
&self,
current: &mut [f32],
dirty: &DirtyTracker,
old_contributions: &HashMap<String, Vec<f32>>,
)
pub fn rebuild_incremental( &self, current: &mut [f32], dirty: &DirtyTracker, old_contributions: &HashMap<String, Vec<f32>>, )
Incremental rebuild: only recompute dirty targets.
current is the mesh position buffer from the previous frame (mutated
in-place). For each dirty target the old contribution is subtracted
and the new one (already stored via update_target) is added.
old_contributions maps target name -> the previous contribution
buffer that was already baked into current. After this call,
current reflects the latest cached contributions.
Targets present in the dirty set but absent from old_contributions
are treated as newly added (old contribution is zero).
Sourcepub fn snapshot_contribution(&self, name: &str) -> Option<Vec<f32>>
pub fn snapshot_contribution(&self, name: &str) -> Option<Vec<f32>>
Snapshot the current contribution buffer for a target (for use as
old_contributions in the next incremental rebuild).
Trait Implementations§
Source§impl Clone for IncrementalMorphCache
impl Clone for IncrementalMorphCache
Source§fn clone(&self) -> IncrementalMorphCache
fn clone(&self) -> IncrementalMorphCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for IncrementalMorphCache
impl RefUnwindSafe for IncrementalMorphCache
impl Send for IncrementalMorphCache
impl Sync for IncrementalMorphCache
impl Unpin for IncrementalMorphCache
impl UnsafeUnpin for IncrementalMorphCache
impl UnwindSafe for IncrementalMorphCache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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