Skip to content

Commit ae8f756

Browse files
committed
Renamed RANDOM_M11
1 parent 36a2e67 commit ae8f756

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/ParticleSystem.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ inline void normalizePoint(float x, float y, Pointf* out)
4545
/**
4646
A more effect random number getter function, get from ejoy2d.
4747
*/
48-
inline static float RANDOM_M11(unsigned int* seed)
48+
inline static float randomM11(unsigned int* seed)
4949
{
5050
*seed = *seed * 134775813 + 1;
5151
union
@@ -92,45 +92,45 @@ void ParticleSystem::addParticles(int count)
9292
{
9393
return;
9494
}
95-
uint32_t RANDSEED = std::rand();
95+
uint32_t randseed = std::rand();
9696

9797
int start = _particleCount;
9898
_particleCount += count;
9999

100100
//life
101101
for (int i = start; i < _particleCount; ++i)
102102
{
103-
float theLife = _life + _lifeVar * RANDOM_M11(&RANDSEED);
103+
float theLife = _life + _lifeVar * randomM11(&randseed);
104104
particle_data_[i].timeToLive = (std::max)(0.0f, theLife);
105105
}
106106

107107
//position
108108
for (int i = start; i < _particleCount; ++i)
109109
{
110-
particle_data_[i].posx = _sourcePosition.x + _posVar.x * RANDOM_M11(&RANDSEED);
110+
particle_data_[i].posx = _sourcePosition.x + _posVar.x * randomM11(&randseed);
111111
}
112112

113113
for (int i = start; i < _particleCount; ++i)
114114
{
115-
particle_data_[i].posy = _sourcePosition.y + _posVar.y * RANDOM_M11(&RANDSEED);
115+
particle_data_[i].posy = _sourcePosition.y + _posVar.y * randomM11(&randseed);
116116
}
117117

118118
//color
119119
#define SET_COLOR(c, b, v) \
120120
for (int i = start; i < _particleCount; ++i) \
121121
{ \
122-
particle_data_[i].c = clampf((b) + (v) * RANDOM_M11(&RANDSEED), 0, 1); \
122+
particle_data_[i].c = clampf((b) + (v) * randomM11(&randseed), 0, 1); \
123123
}
124124

125-
SET_COLOR(colorR, _startColor.r, _startColorVar.r)
126-
SET_COLOR(colorG, _startColor.g, _startColorVar.g)
127-
SET_COLOR(colorB, _startColor.b, _startColorVar.b)
128-
SET_COLOR(colorA, _startColor.a, _startColorVar.a)
125+
SET_COLOR(colorR, _startColor.r, _startColorVar.r)
126+
SET_COLOR(colorG, _startColor.g, _startColorVar.g)
127+
SET_COLOR(colorB, _startColor.b, _startColorVar.b)
128+
SET_COLOR(colorA, _startColor.a, _startColorVar.a)
129129

130-
SET_COLOR(deltaColorR, _endColor.r, _endColorVar.r)
131-
SET_COLOR(deltaColorG, _endColor.g, _endColorVar.g)
132-
SET_COLOR(deltaColorB, _endColor.b, _endColorVar.b)
133-
SET_COLOR(deltaColorA, _endColor.a, _endColorVar.a)
130+
SET_COLOR(deltaColorR, _endColor.r, _endColorVar.r)
131+
SET_COLOR(deltaColorG, _endColor.g, _endColorVar.g)
132+
SET_COLOR(deltaColorB, _endColor.b, _endColorVar.b)
133+
SET_COLOR(deltaColorA, _endColor.a, _endColorVar.a)
134134

135135
#define SET_DELTA_COLOR(c, dc) \
136136
for (int i = start; i < _particleCount; ++i) \
@@ -146,15 +146,15 @@ void ParticleSystem::addParticles(int count)
146146
//size
147147
for (int i = start; i < _particleCount; ++i)
148148
{
149-
particle_data_[i].size = _startSize + _startSizeVar * RANDOM_M11(&RANDSEED);
149+
particle_data_[i].size = _startSize + _startSizeVar * randomM11(&randseed);
150150
particle_data_[i].size = (std::max)(0.0f, particle_data_[i].size);
151151
}
152152

153153
if (_endSize != START_SIZE_EQUAL_TO_END_SIZE)
154154
{
155155
for (int i = start; i < _particleCount; ++i)
156156
{
157-
float endSize = _endSize + _endSizeVar * RANDOM_M11(&RANDSEED);
157+
float endSize = _endSize + _endSizeVar * randomM11(&randseed);
158158
endSize = (std::max)(0.0f, endSize);
159159
particle_data_[i].deltaSize = (endSize - particle_data_[i].size) / particle_data_[i].timeToLive;
160160
}
@@ -170,11 +170,11 @@ void ParticleSystem::addParticles(int count)
170170
// rotation
171171
for (int i = start; i < _particleCount; ++i)
172172
{
173-
particle_data_[i].rotation = _startSpin + _startSpinVar * RANDOM_M11(&RANDSEED);
173+
particle_data_[i].rotation = _startSpin + _startSpinVar * randomM11(&randseed);
174174
}
175175
for (int i = start; i < _particleCount; ++i)
176176
{
177-
float endA = _endSpin + _endSpinVar * RANDOM_M11(&RANDSEED);
177+
float endA = _endSpin + _endSpinVar * randomM11(&randseed);
178178
particle_data_[i].deltaRotation = (endA - particle_data_[i].rotation) / particle_data_[i].timeToLive;
179179
}
180180

@@ -199,23 +199,23 @@ void ParticleSystem::addParticles(int count)
199199
// radial accel
200200
for (int i = start; i < _particleCount; ++i)
201201
{
202-
particle_data_[i].modeA.radialAccel = modeA.radialAccel + modeA.radialAccelVar * RANDOM_M11(&RANDSEED);
202+
particle_data_[i].modeA.radialAccel = modeA.radialAccel + modeA.radialAccelVar * randomM11(&randseed);
203203
}
204204

205205
// tangential accel
206206
for (int i = start; i < _particleCount; ++i)
207207
{
208-
particle_data_[i].modeA.tangentialAccel = modeA.tangentialAccel + modeA.tangentialAccelVar * RANDOM_M11(&RANDSEED);
208+
particle_data_[i].modeA.tangentialAccel = modeA.tangentialAccel + modeA.tangentialAccelVar * randomM11(&randseed);
209209
}
210210

211211
// rotation is dir
212212
if (modeA.rotationIsDir)
213213
{
214214
for (int i = start; i < _particleCount; ++i)
215215
{
216-
float a = deg2Rad(_angle + _angleVar * RANDOM_M11(&RANDSEED));
216+
float a = deg2Rad(_angle + _angleVar * randomM11(&randseed));
217217
Vec2 v(cosf(a), sinf(a));
218-
float s = modeA.speed + modeA.speedVar * RANDOM_M11(&RANDSEED);
218+
float s = modeA.speed + modeA.speedVar * randomM11(&randseed);
219219
Vec2 dir = v * s;
220220
particle_data_[i].modeA.dirX = dir.x; //v * s ;
221221
particle_data_[i].modeA.dirY = dir.y;
@@ -226,9 +226,9 @@ void ParticleSystem::addParticles(int count)
226226
{
227227
for (int i = start; i < _particleCount; ++i)
228228
{
229-
float a = deg2Rad(_angle + _angleVar * RANDOM_M11(&RANDSEED));
229+
float a = deg2Rad(_angle + _angleVar * randomM11(&randseed));
230230
Vec2 v(cosf(a), sinf(a));
231-
float s = modeA.speed + modeA.speedVar * RANDOM_M11(&RANDSEED);
231+
float s = modeA.speed + modeA.speedVar * randomM11(&randseed);
232232
Vec2 dir = v * s;
233233
particle_data_[i].modeA.dirX = dir.x; //v * s ;
234234
particle_data_[i].modeA.dirY = dir.y;
@@ -241,18 +241,18 @@ void ParticleSystem::addParticles(int count)
241241
{
242242
for (int i = start; i < _particleCount; ++i)
243243
{
244-
particle_data_[i].modeB.radius = modeB.startRadius + modeB.startRadiusVar * RANDOM_M11(&RANDSEED);
244+
particle_data_[i].modeB.radius = modeB.startRadius + modeB.startRadiusVar * randomM11(&randseed);
245245
}
246246

247247
for (int i = start; i < _particleCount; ++i)
248248
{
249-
particle_data_[i].modeB.angle = deg2Rad(_angle + _angleVar * RANDOM_M11(&RANDSEED));
249+
particle_data_[i].modeB.angle = deg2Rad(_angle + _angleVar * randomM11(&randseed));
250250
}
251251

252252
for (int i = start; i < _particleCount; ++i)
253253
{
254254
particle_data_[i].modeB.degreesPerSecond =
255-
deg2Rad(modeB.rotatePerSecond + modeB.rotatePerSecondVar * RANDOM_M11(&RANDSEED));
255+
deg2Rad(modeB.rotatePerSecond + modeB.rotatePerSecondVar * randomM11(&randseed));
256256
}
257257

258258
if (modeB.endRadius == START_RADIUS_EQUAL_TO_END_RADIUS)
@@ -266,7 +266,7 @@ void ParticleSystem::addParticles(int count)
266266
{
267267
for (int i = start; i < _particleCount; ++i)
268268
{
269-
float endRadius = modeB.endRadius + modeB.endRadiusVar * RANDOM_M11(&RANDSEED);
269+
float endRadius = modeB.endRadius + modeB.endRadiusVar * randomM11(&randseed);
270270
particle_data_[i].modeB.deltaRadius = (endRadius - particle_data_[i].modeB.radius) / particle_data_[i].timeToLive;
271271
}
272272
}

0 commit comments

Comments
 (0)