From d2bf3a2a5de032b6d1f7169ad99472d8c7230e10 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 23 Jan 2014 13:46:12 -0800 Subject: [PATCH] set default particle lifetime to 10 seconds, make sure lifetime is always honored --- examples/toyball.js | 2 +- libraries/particles/src/Particle.cpp | 2 +- libraries/particles/src/Particle.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/toyball.js b/examples/toyball.js index 1682cbe3d4..be26c3d3fb 100644 --- a/examples/toyball.js +++ b/examples/toyball.js @@ -135,7 +135,7 @@ function checkControllerSide(whichSide) { inHand: true, radius: 0.05, color: { red: 255, green: 0, blue: 0 }, - lifetime: 10 // 10 seconds + lifetime: 10 // 10 seconds - same as default, not needed but here as an example }; newParticle = Particles.addParticle(properties); diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index 5570797ab4..5cf5e9248d 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -682,7 +682,7 @@ void Particle::update(const uint64_t& now) { const uint64_t REALLY_OLD = 30 * USECS_PER_SECOND; // 30 seconds bool isReallyOld = ((now - _created) > REALLY_OLD); bool isInHand = getInHand(); - bool shouldDie = getShouldDie() || (!isInHand && isStopped && isReallyOld); + bool shouldDie = (getAge() > getLifetime()) || getShouldDie() || (!isInHand && isStopped && isReallyOld); setShouldDie(shouldDie); runUpdateScript(); // allow the javascript to alter our state diff --git a/libraries/particles/src/Particle.h b/libraries/particles/src/Particle.h index 9c93423c08..e534c7b418 100644 --- a/libraries/particles/src/Particle.h +++ b/libraries/particles/src/Particle.h @@ -42,7 +42,7 @@ const uint16_t PACKET_CONTAINS_INHAND = 128; const uint16_t PACKET_CONTAINS_SCRIPT = 256; const uint16_t PACKET_CONTAINS_SHOULDDIE = 512; -const float DEFAULT_LIFETIME = 60.0f * 60.0f * 24.0f; // particles live for 1 day by default +const float DEFAULT_LIFETIME = 10.0f; // particles live for 10 seconds by default const float DEFAULT_DAMPING = 0.99f; const float DEFAULT_RADIUS = 0.1f / TREE_SCALE; const float MINIMUM_PARTICLE_ELEMENT_SIZE = (1.0f / 100000.0f) / TREE_SCALE; // smallest size container