Determining if a Particle System is done

Moderator: spookyboo

Determining if a Particle System is done

Postby fedyakin on Wed Mar 10, 2010 6:32 pm

We want to attach a particle system to an ogre entity, play the particle system, and then remove the system when it has completed. Is there a way to be notified when the system is done? Failing that is there a way to query a system and see if it has finished?
fedyakin
 
Posts: 3
Joined: Wed Mar 10, 2010 6:20 pm

Re: Determining if a Particle System is done

Postby spookyboo on Thu Mar 11, 2010 7:30 pm

Add a ParticleSystemListener with ParticleSystem::addParticleSystemListener and implement the stopped() function.
(This triggers me to add a getState() to a Partice System, so you don't need to add a listener to every particle system).

With setFixedTimeout() you can set the amount of time after which the particle system automatically stops.
In V1.2 a new function called startAndStopFade() was added, which starts a particle system and stops after a certain amount of time. It doesn't stop immediately, but stops until all particles are expired.
User avatar
spookyboo
 
Posts: 447
Joined: Sat May 17, 2008 7:58 pm

Re: Determining if a Particle System is done

Postby fedyakin on Fri Mar 12, 2010 5:29 pm

Thanks for the quick response.

Just a quick note for anyone else that reads this thread, it's not safe to destroy a particle system from its stopped callback...
fedyakin
 
Posts: 3
Joined: Wed Mar 10, 2010 6:20 pm

Re: Determining if a Particle System is done

Postby spookyboo on Fri Mar 12, 2010 10:40 pm

I didn't realized that ParticleSystem::getState() already exists. This means you can also check on:

if (pSys->getState() == ParticleSystem::PSS_STOPPED)
User avatar
spookyboo
 
Posts: 447
Joined: Sat May 17, 2008 7:58 pm

Re: Determining if a Particle System is done

Postby alvinsay on Thu Mar 25, 2010 9:59 am

Hi,

I don't think using ParticleSystem::getState() is a efficient way to recycle or delete finished particle system.
If you have many particle system, you have to poll their states one by one in each frame!

Is there any plan to add some kind of "create and forget" mechanism?
In most scenarios, particle system are created in events such as explosion, gun firing or hitting. These events cause particle systems to be played in a short duration, then particle system are recycled or deleted. Therefore, users often need to write some classes to manage those playing once particle system, to detect whether they are done, and then do some actions for those finished. It would be appreciated if particle universe had already had this kind of mechanism itself.
alvinsay
 
Posts: 3
Joined: Thu Mar 25, 2010 9:42 am

Re: Determining if a Particle System is done

Postby spookyboo on Thu Mar 25, 2010 5:55 pm

With ParticleSystem::startAndStopFade() and
ParticleSystem::start() in combination with ParticleSystem::setFixedTimeout() you can already start a particle system, without having to check whether it has stopped. It automatically stops after a certain time. ParticleUniverse doesn't have a mechanism where particle systems are automatically deleted or added to a pool, but that is not very difficult to add. It seems that particle system pooling is a wanted feature, so I can add it to the next version.
User avatar
spookyboo
 
Posts: 447
Joined: Sat May 17, 2008 7:58 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron