From b71bd3df84c036a61ca39daf8dbb660b13ed8e9d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 13 Feb 2016 23:37:08 +0200 Subject: [PATCH] LWO: Fix division by zero --- code/LWOAnimation.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/LWOAnimation.cpp b/code/LWOAnimation.cpp index de6d6493c..9f23c13b2 100644 --- a/code/LWOAnimation.cpp +++ b/code/LWOAnimation.cpp @@ -328,7 +328,12 @@ void AnimResolver::DoInterpolation2(std::vector::const_iterator beg, break; } // linear interpolation - default - fill = (*beg).value + ((*end).value - (*beg).value)*(float)(((time - (*beg).time) / ((*end).time - (*beg).time))); + double duration = (*end).time - (*beg).time; + if (duration > 0.0) { + fill = (*beg).value + ((*end).value - (*beg).value)*(float)(((time - (*beg).time) / duration)); + } else { + fill = (*beg).value; + } } // ------------------------------------------------------------------------------------------------