diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-27 15:42:05 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-27 15:42:05 +0100 |
commit | 1bf7b84fbff4ff648ea0f56842cf287724a1c9b8 (patch) | |
tree | 20d55fb21667f642195d7510113dad67d47c0497 | |
parent | 8a1369192ea1c3a82ac50b0b878a99d29f2c1282 (diff) | |
parent | 95244f0e7a81a340af6810dd4dbf033449045b91 (diff) |
Merge pull request #62123 from holgac/bugfix-62097
Fix infinite loop in animation compress
-rw-r--r-- | scene/resources/animation.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 50f3015814..cb3c865f05 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -4691,6 +4691,7 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol data_tracks.resize(tracks_to_compress.size()); time_tracks.resize(tracks_to_compress.size()); + uint32_t needed_min_page_size = base_page_size; for (uint32_t i = 0; i < data_tracks.size(); i++) { data_tracks[i].split_tolerance = p_split_tolerance; if (track_get_type(tracks_to_compress[i]) == TYPE_BLEND_SHAPE) { @@ -4698,7 +4699,12 @@ void Animation::compress(uint32_t p_page_size, uint32_t p_fps, float p_split_tol } else { data_tracks[i].components = 3; } + needed_min_page_size += data_tracks[i].data.size() + data_tracks[i].get_temp_packet_size(); } + for (uint32_t i = 0; i < time_tracks.size(); i++) { + needed_min_page_size += time_tracks[i].packets.size() * 4; // time packet is 32 bits + } + ERR_FAIL_COND_MSG(p_page_size < needed_min_page_size, "Cannot compress with the given page size"); while (true) { // Begin by finding the keyframe in all tracks with the time closest to the current time |