Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 3:37:48 AM (16 years ago)
Author:
landauf
Message:
  • Added a health bar
  • Some changes in CameraManager to handle the case when no camera exists after removing the last one, but this is still somehow buggy (freezes and later crashes reproducible but inexplicable after a few respawns)
  • Added PawnManager to handle destruction of Pawns without using delete within tick()
File:
1 edited

Legend:

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

    r2171 r2369  
    3030
    3131#include <OgreViewport.h>
     32#include <OgreSceneManager.h>
     33#include <OgreCamera.h>
    3234
    3335#include "core/Core.h"
    3436#include "objects/worldentities/Camera.h"
    35 
     37#include "objects/Scene.h"
     38#include "util/String.h"
    3639
    3740namespace orxonox
     
    4447        assert(singletonRef_s == 0);
    4548        singletonRef_s = this;
     49
     50        this->fallbackCamera_ = 0;
    4651    }
    4752
     
    5055        assert(singletonRef_s != 0);
    5156        singletonRef_s = 0;
     57
     58        if (this->fallbackCamera_)
     59        {
     60            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
     61COUT(0) << "remove camera-manager" << std::endl;
     62        }
    5263    }
    5364
     
    6879        if (this->cameraList_.size() > 0)
    6980            this->cameraList_.front()->removeFocus();
     81        else if (this->fallbackCamera_)
     82        {
     83            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
     84            this->fallbackCamera_ = 0;
     85COUT(0) << "remove fallback camera" << std::endl;
     86        }
    7087
    7188        camera->setFocus(this->viewport_);
    7289
     90        // make sure we don't add it twice
     91        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
     92            if ((*it) == camera)
     93                return;
     94
    7395        // add to list
    74         std::list<Camera*>::iterator it;
    75         for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
    76         {
    77             if ((*it) == camera)
    78                 return; // make sure we don't add it twice
    79         }
    8096        this->cameraList_.push_front(camera);
    8197    }
     
    92108            this->cameraList_.pop_front();
    93109
    94             // set new focus if necessary
    95             if (cameraList_.size() > 0)
    96                 cameraList_.front()->setFocus(this->viewport_);
     110            // set new focus if possible
     111            if (this->cameraList_.size() > 0)
     112                this->cameraList_.front()->setFocus(this->viewport_);
     113            else
     114            {
     115                // there are no more cameras, create a fallback
     116                if (!this->fallbackCamera_)
     117                {
     118COUT(0) << "create fallback camera" << std::endl;
     119                    this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
     120                }
     121                this->viewport_->setCamera(this->fallbackCamera_);
     122COUT(0) << "use fallback camera" << std::endl;
     123            }
    97124        }
    98125        else
Note: See TracChangeset for help on using the changeset viewer.