summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2024-09-21 06:28:11 -0700
committerK. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>2024-09-21 19:20:19 -0700
commitdd9525be040518bfbc401f5cb9c3a9fd2f34c442 (patch)
tree6e23764fe92f6b6e94ab667dad415d8b4d182202
parente4e024ab88efe74677769395886bc1b09eccbac7 (diff)
downloadredot-engine-dd9525be040518bfbc401f5cb9c3a9fd2f34c442.tar.gz
Fix animation compression going the wrong way
When compressing animation key frame indices the truncation breaks the animation near the border of pages. We use banker's rounding (FE_TONEAREST) as implemented by fast_ftoi to get the nearest integer frame.
-rw-r--r--scene/resources/animation.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index a2ed6af23c..eff0e883de 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -4804,9 +4804,9 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol
continue; // This track is exhausted (all keys were added already), don't consider.
}
}
-
- uint32_t key_frame = double(track_get_key_time(uncomp_track, time_tracks[i].key_index)) / frame_len;
-
+ double key_time = track_get_key_time(uncomp_track, time_tracks[i].key_index);
+ double result = key_time / frame_len;
+ uint32_t key_frame = Math::fast_ftoi(result);
if (time_tracks[i].needs_start_frame && key_frame > base_page_frame) {
start_frame = true;
best_frame = base_page_frame;