Skip to main content
GameDev.net gamedev.net
🔒 Locked

Which data structure, or sorting algorithm to use?

Started by ph33r Nov 21, 2004 at 2:07 PM 0 replies 400+ views
Original Post
ph33r
ph33r
I'm designing a particle system right now and a particle manager. The particle manager has a list of all particles for every type of system, be it a gun, rain, or snow, all the particles are stored in one giant master list. The manager has a fixed size, say 5000 particles and a boolean called isAlive. When I add a particle to a system, it checks the master list for the first dead particle and uses it. My question is this: I need to sort by texture every frame, but should I also sort by isAlive every frame? What would be the most optimal way of aranging the data structures. Should I have a master list of particles, and sort? Or should I only sort by texture and iterate through the whole list only drawing alive particles. Or should I have a list of dead aprticles and alive particles. In my opinion, it would make sense to use a boolean of alive and dead, so I don't have to erase and recreate every frame because particle systems have erratic lifetime behaviors. But I'm not sure whats the best way of structing this, any help is appreciated.
Zahlman
Zahlman
Assuming your 'list' is some STL container, I think you want to look at "std::partition".

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.