15 #include "particleSystemManager.h" 16 #include "particleSystem.h" 18 #include "pandabase.h" 19 #include "physicsManager.h" 20 #include "clockObject.h" 21 #include "pStatTimer.h" 25 PStatCollector ParticleSystemManager::_do_particles_collector(
"App:Particles:Do Particles");
34 _nth_frame(every_nth_frame), _cur_frame(0) {
56 found = find(_ps_list.begin(), _ps_list.end(), ptps);
58 if (found == _ps_list.end())
61 _ps_list.erase(found);
80 bool render_due =
false;
84 if (_cur_frame >= _nth_frame) {
89 cur = _ps_list.begin();
94 while (cur != _ps_list.end()) {
98 if (cur_ps->get_active_system_flag() ==
true) {
104 if (cur_ps->get_system_grows_older_flag() ==
true) {
105 PN_stdfloat age = cur_ps->get_system_age() + dt;
106 cur_ps->set_system_age(age);
109 if (age >= cur_ps->get_system_lifespan()) {
113 _ps_list.erase(kill);
124 if (cur != _ps_list.end()) {
141 if (ps->get_active_system_flag() ==
true) {
144 if (ps->get_system_grows_older_flag() ==
true) {
145 PN_stdfloat age = ps->get_system_age() + dt;
146 ps->set_system_age(age);
165 out<<
"ParticleSystemManager";
179 out<<
""<<
"_ps_list ("<<_ps_list.size()<<
" systems)\n";
183 (*i)->write(out, indent+2);
195 write(ostream &out,
int indent)
const {
197 out.width(indent); out<<
""; out<<
"ParticleSystemManager:\n";
198 out.width(indent+2); out<<
""; out<<
"_nth_frame "<<_nth_frame<<
"\n";
199 out.width(indent+2); out<<
""; out<<
"_cur_frame "<<_cur_frame<<
"\n";
void remove_particlesystem(ParticleSystem *ps)
removes a ps from the maintenance list
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
void do_particles(PN_stdfloat dt)
does an update and render for each ps in the list.
virtual void write_ps_list(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
This is our own Panda specialization on the default STL list.
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
A lightweight class that represents a single element that may be timed and/or counted via stats...
Contains and manages a particle system.
ParticleSystemManager(int every_nth_frame=1)
default constructor
void update(PN_stdfloat dt)
Updates the particle system.
void render()
Populates an attached GeomNode structure with the particle geometry for rendering.
virtual ~ParticleSystemManager()
Destructor.