@@ -242,6 +242,7 @@ void ParticleSystem::initParticle(Particle *p, float t)
242
242
243
243
p->position = pos;
244
244
245
+ float rand_x, rand_y;
245
246
switch (areaSpreadDistribution)
246
247
{
247
248
case DISTRIBUTION_UNIFORM:
@@ -252,6 +253,12 @@ void ParticleSystem::initParticle(Particle *p, float t)
252
253
p->position .x += (float ) rng.randomNormal (areaSpread.getX ());
253
254
p->position .y += (float ) rng.randomNormal (areaSpread.getY ());
254
255
break ;
256
+ case DISTRIBUTION_ELLIPSE:
257
+ rand_x = (float ) rng.random (-1 , 1 );
258
+ rand_y = (float ) rng.random (-1 , 1 );
259
+ p->position .x += areaSpread.getX () * (rand_x * sqrt (1 - 0 .5f *pow (rand_y, 2 )));
260
+ p->position .y += areaSpread.getY () * (rand_y * sqrt (1 - 0 .5f *pow (rand_x, 2 )));
261
+ break ;
255
262
case DISTRIBUTION_NONE:
256
263
default :
257
264
break ;
@@ -969,6 +976,7 @@ StringMap<ParticleSystem::AreaSpreadDistribution, ParticleSystem::DISTRIBUTION_M
969
976
{ " none" , DISTRIBUTION_NONE },
970
977
{ " uniform" , DISTRIBUTION_UNIFORM },
971
978
{ " normal" , DISTRIBUTION_NORMAL },
979
+ { " ellipse" , DISTRIBUTION_ELLIPSE },
972
980
};
973
981
974
982
StringMap<ParticleSystem::AreaSpreadDistribution, ParticleSystem::DISTRIBUTION_MAX_ENUM> ParticleSystem::distributions (ParticleSystem::distributionsEntries, sizeof (ParticleSystem::distributionsEntries));
0 commit comments