You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removed PS memory manager and some minor improvements (wled#4651)
* Removed memory manager from PS
- reverted all changes related to memory manager
- moved local buffer into effect data memory
- some RAM issues may occur on larger setups: tested on S3 it works fine up to 32x32 but runs into memory issues at 64x32
* fixed ifdef, improved readability, add optimize "o2" flags to improve speed
- added struct for x and y coordinates, thx to @blazoncek
* cleanup and minor improvements
- removed local buffer for ESP8266 in 1D system to save on RAM
- increased particle brightness in PS Impact
- minor tweak in collision binning (might improve speed)
- removed comments and some other unused stuff
- fixed a few compiler wranings
* fixed init sequence bug
uint32_t numFlames; // number of flames: depends on fire width. for a fire width of 16 pixels, about 25-30 flames give good results
8000
8000
8001
-
if (SEGMENT.call == 0) { // initialization TODO: make this a PSinit function, this is needed in every particle FX but first, get this working.
8001
+
if (SEGMENT.call == 0) { // initialization
8002
8002
if (!initParticleSystem2D(PartSys, SEGMENT.virtualWidth(), 4)) //maximum number of source (PS may limit based on segment size); need 4 additional bytes for time keeping (uint32_t lastcall)
8003
8003
returnmode_static(); // allocation failed or not 2D
8004
8004
SEGENV.aux0 = hw_random16(); // aux0 is wind position (index) in the perlin noise
if (!initParticleSystem2D(PartSys, 1, 0, true, false)) // init, request one source (actually dont really need one TODO: test if using zero sources also works)
8093
+
if (!initParticleSystem2D(PartSys, 0, 0, true, false)) // init
8094
8094
returnmode_static(); // allocation failed or not 2D
8095
8095
PartSys->setKillOutOfBounds(true);
8096
8096
PartSys->setGravity(); // enable with default gravity
if ( PartSys->sources[i].source.vy < 0) // moving down, emit sparks
8418
8414
emitparticles = 1;
8419
-
#else
8420
-
emitparticles = 2;
8421
-
#endif
8422
-
}
8423
8415
elseif ( PartSys->sources[i].source.vy > 0) // moving up means meteor is on 'standby'
8424
8416
emitparticles = 0;
8425
8417
else { // speed is zero, explode!
8426
8418
PartSys->sources[i].source.vy = 10; // set source speed positive so it goes into timeout and launches again
8427
-
#ifdef ESP8266
8428
-
emitparticles = hw_random16(SEGMENT.intensity >> 3) + 5; // defines the size of the explosion
8429
-
#else
8430
-
emitparticles = map(SEGMENT.intensity, 0, 255, 10, hw_random16(PartSys->usedParticles>>2)); // defines the size of the explosion !!!TODO: check if this works on ESP8266, drop esp8266 def if it does
8431
-
#endif
8419
+
emitparticles = map(SEGMENT.intensity, 0, 255, 10, hw_random16(PartSys->usedParticles>>2)); // defines the size of the explosion
PartSys->sources[i].var = 3; // speed variation around vx,vy (+/- var)
8477
8465
}
8478
8466
}
8479
8467
8468
+
for (uint32_t i = 0; i < PartSys->usedParticles; i++) {
8469
+
if (PartSys->particles[i].ttl > 5) PartSys->particles[i].ttl -= 5; //ttl is linked to brightness, this allows to use higher brightness but still a short spark lifespan
if (SEGMENT.call % (11 - (SEGMENT.custom2 / 25)) == 0) { // every nth frame, cycle color and emit particles //TODO: make this a segment call % SEGMENT.custom2 for better control
8875
+
if (SEGMENT.call % (11 - (SEGMENT.custom2 / 25)) == 0) { // every nth frame, cycle color and emit particles
if (!initParticleSystem2D(PartSys, 1, 0, true, true)) //init, request one source, no additional bytes, advanced size & size control (actually dont really need one TODO: test if using zero sources also works)
8895
+
if (!initParticleSystem2D(PartSys, 0, 0, true, true)) //init, no additional bytes, advanced size & size control
8904
8896
returnmode_static(); // allocation failed or not 2D
if ((SEGMENT.intensity| (PartSys->getAvailableParticles() << 8)) != *settingTracker) { // initialize, getAvailableParticles changes while in FX transition
for (uint i = 0; i < 3; i++) { // 3 base flames TODO: check if this is ok or needs adjustments
9999
+
for (uint i = 0; i < 3; i++) { // 3 base flames
10011
10000
if (PartSys->sources[i].source.ttl > 50)
10012
10001
PartSys->sources[i].source.ttl -= 10; // TODO: in 2D making the source fade out slow results in much smoother flames, need to check if it can be done the same
PartSys->sources[j].minLife = PartSys->sources[j].source.ttl + SEGMENT.intensity;// TODO: in 2D, emitted particle ttl depends on source TTL, mimic here the same way? OR: change 2D to the same way it is done here and ditch special fire treatment in emit?
uint32_t settingssum = SEGMENT.custom1 + SEGMENT.check2 + PartSys->getAvailableParticles(); // note: getAvailableParticles is used to enforce update during transitions
0 commit comments