From f463ae409faae9160242b1dbfde08bef4c1dbee2 Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Sun, 30 Nov 2008 16:52:14 -0500 Subject: [PATCH] added better thread safty ... still broke --- src/entityManager.cpp | 24 ++++++++++++++++++++++-- src/handleSignal.cpp | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/entityManager.cpp b/src/entityManager.cpp index 65b8273..1664210 100644 --- a/src/entityManager.cpp +++ b/src/entityManager.cpp @@ -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 diff --git a/src/handleSignal.cpp b/src/handleSignal.cpp index ef9daa6..fa5a8c4 100644 --- a/src/handleSignal.cpp +++ b/src/handleSignal.cpp @@ -19,6 +19,7 @@ #include #include +#include /// ***** Private Method Headers ***** -- 2.10.2