particle limits are back again
This commit is contained in:
parent
5f698575d9
commit
268aa4793b
|
@ -105,7 +105,7 @@ protected:
|
||||||
bool active;
|
bool active;
|
||||||
bool visible;
|
bool visible;
|
||||||
int aliveParticleCount;
|
int aliveParticleCount;
|
||||||
//int particleCount;
|
int particleCount;
|
||||||
|
|
||||||
|
|
||||||
Texture *texture;
|
Texture *texture;
|
||||||
|
|
|
@ -50,7 +50,7 @@ ParticleSystem::ParticleSystem(int particleCount) {
|
||||||
particleObserver= NULL;
|
particleObserver= NULL;
|
||||||
|
|
||||||
//params
|
//params
|
||||||
//this->particleCount= particleCount;
|
this->particleCount= particleCount;
|
||||||
//this->particleCount= particles.size();
|
//this->particleCount= particles.size();
|
||||||
maxParticleEnergy= 250;
|
maxParticleEnergy= 250;
|
||||||
varParticleEnergy= 50;
|
varParticleEnergy= 50;
|
||||||
|
@ -101,13 +101,7 @@ void ParticleSystem::update() {
|
||||||
Particle *p = createParticle();
|
Particle *p = createParticle();
|
||||||
initParticle(p, i);
|
initParticle(p, i);
|
||||||
}
|
}
|
||||||
emissionState=emissionState-(float)emissionIntValue;
|
emissionState=emissionState-(float)emissionIntValue;
|
||||||
// if(aliveParticleCount==0){
|
|
||||||
// Particle *p = createParticle();
|
|
||||||
// initParticle(p, 0);
|
|
||||||
// emissionState=0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,16 +200,21 @@ int ParticleSystem::isEmpty() const{
|
||||||
Particle * ParticleSystem::createParticle(){
|
Particle * ParticleSystem::createParticle(){
|
||||||
|
|
||||||
//if any dead particles
|
//if any dead particles
|
||||||
if(aliveParticleCount < particles.size()) {
|
if(aliveParticleCount < particleCount) {
|
||||||
++aliveParticleCount;
|
++aliveParticleCount;
|
||||||
return &particles[aliveParticleCount-1];
|
return &particles[aliveParticleCount-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
//if not
|
//if not
|
||||||
particles.push_back(Particle());
|
int minEnergy = particles[0].energy;
|
||||||
int particleCount = particles.size();
|
int minEnergyParticle = 0;
|
||||||
int minEnergy = particles[particleCount-1].energy;
|
|
||||||
int minEnergyParticle = particleCount-1;
|
for(int i = 0; i < particleCount; ++i){
|
||||||
|
if(particles[i].energy < minEnergy){
|
||||||
|
minEnergy = particles[i].energy;
|
||||||
|
minEnergyParticle = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
return &particles[minEnergyParticle];
|
return &particles[minEnergyParticle];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -521,22 +520,6 @@ void UnitParticleSystem::updateParticle(Particle *p){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
p->lastPos= p->pos;
|
|
||||||
p->pos= p->pos+p->speed;
|
|
||||||
p->energy--;
|
|
||||||
|
|
||||||
if(p->color.x>0.0f)
|
|
||||||
p->color.x*= 0.98f;
|
|
||||||
if(p->color.y>0.0f)
|
|
||||||
p->color.y*= 0.98f;
|
|
||||||
if(p->color.w>0.0f)
|
|
||||||
p->color.w*= 0.98f;
|
|
||||||
|
|
||||||
p->speed.x*=1.001f;
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= SET PARAMS ====================
|
// ================= SET PARAMS ====================
|
||||||
|
@ -961,13 +944,13 @@ void ParticleManager::update(int renderFps) {
|
||||||
chrono.start();
|
chrono.start();
|
||||||
|
|
||||||
int particleSystemCount = particleSystems.size();
|
int particleSystemCount = particleSystems.size();
|
||||||
int particleCount = 0;
|
int currentParticleCount = 0;
|
||||||
|
|
||||||
vector<ParticleSystem *> cleanupParticleSystemsList;
|
vector<ParticleSystem *> cleanupParticleSystemsList;
|
||||||
for (int i = 0; i < particleSystems.size(); i++) {
|
for (int i = 0; i < particleSystems.size(); i++) {
|
||||||
ParticleSystem *ps = particleSystems[i];
|
ParticleSystem *ps = particleSystems[i];
|
||||||
if(ps != NULL) {
|
if(ps != NULL) {
|
||||||
particleCount += ps->getAliveParticleCount();
|
currentParticleCount += ps->getAliveParticleCount();
|
||||||
|
|
||||||
bool showParticle = true;
|
bool showParticle = true;
|
||||||
if( dynamic_cast<UnitParticleSystem *>(ps) != NULL ||
|
if( dynamic_cast<UnitParticleSystem *>(ps) != NULL ||
|
||||||
|
@ -987,7 +970,7 @@ void ParticleManager::update(int renderFps) {
|
||||||
//particleSystems.remove(NULL);
|
//particleSystems.remove(NULL);
|
||||||
cleanupParticleSystems(cleanupParticleSystemsList);
|
cleanupParticleSystems(cleanupParticleSystemsList);
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld, particleSystemCount = %d, particleCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),particleSystemCount,particleCount);
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld, particleSystemCount = %d, currentParticleCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),particleSystemCount,currentParticleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParticleManager::validateParticleSystemStillExists(ParticleSystem * particleSystem) const {
|
bool ParticleManager::validateParticleSystemStillExists(ParticleSystem * particleSystem) const {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user