Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intermediate fix for PS transition speedup #4562

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions wled00/FXparticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions wled00/FXparticleSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down