[Orxonox-commit 1192] r5913 - code/branches/core5/src/orxonox/controllers

rgrieder at orxonox.net rgrieder at orxonox.net
Thu Oct 8 23:23:14 CEST 2009


Author: rgrieder
Date: 2009-10-08 23:23:13 +0200 (Thu, 08 Oct 2009)
New Revision: 5913

Modified:
   code/branches/core5/src/orxonox/controllers/HumanController.cc
Log:
Using the Camera position instead of the ControllableEntity position for the sound listener.

Modified: code/branches/core5/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/core5/src/orxonox/controllers/HumanController.cc	2009-10-08 21:11:49 UTC (rev 5912)
+++ code/branches/core5/src/orxonox/controllers/HumanController.cc	2009-10-08 21:23:13 UTC (rev 5913)
@@ -35,6 +35,7 @@
 #include "gametypes/Gametype.h"
 #include "infos/PlayerInfo.h"
 #include "overlays/Map.h"
+#include "graphics/Camera.h"
 #include "sound/SoundManager.h"
 #include "Radar.h"
 #include "Scene.h"
@@ -79,14 +80,17 @@
 
     void HumanController::tick(float dt)
     {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+        if (GameMode::playsSound() && HumanController::localController_s && HumanController::localController_s->controllableEntity_)
         {
-            if (GameMode::playsSound())
+            // Update sound listener
+            Camera* camera = HumanController::localController_s->controllableEntity_->getCamera();
+            if (camera)
             {
-                // Update sound listener
-                SoundManager::getInstance().setListenerPosition(HumanController::localController_s->controllableEntity_->getPosition());
-                SoundManager::getInstance().setListenerOrientation(HumanController::localController_s->controllableEntity_->getOrientation());
+                SoundManager::getInstance().setListenerPosition(camera->getPosition());
+                SoundManager::getInstance().setListenerOrientation(camera->getOrientation());
             }
+            else
+                COUT(3) << "HumanController, Warning: Using a ControllableEntity without Camera" << std::endl;
         }
     }
 




More information about the Orxonox-commit mailing list