From 14d336eeb73044741b3d9c54c328f2160d9c771b Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Wed, 20 Jan 2021 17:18:43 -0500 Subject: [PATCH] Remove "death" functions from particle system Without the "spawn another effect" binding (that was recently removed), these serve no purpose. Change-Id: Ica8cc3f444c6b749c634c41453501edfff9d9a23 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356417 Reviewed-by: Brian Osman Commit-Queue: Brian Osman --- modules/particles/src/SkParticleEffect.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/modules/particles/src/SkParticleEffect.cpp b/modules/particles/src/SkParticleEffect.cpp index 69bbf2b21f..e2a0a385f6 100644 --- a/modules/particles/src/SkParticleEffect.cpp +++ b/modules/particles/src/SkParticleEffect.cpp @@ -267,9 +267,6 @@ void SkParticleEffect::advanceTime(double now) { fState.fAge += deltaTime / fState.fLifetime; if (fState.fAge > 1) { - // We always run effectDeath when age crosses 1, whether we're looping or actually dying - this->runEffectScript("effectDeath"); - if (fLooping) { // If we looped, then run effectSpawn again (with the updated loop count) fState.fLoopCount += sk_float_floor2int(fState.fAge); @@ -281,26 +278,21 @@ void SkParticleEffect::advanceTime(double now) { } } - // Advance age for existing particles, shuffle all dying particles to the end of the arrays - int numDyingParticles = 0; + // Advance age for existing particles, and remove any that have reached their end of life for (int i = 0; i < fCount; ++i) { fParticles.fData[SkParticles::kAge][i] += fParticles.fData[SkParticles::kLifetime][i] * deltaTime; if (fParticles.fData[SkParticles::kAge][i] > 1.0f) { // NOTE: This is fast, but doesn't preserve drawing order. Could be a problem... for (int j = 0; j < SkParticles::kNumChannels; ++j) { - std::swap(fParticles.fData[j][i], fParticles.fData[j][fCount - 1]); + fParticles.fData[j][i] = fParticles.fData[j][fCount - 1]; } - std::swap(fStableRandoms[i], fStableRandoms[fCount - 1]); + fStableRandoms[i] = fStableRandoms[fCount - 1]; --i; --fCount; - ++numDyingParticles; } } - // Run the death script for all particles that just died - this->runParticleScript("death", fCount, numDyingParticles); - // Run 'effectUpdate' to adjust emitter properties this->runEffectScript("effectUpdate");