added better thread safty ... still broke
authorPatrik Gornicz <Gornicz.P@gmail.com>
Sun, 30 Nov 2008 21:52:14 +0000 (16:52 -0500)
committerPatrik Gornicz <Gornicz.P@gmail.com>
Sun, 30 Nov 2008 21:52:14 +0000 (16:52 -0500)
src/entityManager.cpp
src/handleSignal.cpp

index 65b8273..1664210 100644 (file)
@@ -132,6 +132,16 @@ void manager::draw()
         Autolock lock( particleSetLock );
         DPF(0, "Particle Draw Start");
 
+        // remove dead Particle*s from Active
+        for( setPart::iterator it = particles_To_Remove.begin();
+             it != particles_To_Remove.end();
+             it++ )
+        {
+            DPF(0, "Particle Delete");
+            active_Particles.erase(*it);
+        }
+        particles_To_Remove.clear();
+
         // update active Particle*s
         for( setPart::iterator it = active_Particles.begin();
              it != active_Particles.end();
@@ -147,6 +157,16 @@ void manager::draw()
         Autolock lock( physicsEntitySetLock );
         DPF(0, "Physics Draw Start");
 
+        // remove dead PhysicsEntity*s from Active
+        for( setPhys::iterator it = physics_To_Remove.begin();
+             it != physics_To_Remove.end();
+             it++ )
+        {
+            DPF(0, "Physics Delete");
+            active_Physics.erase(*it);
+        }
+        physics_To_Remove.clear();
+
         // update active PhysicsEntity*s
         for( setPhys::iterator it = active_Physics.begin();
              it != active_Physics.end();
@@ -183,10 +203,10 @@ void updateParticles(float time_step)
             DPF(0, "Particle Delete");
             active_Particles.erase(*it);
         }
+        particles_To_Remove.clear();
     }
 
     particles_To_Add.clear();
-    particles_To_Remove.clear();
 
     // update active Particle*s
     for( setPart::iterator it = active_Particles.begin();
@@ -218,9 +238,9 @@ void updatePhysics(float time_step)
             DPF(0, "Physics Delete");
             active_Physics.erase(*it);
         }
+        physics_To_Remove.clear();
     }
 
-    physics_To_Remove.clear();
     physics_To_Add.clear();
 
     // apply collision math
index ef9daa6..fa5a8c4 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <iostream>
 #include <signal.h>
+#include <stdlib.h>
 
 /// ***** Private Method Headers *****