Stabilise 'day night ratio' to fix object brightness flicker (#8417)
authorParamat <paramat@users.noreply.github.com>
Thu, 4 Apr 2019 22:30:10 +0000 (23:30 +0100)
committerGitHub <noreply@github.com>
Thu, 4 Apr 2019 22:30:10 +0000 (23:30 +0100)
commit5b8363af0084786a7e949ae8fa16bde046f8ffda
treef9f84305c883ba14f93c4a97dc25401103f65c47
parentd1118658902cb70182718f3a32c72b1cd799285f
Stabilise 'day night ratio' to fix object brightness flicker (#8417)

Previously, when basic shaders were enabled, the function
time_to_daynight_ratio() returned values jumping between 149 and 150
between times 4375 and 4625, and values jumping between 999 and 1000
between times 6125 and 6375, (and the corresponding times at sunset)
due to tiny float errors in the interpolation code.

This caused the light level returned by blend_light() to jump between
14 and 15, which became noticeable recently as those light levels were
given different visual brightnesses.

Add early returns to avoid the problematic interpolation, and to
avoid unnecessary running of the loop.
src/daynightratio.h