[Orxonox-commit 6374] r11031 - code/branches/presentationHS15/src/modules/weapons/projectiles

landauf at orxonox.net landauf at orxonox.net
Sun Jan 3 21:46:11 CET 2016


Author: landauf
Date: 2016-01-03 21:46:11 +0100 (Sun, 03 Jan 2016)
New Revision: 11031

Modified:
   code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.cc
   code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.h
Log:
bugfix: due to a limitation of the framework, timers are not automatically destroyed at the end of a level. every timer must be controlled (and destroyed) by a BaseObject (or a descendant). this was not the case for the timer in IceGunProjectile, causing errors when a level ended while a timer was still active.
I fixed this by using a ParticleSpawner (instead of a ParticleEmitter) which is designed to destroy an emitter after a given time, thus perfectly suited for our needs.

Modified: code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.cc
===================================================================
--- code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.cc	2016-01-03 20:28:44 UTC (rev 11030)
+++ code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.cc	2016-01-03 20:46:11 UTC (rev 11031)
@@ -65,27 +65,25 @@
         model->setPosition(Vector3(0,0,0));
 
         // Add effect.
-        emitter_ = new ParticleEmitter(this->getContext());
-        this->attach(emitter_);
-        emitter_->setOrientation(this->getOrientation());
-        emitter_->setSource("Orxonox/ice");   
-        emitter_->setDeleteWithParent(false);     
+        spawner_ = new ParticleSpawner(this->getContext());
+        this->attach(spawner_);
+        spawner_->setOrientation(this->getOrientation());
+        spawner_->setSource("Orxonox/ice");
+        spawner_->setDeleteWithParent(false);
+        spawner_->setDestroydelay(particleDestructionDelay_);
     }
 
     IceGunProjectile::~IceGunProjectile()
     {
         if (this->isInitialized())
         {
-            const Vector3& pos = emitter_->getWorldPosition();
-            const Quaternion& rot = emitter_->getWorldOrientation();
-            this->detach(emitter_);
-            emitter_->setPosition(pos);
-            emitter_->setOrientation(rot);
-            emitter_->getParticleInterface()->setEnabled(false);
-            this->getScene()->getRootSceneNode()->addChild(const_cast<Ogre::SceneNode*>(emitter_->getNode()));
-
-            const ExecutorPtr& executor = createExecutor(createFunctor(&ParticleEmitter::destroy, emitter_));
-            new Timer(particleDestructionDelay_, false, executor, true);
+            const Vector3& pos = spawner_->getWorldPosition();
+            const Quaternion& rot = spawner_->getWorldOrientation();
+            this->detach(spawner_);
+            spawner_->setPosition(pos);
+            spawner_->setOrientation(rot);
+            this->getScene()->getRootSceneNode()->addChild(const_cast<Ogre::SceneNode*>(spawner_->getNode()));
+            this->spawner_->stop(true);
         }
     }
 

Modified: code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.h
===================================================================
--- code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.h	2016-01-03 20:28:44 UTC (rev 11030)
+++ code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.h	2016-01-03 20:46:11 UTC (rev 11031)
@@ -64,7 +64,7 @@
             virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
             static const float particleDestructionDelay_;
         private:
-            ParticleEmitter* emitter_;
+            ParticleSpawner* spawner_;
             float freezeTime_; //The duration of the freezing effect on a target
             float freezeFactor_; //The strength of the freezing effect
     };




More information about the Orxonox-commit mailing list