1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use std::collections::HashMap;
pub use self::action_keyframes::*;
pub use self::bone_keyframes::*;
use crate::Keyframe;
type Frame = u16;
mod action_keyframes;
mod bone_keyframes;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Action {
pub(super) bone_keyframes: BoneKeyframes,
#[serde(default)]
pose_markers: HashMap<Frame, String>,
}
impl Action {
#[allow(missing_docs)]
pub fn new() -> Self {
Action {
bone_keyframes: BoneKeyframes::default(),
pose_markers: HashMap::new(),
}
}
#[cfg(test)]
pub(crate) fn new_with_keyframes(keyframes: Vec<BoneKeyframe>) -> Self {
Action {
bone_keyframes: BoneKeyframes::new_with_keyframes(keyframes),
pose_markers: HashMap::new(),
}
}
pub fn bone_keyframes(&self) -> &BoneKeyframes {
&self.bone_keyframes
}
pub fn insert_bone_keyframe(&mut self, bone_idx: u8, keyframe: BoneKeyframe) {
self.bone_keyframes.insert_bone_keyframe(bone_idx, keyframe);
}
pub fn pose_markers(&self) -> &HashMap<Frame, String> {
&self.pose_markers
}
pub fn pose_markers_mut(&mut self) -> &mut HashMap<Frame, String> {
&mut self.pose_markers
}
pub fn smallest_frame(&self) -> u16 {
self.bone_keyframes.frame_range_inclusive().unwrap().0
}
pub fn largest_frame(&self) -> u16 {
self.bone_keyframes.frame_range_inclusive().unwrap().1
}
pub fn frame_duration(&self) -> u16 {
self.bone_keyframes.frame_duration().unwrap()
}
}
impl Action {
pub(crate) fn keyframes_mut(&mut self) -> &mut HashMap<u8, SortedKeyframes> {
self.bone_keyframes.keyframes_mut()
}
}