Fix infinitys and NaNs in lights

This commit is contained in:
CapsizeGlimmer 2020-05-04 17:17:54 -04:00
parent e5a87f4338
commit 28c454f9ca

View File

@ -136,7 +136,11 @@ impl FigureMgr {
if let Some(emitter) = light_emitter_opt {
(
emitter.col,
emitter.strength,
if emitter.strength.is_finite() {
emitter.strength
} else {
0.0
},
emitter.flicker,
emitter.animated,
)
@ -149,6 +153,9 @@ impl FigureMgr {
if let Some(state) = self.character_states.get(&entity) {
light_anim.offset = state.lantern_offset;
}
if !light_anim.strength.is_finite() {
light_anim.strength = 0.0;
}
if animated {
let flicker = (rand::random::<f32>() - 0.5) * flicker / dt.sqrt();
// Close gap between current and target strength by 95% per second