@@ -7968,16 +7968,14 @@ uint16_t mode_particlevortex(void)
79687968 }
79697969 }
79707970 }
7971-
7972- // TODO: speed increment is still wrong, it only works in autochange, manual change to a lower speed does not work. need to make it better.
7971+
79737972 // set rotation direction and speed
79747973 // can use direction flag to determine current direction
79757974 bool direction = SEGMENT.check2 ; // no automatic direction change, set it to flag
79767975 int32_t currentspeed = (int32_t )SEGMENT.step ; // make a signed integer out of step
79777976
79787977 if (SEGMENT.custom2 > 0 ) // automatic direction change enabled
79797978 {
7980- // speedincrement = 1 + (SEGMENT.speed >> 5) + (SEGMENT.custom2 >> 2);
79817979 uint16_t changeinterval = (270 - SEGMENT.custom2 );
79827980 direction = SEGMENT.aux1 & 0x02 ; // set direction according to flag
79837981
@@ -8014,22 +8012,6 @@ uint16_t mode_particlevortex(void)
80148012
80158013 // calculate angle offset for an even distribution
80168014 uint16_t angleoffset = 0xFFFF / spraycount;
8017-
8018- // int32_t particlespeeddiv = ((263 - SEGMENT.intensity) >> 3);
8019- // int32_t particlespeed = 127/particlespeeddiv; //just for testing, need to replace this with angle emit and come up with a new speed calculation
8020- // particle speed goes from 7 to 128 (sin cos return 15bit value but with sign)
8021-
8022- // for (j = 0; j < spraycount; j++) //TODO: use angle emit
8023- // {
8024-
8025- // calculate the x and y speed using aux0 as the 16bit angle. returned value by sin16/cos16 is 16bit, shifting it by 8 bits results in +/-128, divide that by custom1 slider value
8026- // PartSys->sources[j].vx = (cos16(SEGMENT.aux0 + angleoffset * j) >> 8) / particlespeeddiv; // update spray angle (rotate all sprays with angle offset)
8027- // PartSys->sources[j].vy = (sin16(SEGMENT.aux0 + angleoffset * j) >> 8) / particlespeeddiv; // update spray angle (rotate all sprays with angle offset)
8028- // PartSys->sources[j].var = (SEGMENT.custom3 >> 1); // emiting variation = nozzle size (custom 3 goes from 0-32)
8029- // }
8030-
8031-
8032- // test to check if less particles are ok at lower speeds.
80338015 uint32_t skip = PS_P_HALFRADIUS/(SEGMENT.intensity + 1 ) + 1 ;
80348016 if (SEGMENT.call % skip == 0 )
80358017 {
@@ -8072,7 +8054,7 @@ uint16_t mode_particlefireworks(void)
80728054 if (SEGMENT.call == 0 ) // initialization
80738055 {
80748056 if (!initParticleSystem (PartSys, NUMBEROFSOURCES, true )) // init with advanced particle properties
8075- return mode_static (); // allocation failed; //allocation failed
8057+ return mode_static (); // allocation failed
80768058 PartSys->setKillOutOfBounds (true ); // out of bounds particles dont return (except on top, taken care of by gravity setting)
80778059 PartSys->setWallHardness (100 ); // ground bounce is fixed
80788060 numRockets = min (PartSys->numSources , (uint8_t )NUMBEROFSOURCES);
@@ -8095,7 +8077,6 @@ uint16_t mode_particlefireworks(void)
80958077
80968078 PartSys->setWrapX (SEGMENT.check1 );
80978079 PartSys->setBounceY (SEGMENT.check2 );
8098- // PartSys->setWallHardness(SEGMENT.custom2); //not used anymore, can be removed
80998080 PartSys->setGravity (map (SEGMENT.custom3 ,0 ,31 ,0 ,10 )); // todo: make it a slider to adjust
81008081
81018082 // check each rocket's state and emit particles according to its state: moving up = emit exhaust, at top = explode; falling down = standby time
@@ -8168,6 +8149,7 @@ uint16_t mode_particlefireworks(void)
81688149 else
81698150 {
81708151 /*
8152+ //TODO: this does not look good. adjust or remove completely
81718153 if( PartSys->sources[j].source.vy < 0) //explosion is ongoing
81728154 {
81738155 if(i < (emitparticles>>2)) //set 1/4 of particles to larger size
@@ -8193,7 +8175,7 @@ uint16_t mode_particlefireworks(void)
81938175 {
81948176 if (PartSys->sources [j].source .ttl )
81958177 {
8196- PartSys->particleMoveUpdate (PartSys->sources [j].source ); // todo: need different settings for rocket?
8178+ PartSys->particleMoveUpdate (PartSys->sources [j].source );
81978179 }
81988180 else if (PartSys->sources [j].source .vy > 0 ) // rocket has died and is moving up. stop it so it will explode (is handled in the code above)
81998181 {
@@ -8218,7 +8200,7 @@ uint16_t mode_particlefireworks(void)
82188200 PartSys->sources [j].minLife = 10 ;
82198201 PartSys->sources [j].vx = 0 ; // emitting speed
82208202 PartSys->sources [j].vy = 0 ; // emitting speed
8221- PartSys->sources [j].var = 5 ; // speed variation around vx,vy (+/- var/2)
8203+ PartSys->sources [j].var = 3 ; // speed variation around vx,vy (+/- var/2)
82228204 }
82238205 }
82248206
@@ -8296,7 +8278,7 @@ uint16_t mode_particlevolcano(void)
82968278 PartSys->sources [i].source .vx > 0 ? SEGMENT.custom1 >> 4 : -(SEGMENT.custom1 >> 4 ); // set moving speed but keep the direction
82978279 PartSys->sources [i].vy = SEGMENT.speed >> 2 ; // emitting speed
82988280 PartSys->sources [i].vx = 0 ;
8299- PartSys->sources [i].var = SEGMENT.custom3 | 0x01 ; // emiting variation = nozzle size (custom 3 goes from 0-31), only use odd numbers
8281+ PartSys->sources [i].var = SEGMENT.custom3 >> 1 ; // emiting variation = nozzle size (custom 3 goes from 0-31)
83008282 // spray[j].source.hue = random16(); //set random color for each particle (using palette) -> does not look good
83018283 PartSys->sprayEmit (PartSys->sources [i]);
83028284 PartSys->particleMoveUpdate (PartSys->sources [i].source ); // move the source (also applies gravity, which is corrected for above, that is a hack but easier than creating more particlesettings)
@@ -8385,7 +8367,7 @@ uint16_t mode_particlefire(void)
83858367 PartSys->sources [i].minLife = 4 ;
83868368 PartSys->sources [i].vx = (int8_t )random (-3 , 3 ); // emitting speed (sideways)
83878369 PartSys->sources [i].vy = 5 + (firespeed >> 2 ); // emitting speed (upwards) -> this is good
8388- PartSys->sources [i].var = (random16 (2 + (firespeed >> 5 )) + 3 ) | 0x01 ; // speed variation around vx,vy (+/- var/2), only use odd numbers
8370+ PartSys->sources [i].var = (random16 (1 + (firespeed >> 5 )) + 2 ) ; // speed variation around vx,vy (+/- var)
83898371 }
83908372
83918373 }
@@ -8588,7 +8570,6 @@ uint16_t mode_particlewaterfall(void)
85888570 PartSys->sources [i].maxLife = 400 ; // lifetime in frames
85898571 PartSys->sources [i].minLife = 150 ;
85908572#endif
8591- PartSys->sources [i].var = 7 ; // emiting variation
85928573 }
85938574 }
85948575 else
@@ -8627,7 +8608,7 @@ uint16_t mode_particlewaterfall(void)
86278608 PartSys->sources [i].vy = -SEGMENT.speed >> 3 ; // emitting speed, down
86288609 PartSys->sources [i].source .x = map (SEGMENT.custom3 , 0 , 31 , 0 , (PartSys->maxXpixel - numSprays * 2 ) * PS_P_RADIUS) + i * PS_P_RADIUS * 2 ; // emitter position
86298610 PartSys->sources [i].source .y = PartSys->maxY + (PS_P_RADIUS * ((i<<2 ) + 4 )); // source y position, few pixels above the top to increase spreading before entering the matrix
8630- PartSys->sources [i].var = (SEGMENT.custom1 >> 3 ) | 0x01 ; // emiting variation 0-32, only use odd numbers
8611+ PartSys->sources [i].var = (SEGMENT.custom1 >> 3 ); // emiting variation 0-32
86318612 }
86328613
86338614 for (i = 0 ; i < numSprays; i++)
@@ -8918,7 +8899,7 @@ uint16_t mode_particleimpact(void)
89188899 PartSys->sources [i].source .ttl = random16 ((255 - SEGMENT.speed )) + 10 ; // standby time til next launch (in frames at 42fps, max of 265 is about 6 seconds
89198900 #endif
89208901 PartSys->sources [i].vy = (SEGMENT.custom1 >> 2 ); // emitting speed y
8921- PartSys->sources [i].var = (SEGMENT.custom1 >> 1 ) | 0x01 ; // speed variation around vx,vy (+/- var/2), only use odd numbers
8902+ PartSys->sources [i].var = (SEGMENT.custom1 >> 2 ) ; // speed variation around vx,vy (+/- var)
89228903 }
89238904 }
89248905 }
@@ -8935,7 +8916,7 @@ uint16_t mode_particleimpact(void)
89358916 PartSys->sources [i].maxLife = 60 ; // spark particle life
89368917 PartSys->sources [i].minLife = 20 ;
89378918 PartSys->sources [i].vy = -9 ; // emitting speed (down)
8938- PartSys->sources [i].var = 5 ; // speed variation around vx,vy (+/- var/2 )
8919+ PartSys->sources [i].var = 3 ; // speed variation around vx,vy (+/- var)
89398920 }
89408921 }
89418922
@@ -8977,8 +8958,7 @@ uint16_t mode_particleattractor(void)
89778958 PartSys->sources [0 ].maxLife = 350 ; // lifetime in frames
89788959 PartSys->sources [0 ].minLife = 50 ;
89798960 #endif
8980- PartSys->sources [0 ].var = 7 ; // emiting variation
8981- PartSys->sources [0 ].size = 100 ; // !!! debug remove this again
8961+ PartSys->sources [0 ].var = 4 ; // emiting variation
89828962 PartSys->setWallHardness (255 ); // bounce forever
89838963 PartSys->setWallRoughness (200 ); // randomize wall bounce
89848964 }
@@ -9089,7 +9069,7 @@ uint16_t mode_particleattractor(void)
90899069#endif
90909070 PartSys->sources[0].vx = 0; // emitting speed
90919071 PartSys->sources[0].vy = 0; // emitting speed
9092- PartSys->sources[0].var = 7 ; // emiting variation
9072+ PartSys->sources[0].var = 4 ; // emiting variation
90939073 }
90949074 else
90959075 PartSys = reinterpret_cast<ParticleSystem *>(SEGMENT.data); // if not first call, just set the pointer to the PS
@@ -9189,7 +9169,7 @@ uint16_t mode_particlespray(void)
91899169 PartSys->sources [0 ].maxLife = 300 ; // lifetime in frames
91909170 PartSys->sources [0 ].minLife = 100 ;
91919171 PartSys->sources [0 ].source .collide = true ; // seeded particles will collide (if enabled)
9192- PartSys->sources [0 ].var = 7 ;
9172+ PartSys->sources [0 ].var = 3 ;
91939173
91949174 }
91959175 else
@@ -9218,10 +9198,9 @@ uint16_t mode_particlespray(void)
92189198 if (SEGMENT.call % (11 - (SEGMENT.intensity / 25 )) == 0 ) // every nth frame, cycle color and emit particles
92199199 {
92209200 PartSys->sources [0 ].source .hue ++; // = random16(); //change hue of spray source
9221- // PartSys->sources[i].var = SEGMENT.custom3; // emiting variation = nozzle size (custom 3 goes from 0-32)
9201+ // PartSys->sources[i].var = SEGMENT.custom3; // emiting variation = nozzle size (custom 3 goes from 0-32)
92229202 PartSys->sources [0 ].source .x = map (SEGMENT.custom1 , 0 , 255 , 0 , PartSys->maxX );
92239203 PartSys->sources [0 ].source .y = map (SEGMENT.custom2 , 0 , 255 , 0 , PartSys->maxY );
9224-
92259204 // spray[j].source.hue = random16(); //set random color for each particle (using palette)
92269205 PartSys->angleEmit (PartSys->sources [0 ], (256 - (((int32_t )SEGMENT.custom3 + 1 ) << 3 )) << 8 , SEGMENT.speed >> 2 );
92279206 }
@@ -9381,8 +9360,7 @@ uint16_t mode_particleghostrider(void)
93819360 // Particle System settings
93829361 PartSys->updateSystem (); // update system properties (dimensions and data pointers)
93839362 PartSys->setMotionBlur (SEGMENT.custom1 );
9384- // PartSys->setColorByAge(SEGMENT.check1);
9385- PartSys->sources [0 ].var = (1 + (SEGMENT.custom3 >>1 )) | 0x01 ; // odd numbers only
9363+ PartSys->sources [0 ].var = SEGMENT.custom3 >> 1 ;
93869364
93879365 // color by age (PS color by age always starts with hue = 255 so cannot use that)
93889366 if (SEGMENT.check1 )
@@ -9404,7 +9382,7 @@ uint16_t mode_particleghostrider(void)
94049382 int8_t newvy = ((int32_t )sin16 (SEGMENT.aux0 ) * speed) / (int32_t )32767 ;
94059383 PartSys->sources [0 ].source .vx = ((int32_t )cos16 (SEGMENT.aux0 ) * speed) / (int32_t )32767 ;
94069384 PartSys->sources [0 ].source .vy = ((int32_t )sin16 (SEGMENT.aux0 ) * speed) / (int32_t )32767 ;
9407- PartSys->sources [0 ].source .ttl = 500 ; // source never dies
9385+ PartSys->sources [0 ].source .ttl = 500 ; // source never dies (note: setting 'perpetual' is not needed if replenished each frame)
94089386 PartSys->particleMoveUpdate (PartSys->sources [0 ].source , &ghostsettings);
94099387 // set head (steal one of the particles)
94109388 PartSys->particles [PartSys->usedParticles -1 ].x = PartSys->sources [0 ].source .x ;
0 commit comments