[Orxonox-commit 1204] r5925 - in code/branches/core5/src: libraries/core modules/objects orxonox orxonox/graphics
rgrieder at orxonox.net
rgrieder at orxonox.net
Fri Oct 9 18:46:54 CEST 2009
Author: rgrieder
Date: 2009-10-09 18:46:54 +0200 (Fri, 09 Oct 2009)
New Revision: 5925
Modified:
code/branches/core5/src/libraries/core/GUIManager.h
code/branches/core5/src/libraries/core/GraphicsManager.cc
code/branches/core5/src/modules/objects/Planet.cc
code/branches/core5/src/orxonox/CameraManager.cc
code/branches/core5/src/orxonox/graphics/Camera.cc
Log:
Reapplied some of the changes that got reverted in the last commit (including two fixes).
Modified: code/branches/core5/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/core5/src/libraries/core/GUIManager.h 2009-10-09 16:04:16 UTC (rev 5924)
+++ code/branches/core5/src/libraries/core/GUIManager.h 2009-10-09 16:46:54 UTC (rev 5925)
@@ -101,7 +101,7 @@
CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each gui
- Ogre::Camera* camera_; //!< Camera used to render the scene with the
+ Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI
static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager
Modified: code/branches/core5/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/GraphicsManager.cc 2009-10-09 16:04:16 UTC (rev 5924)
+++ code/branches/core5/src/libraries/core/GraphicsManager.cc 2009-10-09 16:46:54 UTC (rev 5925)
@@ -360,8 +360,7 @@
uint64_t timeBeforeTick = time.getRealMicroseconds();
// Render frame
- if( this->viewport_->getCamera() )
- ogreRoot_->_updateAllRenderTargets();
+ ogreRoot_->_updateAllRenderTargets();
uint64_t timeAfterTick = time.getRealMicroseconds();
// Subtract the time used for rendering from the tick time counter
Modified: code/branches/core5/src/modules/objects/Planet.cc
===================================================================
--- code/branches/core5/src/modules/objects/Planet.cc 2009-10-09 16:04:16 UTC (rev 5924)
+++ code/branches/core5/src/modules/objects/Planet.cc 2009-10-09 16:46:54 UTC (rev 5925)
@@ -46,7 +46,7 @@
/**
* @brief Constructor
*/
- Planet::Planet(BaseObject* creator): MovableEntity(creator)
+ Planet::Planet(BaseObject* creator) : MovableEntity(creator)
{
RegisterObject(Planet);
this->registerVariables();
@@ -63,13 +63,13 @@
void Planet::tick(float dt)
{
- if(!this->isVisible())
+ if (!this->isVisible())
return;
if (GameMode::showsGraphics())
{
Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
- if(activeCamera)
+ if (activeCamera)
{
float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
// COUT(2) << distance << std::endl;
Modified: code/branches/core5/src/orxonox/CameraManager.cc
===================================================================
--- code/branches/core5/src/orxonox/CameraManager.cc 2009-10-09 16:04:16 UTC (rev 5924)
+++ code/branches/core5/src/orxonox/CameraManager.cc 2009-10-09 16:46:54 UTC (rev 5925)
@@ -50,6 +50,7 @@
CameraManager::CameraManager()
: viewport_(GraphicsManager::getInstance().getViewport())
{
+ assert(GameMode::showsGraphics());
}
CameraManager::~CameraManager()
@@ -59,7 +60,7 @@
Camera* CameraManager::getActiveCamera() const
{
- if (this->cameraList_.size() > 0)
+ if (!this->cameraList_.empty())
return this->cameraList_.front();
else
return 0;
@@ -67,29 +68,24 @@
void CameraManager::requestFocus(Camera* camera)
{
- if (!GameMode::showsGraphics())
- assert(0);
-
// notify old camera (if it exists)
- if (this->cameraList_.size() > 0)
+ if (!this->cameraList_.empty())
this->cameraList_.front()->removeFocus();
camera->setFocus();
// make sure we don't add it twice
- for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
+ for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end();)
if ((*it) == camera)
- return;
-
+ this->cameraList_.erase(it++);
+ else
+ ++it;
// add to list
this->cameraList_.push_front(camera);
}
void CameraManager::releaseFocus(Camera* camera)
{
- if (!GameMode::showsGraphics())
- assert(0);
-
// notify the cam of releasing the focus
if (!this->cameraList_.empty() && this->cameraList_.front() == camera)
{
@@ -97,7 +93,7 @@
this->cameraList_.pop_front();
// set new focus if possible
- if (this->cameraList_.size() > 0)
+ if (!this->cameraList_.empty())
this->cameraList_.front()->setFocus();
}
else
Modified: code/branches/core5/src/orxonox/graphics/Camera.cc
===================================================================
--- code/branches/core5/src/orxonox/graphics/Camera.cc 2009-10-09 16:04:16 UTC (rev 5924)
+++ code/branches/core5/src/orxonox/graphics/Camera.cc 2009-10-09 16:46:54 UTC (rev 5925)
@@ -37,6 +37,7 @@
#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
+#include "core/GameMode.h"
#include "core/GUIManager.h"
#include "Scene.h"
#include "CameraManager.h"
@@ -49,6 +50,8 @@
{
RegisterObject(Camera);
+ if (!GameMode::showsGraphics())
+ ThrowException(AbortLoading, "Can't create Camera, no graphics.");
if (!this->getScene())
ThrowException(AbortLoading, "Can't create Camera, no scene.");
if (!this->getScene()->getSceneManager())
@@ -75,8 +78,8 @@
{
if (this->isInitialized())
{
- if( GUIManager::getInstance().getCamera() == this->camera_ )
- GUIManager::getInstance().setCamera( NULL );
+ if (GUIManager::getInstance().getCamera() == this->camera_)
+ GUIManager::getInstance().setCamera(NULL);
this->releaseFocus();
this->cameraNode_->detachAllObjects();
More information about the Orxonox-commit
mailing list