(#54) make radius deceleration depend on delta radius

This commit is contained in:
rexim 2019-11-28 01:20:18 +07:00
parent eea38a2247
commit 76e9b7dfca

View File

@ -84,12 +84,13 @@ type Flashlight = object
const
INITIAL_FL_DELTA_RADIUS = 100.0
FL_DELTA_RADIUS_DECELERATION = 400.0
FL_DELTA_RADIUS_DECELERATION = 5.0
proc update(flashlight: var Flashlight, dt: float32) =
flashlight.radius = max(0.0, flashlight.radius + flashlight.deltaRadius * dt)
if abs(flashlight.deltaRadius) > 0.5:
flashlight.deltaRadius -= sgn(flashlight.deltaRadius).float32 * FL_DELTA_RADIUS_DECELERATION * dt
flashlight.deltaRadius -= flashlight.deltaRadius * FL_DELTA_RADIUS_DECELERATION * dt
if flashlight.isEnabled:
flashlight.shadow = min(flashlight.shadow + 6.0 * dt, 0.8)