ParticleSystem remove emitter by * (patch included)
Posted: Thu Jul 12, 2012 2:35 am
Hi guys,
I'd like to be able to delete Ogre::ParticleSystem "Emitter"s by pointer. At the moment the only function available is to delete via an index (which you can't actually get from the emitter anyway!) http://www.ogre3d.org/docs/api/html/cla ... ystem.html
I'd like to submit this patch which overloads 'Ogre::ParticleSystem::removeEmitter()' function to take a pointer to an emitter, it's a very simple change.
ParticleSystem.h
ParticleSystem.cpp
The reason that I'm needing this function is that to save on batches I often just create a single ParticleSystem and then create heaps of emitters all over the place. I know there are downsides to this but come deletion time it's real difficult to delete via index (especially after emitters have been getting added & deleted). In case anyone is interested, here's a forum post I made a while ago detailing how I go about doing this http://www.ogre3d.org/forums/viewtopic.php?f=2&t=69259 I'd like to turn this into a wiki article but until it's easy to delete emitters I'm going to hold off.
I've attached the patch files to this post, I've tested them and they work fine.
Thoughts?
I'd like to be able to delete Ogre::ParticleSystem "Emitter"s by pointer. At the moment the only function available is to delete via an index (which you can't actually get from the emitter anyway!) http://www.ogre3d.org/docs/api/html/cla ... ystem.html
I'd like to submit this patch which overloads 'Ogre::ParticleSystem::removeEmitter()' function to take a pointer to an emitter, it's a very simple change.
ParticleSystem.h
Code: Select all
/** Removes an emitter from the system.
@remarks
Drops the emitter from this system.
@param
emitter Pointer to a particle emitter.
*/
void removeEmitter(ParticleEmitter *emitter);
Code: Select all
void ParticleSystem::removeEmitter(ParticleEmitter* emitter)
{
mEmitters.erase(
remove(mEmitters.begin(), mEmitters.end(), emitter), mEmitters.end());
ParticleSystemManager::getSingleton()._destroyEmitter(emitter);
}
I've attached the patch files to this post, I've tested them and they work fine.
Thoughts?