use crate::{Result, core::Transform};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum AnimWrapMode {
#[default]
Clamp,
Loop,
}
#[derive(Clone, Debug, PartialEq)]
pub struct AnimClip {
pub(crate) skeleton_id: u32,
pub(crate) joint_count: u32,
pub(crate) frame_count: u32,
pub(crate) frames_per_second: f32,
pub(crate) samples: Vec<Transform>,
}
impl AnimClip {
pub fn skeleton_id(&self) -> u32 {
self.skeleton_id
}
pub fn joint_count(&self) -> u32 {
self.joint_count
}
pub fn frame_count(&self) -> u32 {
self.frame_count
}
pub fn frames_per_second(&self) -> f32 {
self.frames_per_second
}
pub fn duration_seconds(&self) -> f64 {
if self.frame_count <= 1 || self.frames_per_second <= 0.0 {
return 0.0;
}
f64::from(self.frame_count - 1) / f64::from(self.frames_per_second)
}
pub fn samples(&self) -> &[Transform] {
&self.samples
}
pub fn sample(&self, time_seconds: f64, wrap_mode: AnimWrapMode) -> Result<super::SkelPose> {
super::sample_clip(self, time_seconds, wrap_mode)
}
}