goud_engine/ecs/components/skeleton2d/animation.rs
1//! Skeletal animation data types.
2//!
3//! Defines keyframe tracks that drive bone transforms over time.
4//! A [`SkeletalAnimation`] contains one [`BoneTrack`] per animated bone,
5//! each holding a sorted list of [`BoneKeyframe`]s.
6
7use super::types::BoneTransform;
8
9/// A single keyframe storing a bone transform at a specific time.
10#[derive(Debug, Clone)]
11pub struct BoneKeyframe {
12 /// Time in seconds from the start of the animation.
13 pub time: f32,
14 /// Bone transform at this keyframe.
15 pub transform: BoneTransform,
16}
17
18/// Timeline of keyframes for one bone.
19#[derive(Debug, Clone)]
20pub struct BoneTrack {
21 /// Index into [`Skeleton2D::bones`](super::Skeleton2D) identifying
22 /// which bone this track animates.
23 pub bone_id: usize,
24 /// Keyframes sorted by ascending `time`.
25 pub keyframes: Vec<BoneKeyframe>,
26}
27
28/// A complete skeletal animation clip.
29#[derive(Debug, Clone)]
30pub struct SkeletalAnimation {
31 /// Human-readable name (e.g. "walk", "idle").
32 pub name: String,
33 /// Total duration in seconds.
34 pub duration: f32,
35 /// Per-bone keyframe tracks.
36 pub tracks: Vec<BoneTrack>,
37 /// Whether the animation loops back to the start.
38 pub looping: bool,
39}