Skip to content

Commit 7abc440

Browse files
committed
removed zero inits
- removed zero initialisations in FX, segment.data is set to zero by alloc function
1 parent 54e94dd commit 7abc440

2 files changed

Lines changed: 6 additions & 27 deletions

File tree

wled00/FX.cpp

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7918,13 +7918,8 @@ uint16_t mode_particlevortex(void)
79187918
{
79197919
PartSys->sources[i].source.x = (PartSys->maxX + 1) >> 1; // center
79207920
PartSys->sources[i].source.y = (PartSys->maxY + 1) >> 1; // center
7921-
PartSys->sources[i].source.vx = 0;
7922-
PartSys->sources[i].source.vy = 0;
79237921
PartSys->sources[i].maxLife = 900;
79247922
PartSys->sources[i].minLife = 800;
7925-
PartSys->sources[i].vx = 0; // emitting speed
7926-
PartSys->sources[i].vy = 0; // emitting speed
7927-
PartSys->sources[i].var = 0; // emitting variation
79287923
}
79297924
PartSys->setKillOutOfBounds(true);
79307925
}
@@ -8243,8 +8238,7 @@ uint16_t mode_particlevolcano(void)
82438238
PartSys->sources[i].source.x = PartSys->maxX / (numSprays + 1) * (i + 1); //distribute evenly
82448239
PartSys->sources[i].maxLife = 300; // lifetime in frames
82458240
PartSys->sources[i].minLife = 250;
8246-
PartSys->sources[i].source.collide = true; // seeded particles will collide (if enabled)
8247-
PartSys->sources[i].vx = 0; // emitting speed
8241+
PartSys->sources[i].source.collide = true; // seeded particles will collide (if enabled)
82488242
}
82498243
}
82508244
else
@@ -8317,14 +8311,6 @@ uint16_t mode_particlefire(void)
83178311
SEGMENT.aux0 = rand(); // aux0 is wind position (index) in the perlin noise
83188312
// initialize the flame sprays
83198313
numFlames = PartSys->numSources;
8320-
for (i = 0; i < numFlames; i++)
8321-
{
8322-
PartSys->sources[i].source.ttl = 0;
8323-
PartSys->sources[i].source.vx = 0; // emitter moving speed;
8324-
PartSys->sources[i].source.vy = 0;
8325-
// note: other parameters are set when creating the flame (see blow)
8326-
}
8327-
83288314
DEBUG_PRINTF_P(PSTR("segment data ptr in fireFX %p\n"), SEGMENT.data);
83298315
}
83308316
else
@@ -8652,7 +8638,6 @@ uint16_t mode_particlewaterfall(void)
86528638
for (i = 0; i < numSprays; i++)
86538639
{
86548640
PartSys->sources[i].source.hue = random16();
8655-
PartSys->sources[i].source.vx = 0;
86568641
PartSys->sources[i].source.collide = true; // seeded particles will collide
86578642
#ifdef ESP8266
86588643
PartSys->sources[i].maxLife = 250; // lifetime in frames (ESP8266 has less particles, make them short lived to keep the water flowing)
@@ -8661,7 +8646,6 @@ uint16_t mode_particlewaterfall(void)
86618646
PartSys->sources[i].maxLife = 400; // lifetime in frames
86628647
PartSys->sources[i].minLife = 150;
86638648
#endif
8664-
PartSys->sources[i].vx = 0; // emitting speed
86658649
PartSys->sources[i].var = 7; // emiting variation
86668650
}
86678651
}
@@ -8924,8 +8908,7 @@ uint16_t mode_particleimpact(void)
89248908
PartSys->setBounceY(true); //always use ground bounce
89258909
MaxNumMeteors = min(PartSys->numSources, (uint8_t)NUMBEROFSOURCES);
89268910
for (i = 0; i < MaxNumMeteors; i++)
8927-
{
8928-
PartSys->sources[i].vx = 0; //emit speed in x
8911+
{
89298912
PartSys->sources[i].source.y = 500;
89308913
PartSys->sources[i].source.ttl = random16(20 * i); // set initial delay for meteors
89318914
PartSys->sources[i].source.vy = 10; // at positive speeds, no particles are emitted and if particle dies, it will be relaunched
@@ -9063,11 +9046,8 @@ uint16_t mode_particleattractor(void)
90639046
if (!initParticleSystem(PartSys, 1, true)) // init using 1 source and advanced particle settings
90649047
return mode_static(); // allocation failed; //allocation failed
90659048

9066-
PartSys->sources[0].source.hue = random16();
9067-
PartSys->sources[0].source.x = PS_P_RADIUS; //start out in bottom left corner
9068-
PartSys->sources[0].source.y = PS_P_RADIUS<<1;
9069-
PartSys->sources[0].source.vx = random16(5) + 3;
9070-
PartSys->sources[0].source.vy = PartSys->sources[0].source.vx - 2; //move slower in y
9049+
PartSys->sources[0].source.hue = random16();
9050+
PartSys->sources[0].source.vx = -7;
90719051
PartSys->sources[0].source.collide = true; // seeded particles will collide
90729052
PartSys->sources[0].source.ttl = 100; //is replenished below, it never dies
90739053
#ifdef ESP8266
@@ -9077,10 +9057,9 @@ uint16_t mode_particleattractor(void)
90779057
PartSys->sources[0].maxLife = 350; // lifetime in frames
90789058
PartSys->sources[0].minLife = 50;
90799059
#endif
9080-
PartSys->sources[0].vx = 0; // emitting speed
9081-
PartSys->sources[0].vy = 0; // emitting speed
90829060
PartSys->sources[0].var = 7; // emiting variation
90839061
PartSys->setWallHardness(255); //bounce forever
9062+
PartSys->setWallRoughness(200); //randomize wall bounce
90849063
}
90859064
else
90869065
PartSys = reinterpret_cast<ParticleSystem *>(SEGMENT.data); // if not first call, just set the pointer to the PS

wled00/FXparticleSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ParticleSystem::ParticleSystem(uint16_t width, uint16_t height, uint16_t numbero
5656
updatePSpointers(isadvanced); // set the particle and sources pointer (call this before accessing sprays or particles)
5757
setMatrixSize(width, height);
5858
setWallHardness(255); // set default wall hardness to max
59-
setWallRoughness(200); // smooth walls by default !!! testing this
59+
setWallRoughness(0); // smooth walls by default !!! testing this
6060
setGravity(0); //gravity disabled by default
6161
setSaturation(255); //full saturation by default
6262
setParticleSize(0); // minimum size by default

0 commit comments

Comments
 (0)