| @@ -14,7 +14,7 @@ struct Light { | |||||
| /** Sets the brightness immediately with no light decay. */ | /** Sets the brightness immediately with no light decay. */ | ||||
| void setBrightness(float brightness) { | void setBrightness(float brightness) { | ||||
| value = (brightness > 0.f) ? brightness : 0.f; | |||||
| value = brightness; | |||||
| } | } | ||||
| float getBrightness() { | float getBrightness() { | ||||
| @@ -23,15 +23,14 @@ struct Light { | |||||
| /** Emulates light decay with slow fall but immediate rise. */ | /** Emulates light decay with slow fall but immediate rise. */ | ||||
| void setSmoothBrightness(float brightness, float deltaTime) { | void setSmoothBrightness(float brightness, float deltaTime) { | ||||
| float v = (brightness > 0.f) ? brightness : 0.f; | |||||
| if (v < value) { | |||||
| if (brightness < value) { | |||||
| // Fade out light | // Fade out light | ||||
| const float lambda = 30.f; | const float lambda = 30.f; | ||||
| value += (v - value) * lambda * deltaTime; | |||||
| value += (brightness - value) * lambda * deltaTime; | |||||
| } | } | ||||
| else { | else { | ||||
| // Immediately illuminate light | // Immediately illuminate light | ||||
| value = v; | |||||
| value = brightness; | |||||
| } | } | ||||
| } | } | ||||