[Orxonox-commit 1547] r6265 - in code/branches/presentation2/src/orxonox: sound weaponsystem

scheusso at orxonox.net scheusso at orxonox.net
Mon Dec 7 14:23:46 CET 2009


Author: scheusso
Date: 2009-12-07 14:23:46 +0100 (Mon, 07 Dec 2009)
New Revision: 6265

Modified:
   code/branches/presentation2/src/orxonox/sound/SoundManager.cc
   code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
   code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h
Log:
fixed weapon sound source problem


Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.cc	2009-12-06 22:23:49 UTC (rev 6264)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.cc	2009-12-07 13:23:46 UTC (rev 6265)
@@ -153,6 +153,7 @@
     void SoundManager::preUpdate(const Clock& time)
     {
         this->processCrossFading(time.getDeltaTime());
+        alcProcessContext(this->context_);
     }
 
     void SoundManager::setConfigValues()

Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc	2009-12-06 22:23:49 UTC (rev 6264)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc	2009-12-07 13:23:46 UTC (rev 6265)
@@ -38,6 +38,7 @@
 #include "Weapon.h"
 #include "WeaponPack.h"
 #include "WeaponSystem.h"
+#include "WeaponSlot.h"
 
 #include "sound/WorldSound.h"
 
@@ -71,6 +72,7 @@
 
         this->defSndWpnFire_ = new WorldSound(this);
         this->defSndWpnFire_->setLooping(false);
+        this->bSoundAttached_ = false;
     }
 
     WeaponMode::~WeaponMode()
@@ -103,6 +105,12 @@
     bool WeaponMode::fire(float* reloadTime)
     {
         (*reloadTime) = this->reloadTime_;
+        if( !this->bSoundAttached_ )
+        {
+            assert(this->getWeapon() && this->getWeapon()->getWeaponSlot());
+            this->getWeapon()->getWeaponSlot()->attach(this->defSndWpnFire_);
+            this->bSoundAttached_ = true;
+        }
 
         if (!this->bReloading_ && this->munition_ && this->munition_->takeMunition(this->munitionPerShot_, this))
         {
@@ -121,8 +129,6 @@
             this->reloadTimer_.setInterval(reloadtime);
             this->reloadTimer_.startTimer();
 
-            assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
-            this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
             if(!(this->defSndWpnFire_->isPlaying()))
             {
                 this->defSndWpnFire_->play();

Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h	2009-12-06 22:23:49 UTC (rev 6264)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h	2009-12-07 13:23:46 UTC (rev 6265)
@@ -165,6 +165,7 @@
             Quaternion muzzleOrientation_;
 
             WorldSound* defSndWpnFire_;
+            bool        bSoundAttached_;
     };
 }
 




More information about the Orxonox-commit mailing list