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 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
uint32_t numFlames; // number of flames: depends on fire width. for a fire width of 16 pixels, about 25-30 flames give good results
9340
9340
9341
-
if (SEGMENT.call == 0) { // initialization TODO: make this a PSinit function, this is needed in every particle FX but first, get this working.
9341
+
if (SEGMENT.call == 0) { // initialization
9342
9342
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)
9343
9343
return mode_static(); // allocation failed or not 2D
9344
9344
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)
9433
+
if (!initParticleSystem2D(PartSys, 0, 0, true, false)) // init
9434
9434
return mode_static(); // allocation failed or not 2D
9435
9435
PartSys->setKillOutOfBounds(true);
9436
9436
PartSys->setGravity(); // enable with default gravity
if ( PartSys->sources[i].source.vy < 0) // moving down, emit sparks
9758
9754
emitparticles = 1;
9759
-
#else
9760
-
emitparticles = 2;
9761
-
#endif
9762
-
}
9763
9755
else if ( PartSys->sources[i].source.vy > 0) // moving up means meteor is on 'standby'
9764
9756
emitparticles = 0;
9765
9757
else { // speed is zero, explode!
9766
9758
PartSys->sources[i].source.vy = 10; // set source speed positive so it goes into timeout and launches again
9767
-
#ifdef ESP8266
9768
-
emitparticles = hw_random16(SEGMENT.intensity >> 3) + 5; // defines the size of the explosion
9769
-
#else
9770
-
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
9771
-
#endif
9759
+
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)
9817
9805
}
9818
9806
}
9819
9807
9808
+
for (uint32_t i = 0; i < PartSys->usedParticles; i++) {
9809
+
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
10215
+
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)
10235
+
if (!initParticleSystem2D(PartSys, 0, 0, true, true)) //init, no additional bytes, advanced size & size control
10244
10236
return mode_static(); // allocation failed or not 2D
for (uint i = 0; i < 3; i++) { // 3 base flames TODO: check if this is ok or needs adjustments
11339
+
for (uint i = 0; i < 3; i++) { // 3 base flames
11351
11340
if (PartSys->sources[i].source.ttl > 50)
11352
11341
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?
0 commit comments