Merge pull request #4861 from assimp/kimkulling/LWOAnimation_fix_division_by_zero_issue-4860

Fix: Fix possible division by zero
pull/4863/head
Kim Kulling 2023-01-04 09:37:41 +01:00 committed by GitHub
commit 2af29f4836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -162,8 +162,11 @@ void AnimResolver::UpdateAnimRangeSetup() {
const double my_last = (*it).keys.back().time;
const double delta = my_last - my_first;
if (delta == 0.0) {
continue;
}
const size_t old_size = (*it).keys.size();
const float value_delta = (*it).keys.back().value - (*it).keys.front().value;
// NOTE: We won't handle reset, linear and constant here.
@ -176,8 +179,7 @@ void AnimResolver::UpdateAnimRangeSetup() {
case LWO::PrePostBehaviour_Oscillate: {
const double start_time = delta - std::fmod(my_first - first, delta);
std::vector<LWO::Key>::iterator n = std::find_if((*it).keys.begin(), (*it).keys.end(),
[start_time](double t) { return start_time > t; }),
m;
[start_time](double t) { return start_time > t; }), m;
size_t ofs = 0;
if (n != (*it).keys.end()) {