Browse Source

we can now perform an update on a single particle system

Josh Wilson 19 years ago
parent
commit
2425624c9d

+ 26 - 0
panda/src/particlesystem/particleSystemManager.cxx

@@ -127,6 +127,32 @@ do_particles(float dt) {
   //  cout << "ParticleSystemManager::doparticles exiting." << endl;
 }
 
+////////////////////////////////////////////////////////////////////
+//    Function : do_particles
+//      Access : public
+// Description : does an update and render for each ps in the list.
+//               this is probably the one you want to use.  Rendering
+//               is the expensive operation, and particles REALLY
+//               should at least be updated every frame, so nth_frame
+//               stepping applies only to rendering.
+////////////////////////////////////////////////////////////////////
+void ParticleSystemManager::
+do_particles(float dt, ParticleSystem *ps, bool do_render) {
+  if (ps->get_active_system_flag() == true) {
+    ps->update(dt);
+    // Handle age:
+    if (ps->get_system_grows_older_flag() == true) {
+      float age = ps->get_system_age() + dt;
+      ps->set_system_age(age);
+    }
+    
+    // handle render
+    if (do_render) {
+      ps->render();
+    }
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function : output
 //       Access : Public

+ 1 - 0
panda/src/particlesystem/particleSystemManager.h

@@ -44,6 +44,7 @@ PUBLISHED:
   INLINE void clear();
 
   void do_particles(float dt);
+  void do_particles(float dt, ParticleSystem * ps, bool do_render = true);
 
   virtual void output(ostream &out) const;
   virtual void write_ps_list(ostream &out, int indent=0) const;