Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 13, 2009, 5:05:17 PM (15 years ago)
Author:
dafrick
Message:

Hopefully merged trunk successfully into pickup branch.

Location:
code/branches/pickup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup

  • code/branches/pickup/src/orxonox/CameraManager.cc

    r5781 r5935  
    2626 *
    2727 */
     28
    2829#include "CameraManager.h"
    2930
     
    3435#include "util/StringUtils.h"
    3536#include "core/GameMode.h"
     37#include "core/GraphicsManager.h"
    3638#include "core/GUIManager.h"
    3739#include "core/ObjectList.h"
     40#include "core/ScopedSingletonManager.h"
    3841#include "tools/Shader.h"
    3942#include "graphics/Camera.h"
     
    4346{
    4447    CameraManager* CameraManager::singletonPtr_s = 0;
     48    ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
    4549
    46     CameraManager::CameraManager(Ogre::Viewport* viewport)
    47         : viewport_(viewport)
     50    CameraManager::CameraManager()
     51        : viewport_(GraphicsManager::getInstance().getViewport())
    4852    {
    49         this->fallbackCamera_ = 0;
     53        assert(GameMode::showsGraphics());
    5054    }
    5155
    5256    CameraManager::~CameraManager()
    5357    {
    54         if (this->fallbackCamera_)
    55             this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
     58        GUIManager::getInstance().setCamera(0);
    5659    }
    5760
    5861    Camera* CameraManager::getActiveCamera() const
    5962    {
    60         if (this->cameraList_.size() > 0)
     63        if (!this->cameraList_.empty())
    6164            return this->cameraList_.front();
    6265        else
     
    6669    void CameraManager::requestFocus(Camera* camera)
    6770    {
    68         if (!GameMode::showsGraphics())
    69             return;
    70 
    7171        // notify old camera (if it exists)
    72         if (this->cameraList_.size() > 0)
     72        if (!this->cameraList_.empty())
    7373            this->cameraList_.front()->removeFocus();
    74         else if (this->fallbackCamera_)
    75         {
    76             this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
    77             this->fallbackCamera_ = 0;
    78         }
    7974
    8075        camera->setFocus();
    8176
    8277        // make sure we don't add it twice
    83         for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
     78        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
    8479            if ((*it) == camera)
    85                 return;
    86 
     80                this->cameraList_.erase(it++);
     81            else
     82                ++it;
    8783        // add to list
    8884        this->cameraList_.push_front(camera);
     
    9187    void CameraManager::releaseFocus(Camera* camera)
    9288    {
    93         if (!GameMode::showsGraphics())
    94             return;
    95 
    9689        // notify the cam of releasing the focus
    97         if (this->cameraList_.front() == camera)
     90        if (!this->cameraList_.empty() && this->cameraList_.front() == camera)
    9891        {
    9992            camera->removeFocus();
     
    10194
    10295            // set new focus if possible
    103             if (this->cameraList_.size() > 0)
     96            if (!this->cameraList_.empty())
    10497                this->cameraList_.front()->setFocus();
    105             else
    106             {
    107                 // there are no more cameras, create a fallback
    108                 if (!this->fallbackCamera_)
    109                     this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    110                 this->useCamera(this->fallbackCamera_);
    111             }
    11298        }
    11399        else
    114         {
    115100            this->cameraList_.remove(camera);
    116         }
    117101    }
    118102
Note: See TracChangeset for help on using the changeset viewer.