Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fix possible division by zero #4861

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions code/AssetLib/LWO/LWOAnimation.cpp
Expand Up @@ -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.
Expand All @@ -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()) {
Expand Down