mirror of https://github.com/axmolengine/axmol.git
Fix indentations.
This commit is contained in:
parent
4ab0fbd62d
commit
c54b142e58
|
@ -328,8 +328,8 @@ bool ParticleSystem::allocAnimationMem()
|
|||
_particleData.animTimeDelta = (float*)malloc(_totalParticles * sizeof(float));
|
||||
_particleData.animIndex = (unsigned short*)malloc(_totalParticles * sizeof(unsigned short));
|
||||
_particleData.animCellIndex = (unsigned short*)malloc(_totalParticles * sizeof(unsigned short));
|
||||
if (_particleData.animTimeLength && _particleData.animTimeDelta &&
|
||||
_particleData.animIndex && _particleData.animCellIndex)
|
||||
if (_particleData.animTimeLength && _particleData.animTimeDelta && _particleData.animIndex &&
|
||||
_particleData.animCellIndex)
|
||||
return _isAnimAllocated = true;
|
||||
else
|
||||
// If any of the above allocations fail, then we safely deallocate the ones that succeeded.
|
||||
|
@ -829,7 +829,8 @@ void ParticleSystem::addParticles(int count, int animationIndex, int animationCe
|
|||
val = powf(val, 1 / shape.edgeElasticity);
|
||||
auto point = Vec2(((val * (shape.outerRadius - shape.innerRadius) + shape.outerRadius) -
|
||||
(shape.outerRadius - shape.innerRadius)) *
|
||||
(RANDOM_KISS() < 0.0F ? 1.0F : -1.0F), 0.0F);
|
||||
(RANDOM_KISS() < 0.0F ? 1.0F : -1.0F),
|
||||
0.0F);
|
||||
point = point.rotateByAngle(Vec2::ZERO, CC_DEGREES_TO_RADIANS(RANDOM_KISS() * 360));
|
||||
_particleData.posx[i] = _sourcePosition.x + shape.x + point.x / 2;
|
||||
_particleData.posy[i] = _sourcePosition.y + shape.y + point.y / 2;
|
||||
|
@ -1035,8 +1036,7 @@ void ParticleSystem::addParticles(int count, int animationIndex, int animationCe
|
|||
// tangential accel
|
||||
for (int i = start; i < _particleCount; ++i)
|
||||
{
|
||||
_particleData.modeA.tangentialAccel[i] =
|
||||
modeA.tangentialAccel + modeA.tangentialAccelVar * RANDOM_KISS();
|
||||
_particleData.modeA.tangentialAccel[i] = modeA.tangentialAccel + modeA.tangentialAccelVar * RANDOM_KISS();
|
||||
}
|
||||
|
||||
// rotation is dir
|
||||
|
@ -1266,16 +1266,14 @@ void ParticleSystem::setAnimationIndicesAtlas()
|
|||
// VERTICAL
|
||||
if (_texture->getPixelsHigh() > _texture->getPixelsWide())
|
||||
{
|
||||
setAnimationIndicesAtlas(_texture->getPixelsWide(),
|
||||
ParticleSystem::TexAnimDir::VERTICAL);
|
||||
setAnimationIndicesAtlas(_texture->getPixelsWide(), ParticleSystem::TexAnimDir::VERTICAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// HORIZONTAL
|
||||
if (_texture->getPixelsWide() > _texture->getPixelsHigh())
|
||||
{
|
||||
setAnimationIndicesAtlas(_texture->getPixelsHigh(),
|
||||
ParticleSystem::TexAnimDir::HORIZONTAL);
|
||||
setAnimationIndicesAtlas(_texture->getPixelsHigh(), ParticleSystem::TexAnimDir::HORIZONTAL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1375,10 +1373,10 @@ void ParticleSystem::simulate(float seconds, float frameRate)
|
|||
{
|
||||
auto l_updatePaused = _updatePaused;
|
||||
_updatePaused = false;
|
||||
seconds = seconds == SIMULATION_USE_PARTICLE_LIFETIME ?
|
||||
getLife() + getLifeVar() : seconds;
|
||||
frameRate = frameRate == SIMULATION_USE_GAME_ANIMATION_INTERVAL ?
|
||||
1.0F / Director::getInstance()->getAnimationInterval() : frameRate;
|
||||
seconds = seconds == SIMULATION_USE_PARTICLE_LIFETIME ? getLife() + getLifeVar() : seconds;
|
||||
frameRate = frameRate == SIMULATION_USE_GAME_ANIMATION_INTERVAL
|
||||
? 1.0F / Director::getInstance()->getAnimationInterval()
|
||||
: frameRate;
|
||||
auto delta = 1.0F / frameRate;
|
||||
if (seconds > delta)
|
||||
{
|
||||
|
@ -1459,7 +1457,10 @@ void ParticleSystem::update(float dt)
|
|||
{
|
||||
_fixedFPSDelta += dt;
|
||||
if (_fixedFPSDelta < 1.0F / _fixedFPS)
|
||||
{
|
||||
CC_PROFILER_STOP_CATEGORY(kProfilerCategoryParticles, "CCParticleSystem - update");
|
||||
return;
|
||||
}
|
||||
dt = _fixedFPSDelta;
|
||||
_fixedFPSDelta = 0.0F;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,8 @@ enum class EmissionShapeType
|
|||
RECTTORUS,
|
||||
CIRCLE,
|
||||
TORUS,
|
||||
CONE,
|
||||
CONETORUS,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -913,52 +915,60 @@ public:
|
|||
void setSpawnAngleVar(float angle) { _spawnAngleVar = angle; }
|
||||
|
||||
/** Gets the spawn opacity fade in time of each particle.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a specified time.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
||||
specified time.
|
||||
|
||||
* @return The spawn opacity fade in time in seconds.
|
||||
*/
|
||||
float getSpawnFadeIn() { return _spawnFadeIn; }
|
||||
/** Sets the spawn opacity fade in time of each particle when it's created.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a specified time.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
||||
* specified time.
|
||||
*
|
||||
* @param time The spawn opacity fade in time in seconds.
|
||||
*/
|
||||
void setSpawnFadeIn(float time);
|
||||
|
||||
/** Gets the spawn opacity fade in time variance of each particle.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a specified time.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
||||
* specified time.
|
||||
*
|
||||
* @return The spawn opacity fade in time variance in seconds.
|
||||
*/
|
||||
float getSpawnFadeInVar() { return _spawnFadeInVar; }
|
||||
/** Sets the spawn opacity fade in time variance of each particle when it's created.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a specified time.
|
||||
* Particles have the ability to spawn while having 0 opacity and gradually start going to 255 opacity with a
|
||||
* specified time.
|
||||
*
|
||||
* @param time The spawn opacity fade in time variance in seconds.
|
||||
*/
|
||||
void setSpawnFadeInVar(float time);
|
||||
|
||||
/** Gets the spawn opacity fade in time of each particle.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified time.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
||||
* time.
|
||||
*
|
||||
* @return The spawn opacity fade in time in seconds.
|
||||
*/
|
||||
float getSpawnScaleIn() { return _spawnScaleIn; }
|
||||
/** Sets the spawn opacity fade in time of each particle when it's created.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified time.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
||||
* time.
|
||||
*
|
||||
* @param time The spawn opacity fade in time in seconds.
|
||||
*/
|
||||
void setSpawnScaleIn(float time);
|
||||
|
||||
/** Gets the spawn opacity fade in time variance of each particle.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified time.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
||||
* time.
|
||||
*
|
||||
* @return The spawn opacity fade in time variance in seconds.
|
||||
*/
|
||||
float getSpawnScaleInVar() { return _spawnScaleInVar; }
|
||||
/** Sets the spawn opacity fade in time variance of each particle when it's created.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified time.
|
||||
* Particles have the ability to spawn while having 0.0 size and gradually start going to 1.0 size with a specified
|
||||
* time.
|
||||
*
|
||||
* @param time The spawn opacity fade in time variance in seconds.
|
||||
*/
|
||||
|
@ -996,7 +1006,8 @@ public:
|
|||
/** Enables or disables tex coord animations that are set by the emitter randomly when a particle is emitted. */
|
||||
void setEmitterAnimation(bool enabled);
|
||||
|
||||
/** Enables or disables tex coord animations that are used to make particles play a sequence forever until they die */
|
||||
/** Enables or disables tex coord animations that are used to make particles play a sequence forever until they die
|
||||
*/
|
||||
void setLoopAnimation(bool enabled);
|
||||
|
||||
bool isLifeAnimated() { return _isLifeAnimated; }
|
||||
|
@ -1024,7 +1035,10 @@ public:
|
|||
*
|
||||
* @param animations Array of specific indices of animations to play at random
|
||||
*/
|
||||
void setMultiAnimationRandomSpecific(const std::vector<unsigned short> &animations) { _randomAnimations = animations; };
|
||||
void setMultiAnimationRandomSpecific(const std::vector<unsigned short>& animations)
|
||||
{
|
||||
_randomAnimations = animations;
|
||||
};
|
||||
|
||||
/** Choose ALL animation descriptors to be selected at random for particles.
|
||||
* This function should be called after you've inserted/overwritten any animation descriptors.
|
||||
|
@ -1036,8 +1050,8 @@ public:
|
|||
* This function will automatically figure out your atlas cell size and direction for you! thank her later :) */
|
||||
void setAnimationIndicesAtlas();
|
||||
|
||||
/** Add all particle animation indices based on cell size and direction spicified if the method of rendering preferred is texture atlas.
|
||||
* will erase the array and add new indices from the atlas.
|
||||
/** Add all particle animation indices based on cell size and direction spicified if the method of rendering
|
||||
* preferred is texture atlas. will erase the array and add new indices from the atlas.
|
||||
*
|
||||
* @param unifiedCellSize The size of cell unified.
|
||||
* @param direction What direction is the atlas
|
||||
|
@ -1100,7 +1114,8 @@ public:
|
|||
|
||||
/** Add a particle animation descriptor with an index.
|
||||
*
|
||||
* @param indexOfDescriptor Index of the animation to be added, adding to the same index will just override the pervious animation descriptor
|
||||
* @param indexOfDescriptor Index of the animation to be added, adding to the same index will just override the
|
||||
* pervious animation descriptor
|
||||
* @param time length of the animation in seconds
|
||||
* @param timeVariance Time randomly selected for each different particle added on the animation length
|
||||
* @param indices An array of the indicies
|
||||
|
@ -1146,12 +1161,18 @@ public:
|
|||
void addEmissionShapeRectTorus(Vec2 pos, Size innerSize, Size outerSize);
|
||||
|
||||
/** Adds an emission shape of type Circle to the system.
|
||||
* @param edgeElasticity If the value is greater than 1.0 then particles will bias towards the edge of the circle more often the greater the value is; If the value is lower than 1.0 then particles will bias towards the center of the circle more often the closer the value is to 0.0; If the value is exactly 1.0 then there will be no bias behaviour.
|
||||
* @param edgeElasticity If the value is greater than 1.0 then particles will bias towards the edge of the circle
|
||||
* more often the greater the value is; If the value is lower than 1.0 then particles will bias towards the center
|
||||
* of the circle more often the closer the value is to 0.0; If the value is exactly 1.0 then there will be no bias
|
||||
* behaviour.
|
||||
*/
|
||||
void addEmissionShapeCircle(Vec2 pos, float radius, float edgeElasticity = 1.0F);
|
||||
|
||||
/** Adds an emission shape of type Torus to the system.
|
||||
* @param edgeElasticity If the value is greater than 1.0 then particles will bias towards the edge of the torus more often the greater the value is; If the value is lower than 1.0 then particles will bias towards the inner radius of the torus more often the closer the value is to 0.0; If the value is exactly 1.0 then there will be no bias behaviour.
|
||||
* @param edgeElasticity If the value is greater than 1.0 then particles will bias towards the edge of the torus
|
||||
* more often the greater the value is; If the value is lower than 1.0 then particles will bias towards the inner
|
||||
* radius of the torus more often the closer the value is to 0.0; If the value is exactly 1.0 then there will be no
|
||||
* bias behaviour.
|
||||
*/
|
||||
void addEmissionShapeTorus(Vec2 pos, float innerRadius, float outerRadius, float edgeElasticity = 1.0F);
|
||||
|
||||
|
@ -1171,7 +1192,9 @@ public:
|
|||
/** Advance the particle system and make it seem like it ran for this many seconds.
|
||||
*
|
||||
* @param seconds Seconds to advance. value of -1 means (SIMULATION_USE_PARTICLE_LIFETIME)
|
||||
* @param frameRate Frame rate to run the simulation with (preferred: 30.0) The higher this value is the more accurate the simulation will be at the cost of performance. value of -1 means (SIMULATION_USE_GAME_ANIMATION_INTERVAL)
|
||||
* @param frameRate Frame rate to run the simulation with (preferred: 30.0) The higher this value is the more
|
||||
* accurate the simulation will be at the cost of performance. value of -1 means
|
||||
* (SIMULATION_USE_GAME_ANIMATION_INTERVAL)
|
||||
*/
|
||||
void simulate(float seconds = SIMULATION_USE_PARTICLE_LIFETIME,
|
||||
float frameRate = SIMULATION_USE_GAME_ANIMATION_INTERVAL);
|
||||
|
@ -1180,7 +1203,9 @@ public:
|
|||
* seconds. The frame rate used for simulation accuracy is the screens refresh rate.
|
||||
*
|
||||
* @param seconds Seconds to advance. value of -1 means (SIMULATION_USE_PARTICLE_LIFETIME)
|
||||
* @param frameRate Frame rate to run the simulation with (preferred: 30.0) The higher this value is the more accurate the simulation will be at the cost of performance. value of -1 means (SIMULATION_USE_GAME_ANIMATION_INTERVAL)
|
||||
* @param frameRate Frame rate to run the simulation with (preferred: 30.0) The higher this value is the more
|
||||
* accurate the simulation will be at the cost of performance. value of -1 means
|
||||
* (SIMULATION_USE_GAME_ANIMATION_INTERVAL)
|
||||
*/
|
||||
void resimulate(float seconds = SIMULATION_USE_PARTICLE_LIFETIME,
|
||||
float frameRate = SIMULATION_USE_GAME_ANIMATION_INTERVAL);
|
||||
|
@ -1279,6 +1304,9 @@ public:
|
|||
virtual float getFixedFPS();
|
||||
|
||||
/** Sets the fixed frame rate count of the particle system.
|
||||
* i.e. if the framerate is set to 30.0 while the refresh rate is greater than 30.0 then the particle system will
|
||||
wait until it hits the 30.0 FPS mark.
|
||||
* This is usefull for increasing performance or for creating old-school effects with it.
|
||||
@param Fixed frame rate count of the particle system. (default: 0.0)
|
||||
*/
|
||||
virtual void setFixedFPS(float frameRate = 0.0F);
|
||||
|
|
|
@ -106,7 +106,9 @@ ParticleSystemQuad* ParticleSystemQuad::create(std::string_view filename)
|
|||
|
||||
ParticleSystemQuad* ParticleSystemQuad::createWithTotalParticles(int numberOfParticles)
|
||||
{
|
||||
CCASSERT(numberOfParticles <= 10000, "Adding more than 10000 particles will crash the renderer, the mesh generated has an index format of U_SHORT (uint16_t)");
|
||||
CCASSERT(numberOfParticles <= 10000,
|
||||
"Adding more than 10000 particles will crash the renderer, the mesh generated has an index format of "
|
||||
"U_SHORT (uint16_t)");
|
||||
|
||||
ParticleSystemQuad* ret = new ParticleSystemQuad();
|
||||
if (ret->initWithTotalParticles(numberOfParticles))
|
||||
|
@ -371,7 +373,8 @@ void ParticleSystemQuad::updateParticleQuads()
|
|||
V3F_C4B_T2F_Quad* quadStart = startQuad;
|
||||
if (_isScaleInAllocated)
|
||||
{
|
||||
for (int i = 0; i < _particleCount; ++i, ++startX, ++startY, ++x, ++y, ++quadStart, ++s, ++r, ++sr, ++sid, ++sil)
|
||||
for (int i = 0; i < _particleCount;
|
||||
++i, ++startX, ++startY, ++x, ++y, ++quadStart, ++s, ++r, ++sr, ++sid, ++sil)
|
||||
{
|
||||
p2.set(*startX, *startY, 0);
|
||||
worldToNodeTM.transformPoint(&p2);
|
||||
|
@ -411,7 +414,8 @@ void ParticleSystemQuad::updateParticleQuads()
|
|||
V3F_C4B_T2F_Quad* quadStart = startQuad;
|
||||
if (_isScaleInAllocated)
|
||||
{
|
||||
for (int i = 0; i < _particleCount; ++i, ++startX, ++startY, ++x, ++y, ++quadStart, ++s, ++r, ++sr, ++sid, ++sil)
|
||||
for (int i = 0; i < _particleCount;
|
||||
++i, ++startX, ++startY, ++x, ++y, ++quadStart, ++s, ++r, ++sr, ++sid, ++sil)
|
||||
{
|
||||
newPos.set(*x, *y);
|
||||
newPos.x = *x - (currentPosition.x - *startX);
|
||||
|
@ -447,7 +451,8 @@ void ParticleSystemQuad::updateParticleQuads()
|
|||
V3F_C4B_T2F_Quad* quadStart = startQuad;
|
||||
if (_isScaleInAllocated)
|
||||
{
|
||||
for (int i = 0; i < _particleCount; ++i, ++startX, ++startY, ++x, ++y, ++quadStart, ++s, ++r, ++sr, ++sid, ++sil)
|
||||
for (int i = 0; i < _particleCount;
|
||||
++i, ++startX, ++startY, ++x, ++y, ++quadStart, ++s, ++r, ++sr, ++sid, ++sil)
|
||||
{
|
||||
newPos.set(*x + pos.x, *y + pos.y);
|
||||
updatePosWithParticle(quadStart, newPos, *s, tweenfunc::expoEaseOut(*sid / *sil), *r, *sr);
|
||||
|
@ -573,8 +578,7 @@ void ParticleSystemQuad::updateParticleQuads()
|
|||
if (_opacityModifyRGB)
|
||||
{
|
||||
auto hsv = HSV();
|
||||
for (int i = 0; i < _particleCount;
|
||||
++i, ++quad, ++r, ++g, ++b, ++a, ++hue, ++sat, ++val)
|
||||
for (int i = 0; i < _particleCount; ++i, ++quad, ++r, ++g, ++b, ++a, ++hue, ++sat, ++val)
|
||||
{
|
||||
float colorR = *r;
|
||||
float colorG = *g;
|
||||
|
@ -598,8 +602,7 @@ void ParticleSystemQuad::updateParticleQuads()
|
|||
else
|
||||
{
|
||||
auto hsv = HSV();
|
||||
for (int i = 0; i < _particleCount;
|
||||
++i, ++quad, ++r, ++g, ++b, ++a, ++hue, ++sat, ++val)
|
||||
for (int i = 0; i < _particleCount; ++i, ++quad, ++r, ++g, ++b, ++a, ++hue, ++sat, ++val)
|
||||
{
|
||||
float colorR = *r;
|
||||
float colorG = *g;
|
||||
|
|
Loading…
Reference in New Issue