Skip to content

Commit ac8137b

Browse files
committed
fix(ltk_anim): small issues
1 parent 5cf7e9e commit ac8137b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

crates/ltk_anim/src/asset/compressed/evaluator.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,8 @@ impl<'a> CompressedEvaluator<'a> {
7777
self.animation
7878
.joints
7979
.iter()
80-
.enumerate()
81-
.map(|(id, &hash)| {
82-
(
83-
hash,
84-
self.state.hot_frames[id].sample(compressed_time, parametrized),
85-
)
86-
})
80+
.zip(self.state.hot_frames.iter())
81+
.map(|(&hash, hot_frame)| (hash, hot_frame.sample(compressed_time, parametrized)))
8782
.collect()
8883
}
8984

crates/ltk_anim/src/asset/uncompressed/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ impl Uncompressed {
4848
joint_frames: HashMap<u32, Vec<UncompressedFrame>>,
4949
) -> Self {
5050
let frame_count = joint_frames.values().next().map(|f| f.len()).unwrap_or(0);
51-
let duration = frame_count as f32 / fps;
51+
let duration = if fps > 0.0 {
52+
frame_count as f32 / fps
53+
} else {
54+
0.0
55+
};
5256
Self {
5357
duration,
5458
fps,

crates/ltk_anim/src/asset/uncompressed/write.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ impl Uncompressed {
8282

8383
// Write joint hashes
8484
let joint_hashes_offset = writer.stream_position()? as i32 - 12;
85-
let joint_hashes: Vec<u32> = self.joint_frames.keys().copied().collect();
85+
let mut joint_hashes: Vec<u32> = self.joint_frames.keys().copied().collect();
86+
joint_hashes.sort_unstable();
8687
for hash in &joint_hashes {
8788
writer.write_u32::<LE>(*hash)?;
8889
}

0 commit comments

Comments
 (0)