Skip to content
Snippets Groups Projects
Commit 635c0556 authored by Micah Elizabeth Scott's avatar Micah Elizabeth Scott
Browse files

Timestep cleanup

Also allows particle lifetime to be dynamic again.
parent 58d14801
No related branches found
No related tags found
No related merge requests found
......@@ -44,14 +44,10 @@ wobbleAmount = 24.0
origin = [0, 0, 0]
# Physics
# numPhysicsTimesteps = 20 TODO: Re-enable when things become more complex
frameDelay = 5
timestepSize = 0.010
gain = 0.1
# Derived values
particleDecay = timestepSize / particleLifetime
# Controlled by the Pitch Transpose Knob
spinAngle = 0
......@@ -187,16 +183,14 @@ draw = () ->
y += wobbleAmp * Math.sin lfoAngle
# Update velocity; use the XZ plane
p.velocity[0] += (x - p.point[0]) * (gain) # / numPhysicsTimesteps)
p.velocity[2] += (y - p.point[2]) * (gain) # / numPhysicsTimesteps)
p.velocity[0] += (x - p.point[0]) * gain
p.velocity[2] += (y - p.point[2]) * gain
# Fixed timestep physics
# TODO: Re-enable this when it's not just re-adding the delta.
# for i in [1 .. numPhysicsTimesteps]
p.point[0] += p.velocity[0]
p.point[1] += p.velocity[1]
p.point[2] += p.velocity[2]
p.life -= particleDecay
p.life -= timestepSize / particleLifetime
# Filter out dead particles
particles = particles.filter (p) -> p.life > 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment