[Orxonox-commit 3164] r7857 - in code/trunk/src/orxonox/worldentities: . pawns

landauf at orxonox.net landauf at orxonox.net
Fri Feb 11 17:17:39 CET 2011


Author: landauf
Date: 2011-02-11 17:17:39 +0100 (Fri, 11 Feb 2011)
New Revision: 7857

Modified:
   code/trunk/src/orxonox/worldentities/ControllableEntity.cc
   code/trunk/src/orxonox/worldentities/pawns/Spectator.h
Log:
 - fixed a crash if mouse look was switched on and off for a ControllableEntity without CameraPosition
 - disabled mouse look for Spectator
 - disable mouse look if camera switches to a position which doesn't allow mouse look


Modified: code/trunk/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.cc	2011-02-11 15:05:55 UTC (rev 7856)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.cc	2011-02-11 16:17:39 UTC (rev 7857)
@@ -203,21 +203,29 @@
                 this->camera_->attachToNode(this->cameraPositionRootNode_);
                 this->currentCameraPosition_ = 0;
             }
+            
+            // disable mouse look if the new camera position doesn't allow it
+            if (this->currentCameraPosition_ && !this->currentCameraPosition_->getAllowMouseLook() && this->bMouseLook_)
+                this->mouseLook();
         }
     }
 
     void ControllableEntity::mouseLook()
     {
-        this->bMouseLook_ = !this->bMouseLook_;
+        // enable mouse look only if allowed - disabling it works always
+        if (this->currentCameraPosition_ && (this->currentCameraPosition_->getAllowMouseLook() || this->bMouseLook_))
+        {
+            this->bMouseLook_ = !this->bMouseLook_;
 
-        if (!this->bMouseLook_)
-            this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY);
-        if (this->getCamera())
-        {
-            if (!this->bMouseLook_&& this->currentCameraPosition_->getDrag())
-                this->getCamera()->setDrag(true);
-            else
-                this->getCamera()->setDrag(false);
+            if (!this->bMouseLook_)
+                this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY);
+            if (this->getCamera())
+            {
+                if (!this->bMouseLook_ && this->currentCameraPosition_->getDrag())
+                    this->getCamera()->setDrag(true);
+                else
+                    this->getCamera()->setDrag(false);
+            }
         }
     }
 

Modified: code/trunk/src/orxonox/worldentities/pawns/Spectator.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Spectator.h	2011-02-11 15:05:55 UTC (rev 7856)
+++ code/trunk/src/orxonox/worldentities/pawns/Spectator.h	2011-02-11 16:17:39 UTC (rev 7857)
@@ -55,6 +55,7 @@
 
             virtual void fired(unsigned int firemode);
             virtual void greet();
+            virtual void mouseLook() {}
 
         protected:
             virtual void setPlayer(PlayerInfo* player);




More information about the Orxonox-commit mailing list