Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 9, 2009, 6:04:16 PM (16 years ago)
Author:
scheusso
Message:

reverted r5911 partially and removed fallbackcamera
level scene now gets deleted after all when changing from level to mainmenu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/orxonox/CameraManager.cc

    r5911 r5924  
    3838#include "core/GUIManager.h"
    3939#include "core/ObjectList.h"
     40#include "core/ScopedSingletonManager.h"
    4041#include "tools/Shader.h"
    4142#include "graphics/Camera.h"
     
    4445namespace orxonox
    4546{
    46     CameraManager::CameraManager(BaseObject* creator)
    47         : BaseObject(creator)
    48         , viewport_(GraphicsManager::getInstance().getViewport())
    49         , fallbackCamera_(NULL)
     47    CameraManager* CameraManager::singletonPtr_s = 0;
     48    ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
     49
     50    CameraManager::CameraManager()
     51        : viewport_(GraphicsManager::getInstance().getViewport())
    5052    {
    51         assert(GameMode::showsGraphics());
    5253    }
    5354
    5455    CameraManager::~CameraManager()
    5556    {
    56         for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
    57             if ((*it)->camera_ == GUIManager::getInstance().getCamera())
    58                 GUIManager::getInstance().setCamera(NULL);
    59 
    60         if (this->fallbackCamera_)
    61             this->getScene()->getSceneManager()->destroyCamera(this->fallbackCamera_);
     57        GUIManager::getInstance().setCamera(0);
    6258    }
    6359
    6460    Camera* CameraManager::getActiveCamera() const
    6561    {
    66         if (!this->cameraList_.empty())
     62        if (this->cameraList_.size() > 0)
    6763            return this->cameraList_.front();
    6864        else
     
    7268    void CameraManager::requestFocus(Camera* camera)
    7369    {
     70        if (!GameMode::showsGraphics())
     71            assert(0);
     72
    7473        // notify old camera (if it exists)
    75         if (!this->cameraList_.empty())
     74        if (this->cameraList_.size() > 0)
    7675            this->cameraList_.front()->removeFocus();
    7776
     
    7978
    8079        // make sure we don't add it twice
    81         for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
     80        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
    8281            if ((*it) == camera)
    83                 this->cameraList_.erase(it++);
    84             else
    85                 ++it;
     82                return;
    8683
    8784        // add to list
     
    9188    void CameraManager::releaseFocus(Camera* camera)
    9289    {
     90        if (!GameMode::showsGraphics())
     91            assert(0);
     92
    9393        // notify the cam of releasing the focus
    9494        if (!this->cameraList_.empty() && this->cameraList_.front() == camera)
     
    9898
    9999            // set new focus if possible
    100             if (!this->cameraList_.empty())
     100            if (this->cameraList_.size() > 0)
    101101                this->cameraList_.front()->setFocus();
    102             else
    103             {
    104                 // there are no more cameras, create a fallback
    105                 if (!this->fallbackCamera_)
    106                     this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    107                 this->useCamera(this->fallbackCamera_);
    108             }
    109102        }
    110103        else
Note: See TracChangeset for help on using the changeset viewer.