From 3d5bdb61d83eacc737fb237c9ab00618bb10575e Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Mon, 17 Feb 2025 19:26:10 +0100 Subject: [PATCH] intermediate fix for transition speedup - fixes FX speedup in fade transitions but its not a proper solution --- wled00/FXparticleSystem.cpp | 8 ++++++++ wled00/FXparticleSystem.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/wled00/FXparticleSystem.cpp b/wled00/FXparticleSystem.cpp index 3aaaa95378..fde07be766 100644 --- a/wled00/FXparticleSystem.cpp +++ b/wled00/FXparticleSystem.cpp @@ -54,6 +54,7 @@ ParticleSystem2D::ParticleSystem2D(uint32_t width, uint32_t height, uint32_t num smearBlur = 0; //no smearing by default emitIndex = 0; collisionStartIdx = 0; + lastRender = 0; //initialize some default non-zero values most FX use for (uint32_t i = 0; i < numSources; i++) { @@ -573,6 +574,9 @@ void ParticleSystem2D::pointAttractor(const uint32_t particleindex, PSparticle & // warning: do not render out of bounds particles or system will crash! rendering does not check if particle is out of bounds // firemode is only used for PS Fire FX void ParticleSystem2D::ParticleSys_render() { + if(blendingStyle == BLEND_STYLE_FADE && SEGMENT.isInTransition() && lastRender + (strip.getFrameTime() >> 1) > strip.now) // fixes speedup during transitions TODO: find a better solution + return; + lastRender = strip.now; CRGB baseRGB; uint32_t brightness; // particle brightness, fades if dying static bool useAdditiveTransfer = false; // use add instead of set for buffer transferring (must persist between calls) @@ -1254,6 +1258,7 @@ ParticleSystem1D::ParticleSystem1D(uint32_t length, uint32_t numberofparticles, smearBlur = 0; //no smearing by default emitIndex = 0; collisionStartIdx = 0; + lastRender = 0; // initialize some default non-zero values most FX use for (uint32_t i = 0; i < numSources; i++) { sources[i].source.ttl = 1; //set source alive @@ -1525,6 +1530,9 @@ void ParticleSystem1D::applyFriction(int32_t coefficient) { // if wrap is set, particles half out of bounds are rendered to the other side of the matrix // warning: do not render out of bounds particles or system will crash! rendering does not check if particle is out of bounds void ParticleSystem1D::ParticleSys_render() { + if(blendingStyle == BLEND_STYLE_FADE && SEGMENT.isInTransition() && lastRender + (strip.getFrameTime() >> 1) > strip.now) // fixes speedup during transitions TODO: find a better solution + return; + lastRender = strip.now; CRGB baseRGB; uint32_t brightness; // particle brightness, fades if dying // bool useAdditiveTransfer; // use add instead of set for buffer transferring diff --git a/wled00/FXparticleSystem.h b/wled00/FXparticleSystem.h index 23f5aae985..a91ebe25e4 100644 --- a/wled00/FXparticleSystem.h +++ b/wled00/FXparticleSystem.h @@ -242,6 +242,7 @@ class ParticleSystem2D { uint8_t motionBlur; // motion blur, values > 100 gives smoother animations. Note: motion blurring does not work if particlesize is > 0 uint8_t smearBlur; // 2D smeared blurring of full frame uint8_t effectID; // ID of the effect that is using this particle system, used for transitions + uint32_t lastRender; // last time the particles were rendered, intermediate fix for speedup }; void blur2D(CRGB *colorbuffer, const uint32_t xsize, uint32_t ysize, const uint32_t xblur, const uint32_t yblur, const uint32_t xstart = 0, uint32_t ystart = 0, const bool isparticle = false); @@ -406,6 +407,7 @@ class ParticleSystem1D uint8_t motionBlur; // enable motion blur, values > 100 gives smoother animations uint8_t smearBlur; // smeared blurring of full frame uint8_t effectID; // ID of the effect that is using this particle system, used for transitions + uint32_t lastRender; // last time the particles were rendered, intermediate fix for speedup }; bool initParticleSystem1D(ParticleSystem1D *&PartSys, const uint32_t requestedsources, const uint8_t fractionofparticles = 255, const uint32_t additionalbytes = 0, const bool advanced = false);