bugfix for particle cleanup

This commit is contained in:
Mark Vejvoda
2013-09-24 03:44:15 +00:00
parent f66a0834c9
commit 875eb95790
5 changed files with 58 additions and 29 deletions

View File

@@ -2198,6 +2198,22 @@ bool ParticleManager::validateParticleSystemStillExists(ParticleSystem * particl
return (index >= 0);
}
void ParticleManager::removeParticleSystemsForParticleOwner(ParticleOwner *particleOwner) {
if(particleOwner != NULL && particleSystems.empty() == false) {
vector<ParticleSystem *> cleanupParticleSystemsList;
for(unsigned int index = 0; index < particleSystems.size(); ++index) {
ParticleSystem *ps= particleSystems[index];
if(ps != NULL && ps->getParticleOwner() == particleOwner) {
cleanupParticleSystemsList.push_back(ps);
}
}
if(cleanupParticleSystemsList.empty() == false) {
cleanupParticleSystems(cleanupParticleSystemsList);
}
}
}
int ParticleManager::findParticleSystems(ParticleSystem *psFind, const vector<ParticleSystem *> &particleSystems) const{
int result= -1;
for(unsigned int i= 0; i < particleSystems.size(); i++){
@@ -2221,6 +2237,11 @@ void ParticleManager::cleanupParticleSystems(ParticleSystem *ps) {
// }
// deleteList[ps]++;
// This code causes segfault on game end, no need to fade, just delete
//if(ps->getState() != ParticleSystem::sFade) {
// ps->fade();
//}
if(ps != NULL) {
ps->callParticleOwnerEnd(ps);
}