|
|
@@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|