From 4a0c998f53426ffff26bc1dd210fac803dc1499a Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 18 Jul 2025 00:13:01 +0300 Subject: [PATCH] Avoid zero division during animation interpolation --- components/nifosg/controller.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index 41c8027eea..cceec279b2 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -112,7 +112,12 @@ namespace NifOsg mLastHighKey = it; mLastLowKey = --it; - float a = (time - mLastLowKey->first) / (mLastHighKey->first - mLastLowKey->first); + const float highTime = mLastHighKey->first; + const float lowTime = mLastLowKey->first; + if (highTime == lowTime) + return mLastLowKey->second.mValue; + + const float a = (time - lowTime) / (highTime - lowTime); return interpolate(mLastLowKey->second, mLastHighKey->second, a, mKeys->mInterpolationType); }