void updateParticles(float);
void updatePhysics(float);
+void clearUpParticles();
+void clearUpPhysics();
/// ***** Private Variables *****
void manager::remove(Entity* e)
{
{
+ Autolock lock( particleSetLock );
Particle* p = dynamic_cast<Particle*>(e);
if( p != 0 )
{
}
{
+ Autolock lock( physicsEntitySetLock );
PhysicsEntity* p = dynamic_cast<PhysicsEntity*>(e);
if( p != 0 )
{
}
void manager::draw()
{
+ clearUpParticles();
{
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();
DPF(0, "Particle Draw End");
}
+ clearUpPhysics();
{
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();
void updateParticles(float time_step)
{
- {
- Autolock lock( particleSetLock );
-
- // add new Particle*s to Active
- for( setPart::iterator it = particles_To_Add.begin();
- it != particles_To_Add.end();
- it++ )
- {
- DPF(0, "Particle Insert");
- active_Particles.insert(*it);
- }
-
- // 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();
- }
-
- particles_To_Add.clear();
+ clearUpParticles();
// update active Particle*s
for( setPart::iterator it = active_Particles.begin();
}
void updatePhysics(float time_step)
{
- {
- Autolock lock( physicsEntitySetLock );
-
- // add new PhysicsEntity*s to Active
- for( setPhys::iterator it = physics_To_Add.begin();
- it != physics_To_Add.end();
- it++ )
- {
- DPF(0, "Physics Insert");
- active_Physics.insert(*it);
- }
-
- // 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();
- }
-
- physics_To_Add.clear();
+ clearUpPhysics();
// apply collision math
collision::update(active_Physics);
(*it)->update(time_step);
}
}
+void clearUpParticles()
+{
+ Autolock lock( particleSetLock );
+
+ // add new Particle*s to Active
+ for( setPart::iterator it = particles_To_Add.begin();
+ it != particles_To_Add.end();
+ it++ )
+ {
+ DPF(0, "Particle Insert");
+ active_Particles.insert(*it);
+ }
+ particles_To_Add.clear();
+
+ // 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();
+}
+void clearUpPhysics()
+{
+ Autolock lock( physicsEntitySetLock );
+
+ // add new PhysicsEntity*s to Active
+ for( setPhys::iterator it = physics_To_Add.begin();
+ it != physics_To_Add.end();
+ it++ )
+ {
+ DPF(0, "Physics Insert");
+ active_Physics.insert(*it);
+ }
+ physics_To_Add.clear();
+
+ // 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();
+}