From 436615f3611d5a65540f212d908ad147e4bb164c Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 28 May 2019 19:44:02 -0400 Subject: [PATCH] Simplify Light::setBrightness/Smooth. --- include/engine/Light.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/engine/Light.hpp b/include/engine/Light.hpp index 3a2b03cf..9407b809 100644 --- a/include/engine/Light.hpp +++ b/include/engine/Light.hpp @@ -14,7 +14,7 @@ struct Light { /** Sets the brightness immediately with no light decay. */ void setBrightness(float brightness) { - value = (brightness > 0.f) ? brightness : 0.f; + value = brightness; } float getBrightness() { @@ -23,15 +23,14 @@ struct Light { /** Emulates light decay with slow fall but immediate rise. */ void setSmoothBrightness(float brightness, float deltaTime) { - float v = (brightness > 0.f) ? brightness : 0.f; - if (v < value) { + if (brightness < value) { // Fade out light const float lambda = 30.f; - value += (v - value) * lambda * deltaTime; + value += (brightness - value) * lambda * deltaTime; } else { // Immediately illuminate light - value = v; + value = brightness; } }