Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 10:44 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Fri Jan 06, 2012 6:22 pm 
Offline

Joined: Sun Jan 30, 2011 4:22 pm
Posts: 61
Hi again.
I realized recently, that I have a bottle neck in my game while creating new objects with particle systems. Since those objects are shots, there may very easy be hundreds of them created each second. But loading a particle system from XML (using ParticleIO.loadConfiguredSystem()) takes 5-15ms. So basically I need some very fast way how to duplicate a particle system. I discovered a duplicate() method on the system, but surprisingly it only does a serialization, saves the system to xml and then reloads it. So it is not faster at all.
Am I missing something ? Is there some better approach to this problematic ? It seems to me that I have a bad approach and I'm missing something obvious. Maybe I'm using the particle system in a wrong way... ?
I need to create a lot of object on fly and a particle system for each of them.
Is there someone who solved this issue somehow ?


Top
 Profile  
 
PostPosted: Fri Jan 06, 2012 7:12 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
Use ConfigurableEmitters. Their duplicate method works on the object without serializing it to XML.

Why do you need so many ParticleSystems?

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
PostPosted: Fri Jan 06, 2012 7:24 pm 
Offline

Joined: Sun Jan 30, 2011 4:22 pm
Posts: 61
I use ConfigurableEmitters, but I checked and their duplicate method is similar to the one on system. Again - save to XML and then reload.
Also what's the purpose of the particle system, if I can use only emitters ? I have a system with several emitters in one XML file, so I would like to duplicate the whole system, not only emitters.

Quote:
Why do you need so many ParticleSystems?

Well as I said - for each shot (missile, for example) I'd like to have a particle system. Let's say a ship can fire 20 missiles, then I need 20 particle systems at once. All based on the same template. Does that make sense ?


Top
 Profile  
 
PostPosted: Sat Jan 14, 2012 6:29 pm 
Offline

Joined: Sun Jan 30, 2011 4:22 pm
Posts: 61
So there is no effective solution ? :-o


Top
 Profile  
 
PostPosted: Sat Jan 14, 2012 9:11 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
Rewrite the particle system. Eg use a sane XML API (streaming), use internal cloning (eg copy constructors), split data into mutable and immutable state and copy only the mutable data - maybe add a differentiation between initial state and live data etc.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Sun Jan 15, 2012 6:14 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
You could also open an RFE and see if the dev team deals with it :wink:

But it seems there is currently no out-of-the-box solution. Sorry.

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
PostPosted: Wed Feb 08, 2012 9:11 am 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
well i also had these problems so the solution is to load all your stuff in a resource manager and pre-cache your emmitters

a related post to this you can find here: viewtopic.php?f=3&t=4420

at the end this was the solution:

ok perfect, so now i've tweaked the particlesystem "system" to my own needs, i preload the particles and refer from the system to my images "in memory" so i don't have the resourceloader to load them each time (because i need to use a lot of single effects) so the particles go up in memory, are released with the images and after a gc i'm on my initial state (lets say it starts at 20 > goes up to 70 mb and goes back down to 20 mb) which is perfect !
and my byte[] doesn't go berzerk

thank you guys !

so finally i use a stripped version of the particlesystem that load their particles from the config class which has them in memory, also the parsed xml documens so i can refer back to them if i need to re-create a system, otherwise you could use the duplicate method but then you should concider to do a deep copy of your particle system with all objects related to them but i prefer to create a clean system each time then resetting it

result, the byte array is very small + everything is garbage collected afterwards, now it runs in 50 mb of memory at 340 frames on the highest load

again tx for your support to give me a lead where to search!

cheerz


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group