ParticleSystem remove emitter by * (patch included)

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

ParticleSystem remove emitter by * (patch included)

Post by areay »

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

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);
ParticleSystem.cpp

Code: Select all

    void ParticleSystem::removeEmitter(ParticleEmitter* emitter)
    {
        mEmitters.erase(
            remove(mEmitters.begin(), mEmitters.end(), emitter), mEmitters.end());
        ParticleSystemManager::getSingleton()._destroyEmitter(emitter);
    }
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?
Attachments
ogre-1.8.0-particleEmitter.h.patch
(652 Bytes) Downloaded 119 times
ogre-1.8.0-particleEmitter.cpp.patch
(831 Bytes) Downloaded 122 times
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: ParticleSystem remove emitter by * (patch included)

Post by areay »

I think I've posted this in the wrong forum, can this be moved to 'Papercuts' by a moderator please?
Post Reply