Browse Source

Light::setBrightnessSmooth() turns on high values immediately, fades out

low values
tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
b5fdf5d5ba
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      src/engine.cpp

+ 9
- 2
src/engine.cpp View File

@@ -39,8 +39,15 @@ float Light::getBrightness() {
} }


void Light::setBrightnessSmooth(float brightness) { void Light::setBrightnessSmooth(float brightness) {
// lambda = 3 * framerate
value += (brightness * brightness - value) * sampleTime * (60.0 * 3.0);
float v = brightness * brightness;
if (v < value) {
// Fade out light with lambda = 3 * framerate
value += (v - value) * sampleTime * (60.0 * 3.0);
}
else {
// Immediately illuminate light
value = v;
}
} }






Loading…
Cancel
Save