Browse Source

Simplify Light::setBrightness/Smooth.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
436615f361
1 changed files with 4 additions and 5 deletions
  1. +4
    -5
      include/engine/Light.hpp

+ 4
- 5
include/engine/Light.hpp View File

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



Loading…
Cancel
Save