From 8d20d61b4d305b985de4837bb0ed3ddaedb208d1 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Wed, 31 May 2023 10:33:03 -0700 Subject: Fix divide by zero causing NaN with certain day cycles in DRTVWR-559 --- indra/llinventory/llsettingsbase.cpp | 1 + indra/llinventory/llsettingsbase.h | 1 + indra/newview/llenvironment.cpp | 3 +++ 3 files changed, 5 insertions(+) (limited to 'indra') diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 936b166409..bcf8bf6264 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -693,6 +693,7 @@ void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf) F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_in) { LLSettingsBase::TrackPosition blendf = blendf_in; + llassert(!isnan(blendf)); if (blendf >= 1.0) { triggerComplete(); diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index 1f0589f571..50276b801a 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -467,6 +467,7 @@ protected: class LLSettingsBlenderTimeDelta : public LLSettingsBlender { +protected: LOG_CLASS(LLSettingsBlenderTimeDelta); public: static const LLSettingsBase::BlendFactor MIN_BLEND_DELTA; diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index aec7ceaa3c..58da164b5a 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -168,6 +168,9 @@ namespace // Find normalized track position of given time along full length of cycle inline LLSettingsBase::TrackPosition convert_time_to_position(const LLSettingsBase::Seconds& time, const LLSettingsBase::Seconds& len) { + // early out to avoid divide by zero. if len is zero then jump to end position + if (len == 0.f) return 1.f; + LLSettingsBase::TrackPosition position = LLSettingsBase::TrackPosition(fmod((F64)time, (F64)len) / (F64)len); return llclamp(position, 0.0f, 1.0f); } -- cgit v1.2.3