summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorBrad Linden <brad@lindenlab.com>2023-05-31 10:33:03 -0700
committerBrad Linden <brad@lindenlab.com>2023-05-31 10:33:03 -0700
commit8d20d61b4d305b985de4837bb0ed3ddaedb208d1 (patch)
tree36da421ebc6851ba7ae49e15c75ab823d18cc29b /indra/newview
parent2e2a821e3667cbedc57086121b834c339a3c68de (diff)
Fix divide by zero causing NaN with certain day cycles in DRTVWR-559
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llenvironment.cpp3
1 files changed, 3 insertions, 0 deletions
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);
}