pub struct Model { /* private fields */ }Expand description
A validated HMA1 blob.
The decoder reads keys without bounds checks, so the only way to build
one is Model::new, which walks every clip and bone once and proves
that no playback position can read outside the blob. The fields are
private so safe code cannot widen what was proven.
Implementations§
Source§impl Model
impl Model
Sourcepub fn new(d: &'static [u8]) -> Option<Model>
pub fn new(d: &'static [u8]) -> Option<Model>
Validate and wrap an HMA1 blob. None when any clip, at any playback
position, would read outside d, when a bone’s parent does not come
before it (the decoder composes parents first), or when there are no
clips.
Sourcepub fn bone_count(&self) -> usize
pub fn bone_count(&self) -> usize
Number of bones; decode needs this many Affine slots.
Sourcepub fn clip_count(&self) -> usize
pub fn clip_count(&self) -> usize
Number of clips in the blob (at least one).
Sourcepub fn clip_intervals(&self, clip: usize) -> u32
pub fn clip_intervals(&self, clip: usize) -> u32
Source frame intervals of clip (numframes - 1, at least 1): the
clip’s position runs 0..=clip_intervals * 256. Clips past the last
read the last.
Sourcepub fn decode(&self, clip: usize, pos_q8: u32, out: &mut [Affine])
pub fn decode(&self, clip: usize, pos_q8: u32, out: &mut [Affine])
Decode every bone of clip at pos_q8 into model-space affines.
Clips past the last decode the last; an out shorter than
Model::bone_count is left untouched.
Sourcepub fn decode_with(
&self,
clip: usize,
pos_q8: u32,
jaw: &Jaw,
out: &mut [Affine],
)
pub fn decode_with( &self, clip: usize, pos_q8: u32, jaw: &Jaw, out: &mut [Affine], )
Model::decode with a local controller rotation on one bone.
out must hold at least n_bones entries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Model
impl RefUnwindSafe for Model
impl !Send for Model
impl !Sync for Model
impl Unpin for Model
impl UnsafeUnpin for Model
impl UnwindSafe for Model
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)