hunted some memory leaks (with success)
parent
cad9b49ffd
commit
ca21f8c63a
|
@ -1,3 +1,5 @@
|
||||||
|
PROJECT ( Asteroids )
|
||||||
|
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||||
|
|
||||||
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake )
|
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake )
|
||||||
|
@ -36,8 +38,8 @@ SET ( ASTEROIDS_SOURCES
|
||||||
asteroids/MenuOverlay.cc
|
asteroids/MenuOverlay.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE ( hasteroids ${ASTEROIDS_SOURCES} )
|
ADD_EXECUTABLE ( run_asteroids ${ASTEROIDS_SOURCES} )
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES ( hasteroids
|
TARGET_LINK_LIBRARIES ( run_asteroids
|
||||||
Engine
|
Engine
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,7 +21,6 @@ Engine::EntityPhysicState* EntityFactory::CreateEntityPhysicState (int type) {
|
||||||
// However to prevent errors we do a simple check vor validity.
|
// However to prevent errors we do a simple check vor validity.
|
||||||
if (type < 0 || type > GameEntityTypeLast ) {
|
if (type < 0 || type > GameEntityTypeLast ) {
|
||||||
Engine::LogError ("Cannot create Entity with type %d: invalid type!", type);
|
Engine::LogError ("Cannot create Entity with type %d: invalid type!", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the Entity
|
// Create the Entity
|
||||||
|
@ -32,7 +31,6 @@ Engine::EntityPhysicState* EntityFactory::CreateEntityPhysicState (int type) {
|
||||||
entity_physics = new ShipEntityPhysicState ();
|
entity_physics = new ShipEntityPhysicState ();
|
||||||
if (!entity_physics) {
|
if (!entity_physics) {
|
||||||
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
entity_physics->mRadius = 0.5;
|
entity_physics->mRadius = 0.5;
|
||||||
entity_physics->mShape = new coll2d::Sphere (entity_physics->mRadius);
|
entity_physics->mShape = new coll2d::Sphere (entity_physics->mRadius);
|
||||||
|
@ -42,7 +40,6 @@ Engine::EntityPhysicState* EntityFactory::CreateEntityPhysicState (int type) {
|
||||||
entity_physics = new AsteroidEntityPhysicState ();
|
entity_physics = new AsteroidEntityPhysicState ();
|
||||||
if (!entity_physics) {
|
if (!entity_physics) {
|
||||||
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity_physics->mRadius = 1.;
|
entity_physics->mRadius = 1.;
|
||||||
|
@ -53,7 +50,6 @@ Engine::EntityPhysicState* EntityFactory::CreateEntityPhysicState (int type) {
|
||||||
entity_physics = new RocketEntityPhysicState();
|
entity_physics = new RocketEntityPhysicState();
|
||||||
if (!entity_physics) {
|
if (!entity_physics) {
|
||||||
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
entity_physics->mRadius = 0.1;
|
entity_physics->mRadius = 0.1;
|
||||||
entity_physics->mShape = new coll2d::Sphere (entity_physics->mRadius);
|
entity_physics->mShape = new coll2d::Sphere (entity_physics->mRadius);
|
||||||
|
@ -62,13 +58,11 @@ Engine::EntityPhysicState* EntityFactory::CreateEntityPhysicState (int type) {
|
||||||
entity_physics->mBaseType = Engine::EntityBaseTypeBlock;
|
entity_physics->mBaseType = Engine::EntityBaseTypeBlock;
|
||||||
if (!entity_physics) {
|
if (!entity_physics) {
|
||||||
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
Engine::LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
entity_physics->mRadius = 0.1;
|
entity_physics->mRadius = 0.1;
|
||||||
entity_physics->mShape = new coll2d::Sphere (entity_physics->mRadius);
|
entity_physics->mShape = new coll2d::Sphere (entity_physics->mRadius);
|
||||||
} else {
|
} else {
|
||||||
Engine::LogError ("No EntityPhysicState defined for GameEntity type '%d'", type);
|
Engine::LogError ("No EntityPhysicState defined for GameEntity type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity_physics->mType = type;
|
entity_physics->mType = type;
|
||||||
|
@ -81,7 +75,6 @@ Engine::EntityControllerState* EntityFactory::CreateEntityControllerState (int t
|
||||||
// However to prevent errors we do a simple check vor validity.
|
// However to prevent errors we do a simple check vor validity.
|
||||||
if (type < 0 || type >> Engine::EntityBaseTypeLast ) {
|
if (type < 0 || type >> Engine::EntityBaseTypeLast ) {
|
||||||
Engine::LogError ("Cannot create Entity with type %d: invalid type!", type);
|
Engine::LogError ("Cannot create Entity with type %d: invalid type!", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the Entity
|
// Create the Entity
|
||||||
|
@ -92,7 +85,6 @@ Engine::EntityControllerState* EntityFactory::CreateEntityControllerState (int t
|
||||||
entity_controller = new Engine::EntityControllerState ();
|
entity_controller = new Engine::EntityControllerState ();
|
||||||
if (!entity_controller) {
|
if (!entity_controller) {
|
||||||
Engine::LogError ("Could not allocate enough memory for EntityControllerState of type '%d'", type);
|
Engine::LogError ("Could not allocate enough memory for EntityControllerState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +96,6 @@ Engine::EntityBase* EntityFactory::CreateEntity (int type) {
|
||||||
// However to prevent errors we do a simple check vor validity.
|
// However to prevent errors we do a simple check vor validity.
|
||||||
if (type < 0 || type > GameEntityTypeLast ) {
|
if (type < 0 || type > GameEntityTypeLast ) {
|
||||||
Engine::LogError ("Cannot create Entity with type %d: invalid type!", type);
|
Engine::LogError ("Cannot create Entity with type %d: invalid type!", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the Entity
|
// Create the Entity
|
||||||
|
@ -125,7 +116,6 @@ Engine::EntityBase* EntityFactory::CreateEntity (int type) {
|
||||||
|
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
Engine::LogError ("Could not allocate enough memory for EntityVisualState of type '%d'", type);
|
Engine::LogError ("Could not allocate enough memory for EntityVisualState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->mPhysicState = CreateEntityPhysicState (type);
|
entity->mPhysicState = CreateEntityPhysicState (type);
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace asteroids {
|
||||||
|
|
||||||
class Model : public Engine::ModelBase {
|
class Model : public Engine::ModelBase {
|
||||||
public:
|
public:
|
||||||
|
virtual ~Model() {};
|
||||||
virtual void Process();
|
virtual void Process();
|
||||||
int DoLoadLevel (const char* filename);
|
int DoLoadLevel (const char* filename);
|
||||||
int DoSaveLevel (const char* filename);
|
int DoSaveLevel (const char* filename);
|
||||||
|
@ -26,6 +27,10 @@ class Model : public Engine::ModelBase {
|
||||||
protected:
|
protected:
|
||||||
/** \brief Initializes the system */
|
/** \brief Initializes the system */
|
||||||
virtual int OnInit (int argc, char* argv[]);
|
virtual int OnInit (int argc, char* argv[]);
|
||||||
|
virtual void OnDestroy() {
|
||||||
|
Engine::ModelBase::OnDestroy();
|
||||||
|
mAsteroids.clear();
|
||||||
|
};
|
||||||
virtual void OnRegisterCommands ();
|
virtual void OnRegisterCommands ();
|
||||||
|
|
||||||
virtual void OnCreateEntity (const int type, const unsigned int id);
|
virtual void OnCreateEntity (const int type, const unsigned int id);
|
||||||
|
|
|
@ -30,16 +30,16 @@ int View::OnInit (int argc, char* argv[]) {
|
||||||
ViewBase::OnInit (argc, argv);
|
ViewBase::OnInit (argc, argv);
|
||||||
|
|
||||||
// We want menu
|
// We want menu
|
||||||
mMenuOverlay = new MenuOverlay;
|
mMenuOverlay = boost::shared_ptr<MenuOverlay> (new MenuOverlay);
|
||||||
mMenuOverlay->SetModel ((Model*) mModel);
|
mMenuOverlay->SetModel ((Model*) mModel);
|
||||||
mMenuOverlay->Init();
|
mMenuOverlay->Init();
|
||||||
AddOverlay (mMenuOverlay);
|
AddOverlay (mMenuOverlay);
|
||||||
|
|
||||||
// We want the console
|
// We want the console
|
||||||
Engine::SimpleConsoleOverlay *console = new Engine::SimpleConsoleOverlay;
|
mConsoleOverlay = boost::shared_ptr<Engine::SimpleConsoleOverlay> (new Engine::SimpleConsoleOverlay);
|
||||||
// We also want to display the log bar
|
// We also want to display the log bar
|
||||||
console->SetDrawLogBar (true);
|
mConsoleOverlay->SetDrawLogBar (true);
|
||||||
AddOverlay (console);
|
AddOverlay (mConsoleOverlay);
|
||||||
|
|
||||||
// This is a simple star field that makes the game so spacy
|
// This is a simple star field that makes the game so spacy
|
||||||
int i;
|
int i;
|
||||||
|
@ -73,6 +73,14 @@ int View::OnInit (int argc, char* argv[]) {
|
||||||
|
|
||||||
void View::OnDestroy() {
|
void View::OnDestroy() {
|
||||||
delete mAccelerateEventHandler;
|
delete mAccelerateEventHandler;
|
||||||
|
delete mShipExplodeEventHandler;
|
||||||
|
|
||||||
|
mBackgroundStars.clear();
|
||||||
|
mShipPartsEntityIds.clear();
|
||||||
|
|
||||||
|
mMenuOverlay.reset();
|
||||||
|
|
||||||
|
Engine::ViewBase::OnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
#define _VIEW_H
|
#define _VIEW_H
|
||||||
|
|
||||||
#include "ViewBase.h"
|
#include "ViewBase.h"
|
||||||
|
#include "OverlayBase.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "EntityBase.h"
|
#include "EntityBase.h"
|
||||||
|
#include "SimpleConsoleOverlay.h"
|
||||||
|
|
||||||
namespace asteroids {
|
namespace asteroids {
|
||||||
|
|
||||||
|
@ -20,10 +22,13 @@ struct BackgroundStar {
|
||||||
/** \brief Performs the actual drawing based on Camera and Model
|
/** \brief Performs the actual drawing based on Camera and Model
|
||||||
*/
|
*/
|
||||||
class View : public Engine::ViewBase {
|
class View : public Engine::ViewBase {
|
||||||
|
public:
|
||||||
|
virtual ~View() {};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \brief Initializes the system */
|
/** \brief Initializes the system */
|
||||||
int OnInit (int argc, char* argv[]);
|
virtual int OnInit (int argc, char* argv[]);
|
||||||
void OnDestroy ();
|
virtual void OnDestroy ();
|
||||||
|
|
||||||
/** \brief Updates the camera for further drawing */
|
/** \brief Updates the camera for further drawing */
|
||||||
virtual void UpdateCamera ();
|
virtual void UpdateCamera ();
|
||||||
|
@ -38,7 +43,11 @@ class View : public Engine::ViewBase {
|
||||||
void DrawRocket (RocketEntity *asteroid);
|
void DrawRocket (RocketEntity *asteroid);
|
||||||
void DrawShipPart (Engine::EntityBase *entity);
|
void DrawShipPart (Engine::EntityBase *entity);
|
||||||
|
|
||||||
MenuOverlay *mMenuOverlay;
|
// Engine::OverlayBasePtr mMenuOverlay;
|
||||||
|
// Engine::OverlayBasePtr mConsoleOverlay;
|
||||||
|
boost::shared_ptr<MenuOverlay> mMenuOverlay;
|
||||||
|
boost::shared_ptr<Engine::SimpleConsoleOverlay> mConsoleOverlay;
|
||||||
|
|
||||||
std::vector<BackgroundStar> mBackgroundStars;
|
std::vector<BackgroundStar> mBackgroundStars;
|
||||||
|
|
||||||
std::vector<unsigned int> mShipPartsEntityIds;
|
std::vector<unsigned int> mShipPartsEntityIds;
|
||||||
|
|
|
@ -27,7 +27,6 @@ void EntityControllerState::UnsetKey (int state) {
|
||||||
void EntityBase::SetControllerKeyState (int state) {
|
void EntityBase::SetControllerKeyState (int state) {
|
||||||
if (!mControllerState) {
|
if (!mControllerState) {
|
||||||
LogError ("Error when trying to send a KeyState to an Entity that has no EntityControllerState!");
|
LogError ("Error when trying to send a KeyState to an Entity that has no EntityControllerState!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mControllerState->SetKey (state);
|
mControllerState->SetKey (state);
|
||||||
|
@ -36,7 +35,6 @@ void EntityBase::SetControllerKeyState (int state) {
|
||||||
void EntityBase::UnsetControllerKeyState (int state) {
|
void EntityBase::UnsetControllerKeyState (int state) {
|
||||||
if (!mControllerState) {
|
if (!mControllerState) {
|
||||||
LogError ("Error when trying to send a KeyState to an Entity that has no EntityControllerState!");
|
LogError ("Error when trying to send a KeyState to an Entity that has no EntityControllerState!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mControllerState->UnsetKey (state);
|
mControllerState->UnsetKey (state);
|
||||||
|
|
|
@ -18,7 +18,6 @@ EntityPhysicState* EntityFactoryBase::CreateEntityPhysicState (int type) {
|
||||||
// However to prevent errors we do a simple check vor validity.
|
// However to prevent errors we do a simple check vor validity.
|
||||||
if (type < 0 || type >> EntityBaseTypeLast ) {
|
if (type < 0 || type >> EntityBaseTypeLast ) {
|
||||||
LogError ("Cannot create Entity with type %d: invalid type!", type);
|
LogError ("Cannot create Entity with type %d: invalid type!", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
EntityBaseType base_type = (EntityBaseType) type;
|
EntityBaseType base_type = (EntityBaseType) type;
|
||||||
|
|
||||||
|
@ -26,7 +25,6 @@ EntityPhysicState* EntityFactoryBase::CreateEntityPhysicState (int type) {
|
||||||
EntityPhysicState* entity_physics = new EntityPhysicState ();
|
EntityPhysicState* entity_physics = new EntityPhysicState ();
|
||||||
if (!entity_physics) {
|
if (!entity_physics) {
|
||||||
LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// default values for all entities
|
// default values for all entities
|
||||||
|
@ -52,7 +50,6 @@ EntityPhysicState* EntityFactoryBase::CreateEntityPhysicState (int type) {
|
||||||
assert (entity_physics->mShape);
|
assert (entity_physics->mShape);
|
||||||
} else {
|
} else {
|
||||||
LogError ("No EntityPhysicState defined for Entity base_type '%d'", base_type);
|
LogError ("No EntityPhysicState defined for Entity base_type '%d'", base_type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity_physics;
|
return entity_physics;
|
||||||
|
@ -63,7 +60,6 @@ EntityControllerState* EntityFactoryBase::CreateEntityControllerState (int type)
|
||||||
// However to prevent errors we do a simple check vor validity.
|
// However to prevent errors we do a simple check vor validity.
|
||||||
if (type < 0 || type >> EntityBaseTypeLast ) {
|
if (type < 0 || type >> EntityBaseTypeLast ) {
|
||||||
LogError ("Cannot create Entity with type %d: invalid type!", type);
|
LogError ("Cannot create Entity with type %d: invalid type!", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
EntityBaseType base_type = (EntityBaseType) type;
|
EntityBaseType base_type = (EntityBaseType) type;
|
||||||
|
|
||||||
|
@ -76,13 +72,11 @@ EntityControllerState* EntityFactoryBase::CreateEntityControllerState (int type)
|
||||||
entity_controller = new EntityControllerState ();
|
entity_controller = new EntityControllerState ();
|
||||||
if (!entity_controller) {
|
if (!entity_controller) {
|
||||||
LogError ("Could not allocate enough memory for EntityControllerState of type '%d'", type);
|
LogError ("Could not allocate enough memory for EntityControllerState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
} else if (base_type == EntityBaseTypeBlock) {
|
} else if (base_type == EntityBaseTypeBlock) {
|
||||||
} else if (base_type == EntityBaseTypeParticle) {
|
} else if (base_type == EntityBaseTypeParticle) {
|
||||||
} else {
|
} else {
|
||||||
LogError ("No EntityPhysicState defined for Entity base_type '%d'", base_type);
|
LogError ("No EntityPhysicState defined for Entity base_type '%d'", base_type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity_controller;
|
return entity_controller;
|
||||||
|
@ -93,7 +87,6 @@ EntityBase* EntityFactoryBase::CreateEntity (int type) {
|
||||||
// However to prevent errors we do a simple check vor validity.
|
// However to prevent errors we do a simple check vor validity.
|
||||||
if (type < 0 || type >> EntityBaseTypeLast ) {
|
if (type < 0 || type >> EntityBaseTypeLast ) {
|
||||||
LogError ("Cannot create Entity with type %d: invalid type!", type);
|
LogError ("Cannot create Entity with type %d: invalid type!", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
EntityBaseType base_type = (EntityBaseType) type;
|
EntityBaseType base_type = (EntityBaseType) type;
|
||||||
|
|
||||||
|
@ -103,7 +96,6 @@ EntityBase* EntityFactoryBase::CreateEntity (int type) {
|
||||||
|
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
LogError ("Could not allocate enough memory for EntityVisualState of type '%d'", type);
|
LogError ("Could not allocate enough memory for EntityVisualState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->mPhysicState = CreateEntityPhysicState (type);
|
entity->mPhysicState = CreateEntityPhysicState (type);
|
||||||
|
|
|
@ -74,6 +74,14 @@ void Logging::Log (LogLevel level, const char *str, ...) {
|
||||||
<< ": " << msg << std::endl;
|
<< ": " << msg << std::endl;
|
||||||
mLogFileOut.flush();
|
mLogFileOut.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (level == LogLevelError) {
|
||||||
|
std::cerr << "Error occured: Aborting!" << std::endl;
|
||||||
|
mLogFileOut << "Error occured: Aborting!" << std::endl;
|
||||||
|
mLogFileOut.flush();
|
||||||
|
mLogFileOut.close();
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logging::SetLogPrintLevel (LogLevel print_level) {
|
void Logging::SetLogPrintLevel (LogLevel print_level) {
|
||||||
|
@ -85,7 +93,6 @@ void Logging::SetLogFilename (const char *filename) {
|
||||||
|
|
||||||
if (!mLogFileOut) {
|
if (!mLogFileOut) {
|
||||||
LogError ("Could not open logfile %s for writing!", filename);
|
LogError ("Could not open logfile %s for writing!", filename);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
requested_logfilename = "";
|
requested_logfilename = "";
|
||||||
|
|
|
@ -13,6 +13,7 @@ class Module;
|
||||||
* a log filename was specified by Logging::SetLogFilename() then all messages
|
* a log filename was specified by Logging::SetLogFilename() then all messages
|
||||||
* sent to the Logging class are written to the file.
|
* sent to the Logging class are written to the file.
|
||||||
*
|
*
|
||||||
|
* \note The program automatically abortst when reporting an error
|
||||||
* \TODO Add log level for files separately
|
* \TODO Add log level for files separately
|
||||||
*/
|
*/
|
||||||
class Logging : public Module {
|
class Logging : public Module {
|
||||||
|
|
|
@ -26,7 +26,10 @@ void SetLogPrintLevel (LogLevel print_level);
|
||||||
/** \brief Sets the filename to which all the logging is sent, set to NULL to disable logging */
|
/** \brief Sets the filename to which all the logging is sent, set to NULL to disable logging */
|
||||||
void SetLogFilename (const char *filename);
|
void SetLogFilename (const char *filename);
|
||||||
|
|
||||||
/** \brief Sends the Message to the Logging system */
|
/** \brief Sends the Message to the Logging system
|
||||||
|
*
|
||||||
|
* \note The program automatically abortst when reporting an error
|
||||||
|
*/
|
||||||
void LogError (const char* str, ...);
|
void LogError (const char* str, ...);
|
||||||
/** \brief Sends the Message to the Logging system */
|
/** \brief Sends the Message to the Logging system */
|
||||||
void LogWarning (const char* str, ...);
|
void LogWarning (const char* str, ...);
|
||||||
|
|
|
@ -53,7 +53,6 @@ void ModelBase::Process () {
|
||||||
do {
|
do {
|
||||||
if (entity_iter->second == NULL) {
|
if (entity_iter->second == NULL) {
|
||||||
LogError ("Entity with id %d does not exist!", entity_iter->first);
|
LogError ("Entity with id %d does not exist!", entity_iter->first);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
entity_iter->second->Update(mDeltaSec);
|
entity_iter->second->Update(mDeltaSec);
|
||||||
entity_iter++;
|
entity_iter++;
|
||||||
|
@ -93,7 +92,6 @@ void ModelBase::RegisterEntity (EntityBase* entity) {
|
||||||
|
|
||||||
if (mEntities.find(id) != mEntities.end ()) {
|
if (mEntities.find(id) != mEntities.end ()) {
|
||||||
LogError ("Replacing Entity with id '%d'", id);
|
LogError ("Replacing Entity with id '%d'", id);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity->mPhysicState)
|
if (entity->mPhysicState)
|
||||||
|
@ -107,7 +105,6 @@ void ModelBase::KillEntity (const unsigned int id) {
|
||||||
|
|
||||||
if (iter == mEntities.end ()) {
|
if (iter == mEntities.end ()) {
|
||||||
LogError ("Could not kill Entity with id '%d': Entity not found!", id);
|
LogError ("Could not kill Entity with id '%d': Entity not found!", id);
|
||||||
assert (0);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
EntityBase *entity = iter->second;
|
EntityBase *entity = iter->second;
|
||||||
|
@ -128,7 +125,6 @@ void ModelBase::UnregisterEntity (const unsigned int id) {
|
||||||
|
|
||||||
if (iter == mEntities.end ()) {
|
if (iter == mEntities.end ()) {
|
||||||
LogError ("Could not unregister Entity with id '%d': Entity not found!", id);
|
LogError ("Could not unregister Entity with id '%d': Entity not found!", id);
|
||||||
assert (0);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
EntityBase *entity = iter->second;
|
EntityBase *entity = iter->second;
|
||||||
|
@ -137,6 +133,11 @@ void ModelBase::UnregisterEntity (const unsigned int id) {
|
||||||
entity->mPhysicState = NULL;
|
entity->mPhysicState = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity->mControllerState) {
|
||||||
|
delete entity->mControllerState;
|
||||||
|
entity->mControllerState = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
delete entity;
|
delete entity;
|
||||||
|
|
||||||
mEntities.erase (iter);
|
mEntities.erase (iter);
|
||||||
|
@ -228,7 +229,6 @@ void ModelBase::SendEntityCollisionEvent (const unsigned int reference_entity_id
|
||||||
unsigned int GetPlayerEntityId () {
|
unsigned int GetPlayerEntityId () {
|
||||||
if (!ModelInstance) {
|
if (!ModelInstance) {
|
||||||
LogError ("Couldn't create Entity: Model not initialized!");
|
LogError ("Couldn't create Entity: Model not initialized!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ModelInstance->GetPlayerEntityId ();
|
return ModelInstance->GetPlayerEntityId ();
|
||||||
|
@ -237,7 +237,6 @@ unsigned int GetPlayerEntityId () {
|
||||||
float GetFrameDuration () {
|
float GetFrameDuration () {
|
||||||
if (!ModelInstance) {
|
if (!ModelInstance) {
|
||||||
LogError ("Couldn't create Entity: Model not initialized!");
|
LogError ("Couldn't create Entity: Model not initialized!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ModelInstance->GetFrameDuration ();
|
return ModelInstance->GetFrameDuration ();
|
||||||
|
@ -246,7 +245,6 @@ float GetFrameDuration () {
|
||||||
EntityBase * CreateEntity (int type) {
|
EntityBase * CreateEntity (int type) {
|
||||||
if (!ModelInstance) {
|
if (!ModelInstance) {
|
||||||
LogError ("Couldn't create Entity: Model not initialized!");
|
LogError ("Couldn't create Entity: Model not initialized!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityBase *result = ModelInstance->CreateEntity (type);
|
EntityBase *result = ModelInstance->CreateEntity (type);
|
||||||
|
@ -257,7 +255,6 @@ EntityBase * CreateEntity (int type) {
|
||||||
void DestroyEntity (unsigned int id) {
|
void DestroyEntity (unsigned int id) {
|
||||||
if (!ModelInstance) {
|
if (!ModelInstance) {
|
||||||
LogError ("Couldn't destroy Entity: Model not initialized!");
|
LogError ("Couldn't destroy Entity: Model not initialized!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelInstance->UnregisterEntity (id);
|
ModelInstance->UnregisterEntity (id);
|
||||||
|
@ -266,7 +263,6 @@ void DestroyEntity (unsigned int id) {
|
||||||
void KillEntity (unsigned int id) {
|
void KillEntity (unsigned int id) {
|
||||||
if (!ModelInstance) {
|
if (!ModelInstance) {
|
||||||
LogError ("Couldn't kill Entity: Model not initialized!");
|
LogError ("Couldn't kill Entity: Model not initialized!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelInstance->KillEntity (id);
|
ModelInstance->KillEntity (id);
|
||||||
|
@ -275,7 +271,6 @@ void KillEntity (unsigned int id) {
|
||||||
EntityBase * GetEntity (unsigned int id) {
|
EntityBase * GetEntity (unsigned int id) {
|
||||||
if (!ModelInstance) {
|
if (!ModelInstance) {
|
||||||
LogError ("Couldn't execute GetEntity(): Model not initialized!");
|
LogError ("Couldn't execute GetEntity(): Model not initialized!");
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ModelInstance->GetEntity (id);
|
return ModelInstance->GetEntity (id);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef OVERLAY
|
#ifndef OVERLAY
|
||||||
#define OVERLAY
|
#define OVERLAY
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
|
||||||
namespace Engine {
|
namespace Engine {
|
||||||
|
@ -20,6 +22,8 @@ class OverlayBase {
|
||||||
void _strange_function_for_vtable () {};
|
void _strange_function_for_vtable () {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<OverlayBase> OverlayBasePtr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* OVERLAY */
|
#endif /* OVERLAY */
|
||||||
|
|
|
@ -144,13 +144,12 @@ void PhysicsBase::RegisterEntity (EntityPhysicState* entity) {
|
||||||
mEntities[id] = entity;
|
mEntities[id] = entity;
|
||||||
else {
|
else {
|
||||||
LogError ("Physics already has registered an Entity with id '%d'", id);
|
LogError ("Physics already has registered an Entity with id '%d'", id);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsBase::UnregisterEntity (const unsigned int id) {
|
void PhysicsBase::UnregisterEntity (const unsigned int id) {
|
||||||
std::map<unsigned int, EntityPhysicState*>::iterator iter = mEntities.find(id);
|
std::map<unsigned int, EntityPhysicState*>::iterator iter = mEntities.find(id);
|
||||||
LogDebug ("Unegistering EntityPhysicState with id '%d'", id);
|
LogDebug ("Unregistering EntityPhysicState with id '%d'", id);
|
||||||
|
|
||||||
if (iter != mEntities.end ()) {
|
if (iter != mEntities.end ()) {
|
||||||
// Remove all the references of existing contacts to the Entity that is
|
// Remove all the references of existing contacts to the Entity that is
|
||||||
|
@ -175,7 +174,6 @@ void PhysicsBase::UnregisterEntity (const unsigned int id) {
|
||||||
delete entity_physic_state;
|
delete entity_physic_state;
|
||||||
} else {
|
} else {
|
||||||
LogError ("Could not unegister EntityPhysicState with id '%d': Entity not found!", id);
|
LogError ("Could not unegister EntityPhysicState with id '%d': Entity not found!", id);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +252,6 @@ bool PhysicsBase::CalcNextCollision (
|
||||||
|
|
||||||
if (!HandleColl2dError (coll2d_result, stepsize, entity_a, entity_b, temp_info)) {
|
if (!HandleColl2dError (coll2d_result, stepsize, entity_a, entity_b, temp_info)) {
|
||||||
LogError ("Could not handle coll2d error: %d\n", coll2d_result);
|
LogError ("Could not handle coll2d error: %d\n", coll2d_result);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coll2d_result > 0 && temp_info.time < info.time ) {
|
if (coll2d_result > 0 && temp_info.time < info.time ) {
|
||||||
|
@ -267,7 +264,6 @@ bool PhysicsBase::CalcNextCollision (
|
||||||
} else {
|
} else {
|
||||||
reference_entity_id = collision_iter->first;
|
reference_entity_id = collision_iter->first;
|
||||||
incidence_entity_id = collision_ref->first;
|
incidence_entity_id = collision_ref->first;
|
||||||
//assert (0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,8 +406,6 @@ void PhysicsBase::ContactCacheAdd (EntityPhysicState* incidence_entity, EntityPh
|
||||||
void PhysicsBase::ContactCacheRemove (unsigned int entity_a_id, unsigned int entity_b_id) {
|
void PhysicsBase::ContactCacheRemove (unsigned int entity_a_id, unsigned int entity_b_id) {
|
||||||
assert (entity_a_id != entity_b_id);
|
assert (entity_a_id != entity_b_id);
|
||||||
|
|
||||||
// LogDebug ("Removing start %d and %d", entity_a_id, entity_b_id);
|
|
||||||
|
|
||||||
EntityPhysicState *entity_a, *entity_b;
|
EntityPhysicState *entity_a, *entity_b;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -447,8 +441,6 @@ void PhysicsBase::ContactCacheRemove (unsigned int entity_a_id, unsigned int ent
|
||||||
contact_normal[0], contact_normal[1], contact_normal[2],
|
contact_normal[0], contact_normal[1], contact_normal[2],
|
||||||
entity_b_id, entity_a_id);
|
entity_b_id, entity_a_id);
|
||||||
entity_b->mContactNormals.erase (entity_b->mContactNormals.find(entity_a_id));
|
entity_b->mContactNormals.erase (entity_b->mContactNormals.find(entity_a_id));
|
||||||
|
|
||||||
// LogDebug ("Removing done!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Checks whether we are still in contact with the entities stored in mContactNormals
|
/** \brief Checks whether we are still in contact with the entities stored in mContactNormals
|
||||||
|
@ -471,12 +463,12 @@ void PhysicsBase::CheckContactCache (EntityPhysicState* entity) {
|
||||||
// * Attention! *
|
// * Attention! *
|
||||||
// current_iter can be used throughout this environment and contacts_iter
|
// current_iter can be used throughout this environment and contacts_iter
|
||||||
// can already now be increased as it *must not* be used! This is due to
|
// can already now be increased as it *must not* be used! This is due to
|
||||||
// the nature of ContactCachRemove() which might make contacts_iter
|
// the nature of ContactCacheRemove() which might make contacts_iter
|
||||||
// invalid if we were using that.
|
// invalid if we were using that.
|
||||||
current_iter = contacts_iter;
|
current_iter = contacts_iter;
|
||||||
contacts_iter ++;
|
contacts_iter ++;
|
||||||
|
|
||||||
unsigned int contact_entity_id = contacts_iter->first;
|
unsigned int contact_entity_id = current_iter->first;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
EntityPhysicState* contact_entity = mEntities[contact_entity_id];
|
EntityPhysicState* contact_entity = mEntities[contact_entity_id];
|
||||||
|
@ -484,7 +476,7 @@ void PhysicsBase::CheckContactCache (EntityPhysicState* entity) {
|
||||||
EntityPhysicState* contact_entity = mEntities.at (contact_entity_id);
|
EntityPhysicState* contact_entity = mEntities.at (contact_entity_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vector3d normal = contacts_iter->second;
|
vector3d normal = current_iter->second;
|
||||||
vector3d old_velocity = entity->GetVelocity();
|
vector3d old_velocity = entity->GetVelocity();
|
||||||
|
|
||||||
// If we already move away from the normal, we delete the contact.
|
// If we already move away from the normal, we delete the contact.
|
||||||
|
@ -508,21 +500,19 @@ void PhysicsBase::CheckContactCache (EntityPhysicState* entity) {
|
||||||
if (!HandleColl2dError (coll2d_result, 1.0, entity, contact_entity, info)) {
|
if (!HandleColl2dError (coll2d_result, 1.0, entity, contact_entity, info)) {
|
||||||
// error
|
// error
|
||||||
LogError ("Error when performing collision check: %s\n", __FUNCTION__);
|
LogError ("Error when performing collision check: %s\n", __FUNCTION__);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coll2d_result == 0) {
|
if (coll2d_result > 0) {
|
||||||
// no contact, so delete it:
|
// no contact, so delete it:
|
||||||
LogDebug ("Lost Contact with entity %d!", current_iter->first);
|
LogDebug ("Lost Contact with entity %d!", current_iter->first);
|
||||||
ContactCacheRemove (entity->mId, current_iter->first);
|
ContactCacheRemove (entity->mId, current_iter->first);
|
||||||
|
|
||||||
entity->SetVelocity (old_velocity);
|
entity->SetVelocity (old_velocity);
|
||||||
continue;
|
continue;
|
||||||
} else if ( coll2d_result > 0){
|
} else if ( coll2d_result < 0){
|
||||||
// contact
|
// contact
|
||||||
if (info.time != 0. || normal != info.normal) {
|
if (info.time != 0. || normal != info.normal) {
|
||||||
LogError ("Something strange happened when checking for contacts in %s\n", __FUNCTION__);
|
LogError ("Something strange happened when checking for contacts in %s", __FUNCTION__);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,7 +557,6 @@ EntityPhysicState* CreateEntityPhysicState (EntityBaseType type, unsigned int id
|
||||||
EntityPhysicState* entity_physics = new EntityPhysicState ();
|
EntityPhysicState* entity_physics = new EntityPhysicState ();
|
||||||
if (!entity_physics) {
|
if (!entity_physics) {
|
||||||
LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
LogError ("Could not allocate enough memory for EntityPhysicState of type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
// default values for all Entities
|
// default values for all Entities
|
||||||
entity_physics->mId = id;
|
entity_physics->mId = id;
|
||||||
|
@ -593,7 +582,6 @@ EntityPhysicState* CreateEntityPhysicState (EntityBaseType type, unsigned int id
|
||||||
assert (entity_physics->mShape);
|
assert (entity_physics->mShape);
|
||||||
} else {
|
} else {
|
||||||
LogError ("No EntityPhysicState defined for Entity type '%d'", type);
|
LogError ("No EntityPhysicState defined for Entity type '%d'", type);
|
||||||
assert (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity_physics;
|
return entity_physics;
|
||||||
|
|
|
@ -60,7 +60,7 @@ int ViewBase::OnInit (int argc, char* argv[]) {
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleConsoleOverlay* console_overlay = new SimpleConsoleOverlay;
|
OverlayBasePtr console_overlay(new SimpleConsoleOverlay);
|
||||||
AddOverlay (console_overlay);
|
AddOverlay (console_overlay);
|
||||||
|
|
||||||
mConsoleFont->setForegroundColor (1., 1., 1.);
|
mConsoleFont->setForegroundColor (1., 1., 1.);
|
||||||
|
@ -81,13 +81,8 @@ void ViewBase::OnDestroy () {
|
||||||
delete mConsoleFont;
|
delete mConsoleFont;
|
||||||
mConsoleFont = NULL;
|
mConsoleFont = NULL;
|
||||||
|
|
||||||
std::vector<OverlayBase*>::iterator overlay_iter = mOverlays.begin(), overlay_temp;
|
while (mOverlays.size() > 0)
|
||||||
while (overlay_iter != mOverlays.end()) {
|
mOverlays.pop_back();
|
||||||
overlay_temp = overlay_iter;
|
|
||||||
delete *overlay_temp;
|
|
||||||
|
|
||||||
overlay_iter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewInstance = NULL;
|
ViewInstance = NULL;
|
||||||
|
|
||||||
|
@ -185,7 +180,7 @@ void ViewBase::Draw () {
|
||||||
|
|
||||||
DrawWorld ();
|
DrawWorld ();
|
||||||
|
|
||||||
std::vector<OverlayBase*>::iterator overlay_iter;
|
std::vector<OverlayBasePtr>::iterator overlay_iter;
|
||||||
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
||||||
(*overlay_iter)->Draw();
|
(*overlay_iter)->Draw();
|
||||||
}
|
}
|
||||||
|
@ -265,7 +260,7 @@ void ViewBase::Resize (int width, int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViewBase::SendKeyDown (const SDL_keysym &keysym) {
|
bool ViewBase::SendKeyDown (const SDL_keysym &keysym) {
|
||||||
std::vector<OverlayBase*>::iterator overlay_iter;
|
std::vector<OverlayBasePtr>::iterator overlay_iter;
|
||||||
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
||||||
if ( (*overlay_iter)->OnKeyDown (keysym))
|
if ( (*overlay_iter)->OnKeyDown (keysym))
|
||||||
return true;
|
return true;
|
||||||
|
@ -275,7 +270,7 @@ bool ViewBase::SendKeyDown (const SDL_keysym &keysym) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViewBase::SendKeyUp (const SDL_keysym &keysym) {
|
bool ViewBase::SendKeyUp (const SDL_keysym &keysym) {
|
||||||
std::vector<OverlayBase*>::iterator overlay_iter;
|
std::vector<OverlayBasePtr>::iterator overlay_iter;
|
||||||
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
||||||
if ( (*overlay_iter)->OnKeyUp (keysym))
|
if ( (*overlay_iter)->OnKeyUp (keysym))
|
||||||
return true;
|
return true;
|
||||||
|
@ -285,7 +280,7 @@ bool ViewBase::SendKeyUp (const SDL_keysym &keysym) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViewBase::SendMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos) {
|
bool ViewBase::SendMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos) {
|
||||||
std::vector<OverlayBase*>::iterator overlay_iter;
|
std::vector<OverlayBasePtr>::iterator overlay_iter;
|
||||||
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
||||||
if ( (*overlay_iter)->OnMouseButtonUp (button, xpos, ypos))
|
if ( (*overlay_iter)->OnMouseButtonUp (button, xpos, ypos))
|
||||||
return true;
|
return true;
|
||||||
|
@ -295,7 +290,7 @@ bool ViewBase::SendMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViewBase::SendMouseButtonDown (Uint8 button, Uint16 xpos, Uint16 ypos) {
|
bool ViewBase::SendMouseButtonDown (Uint8 button, Uint16 xpos, Uint16 ypos) {
|
||||||
std::vector<OverlayBase*>::iterator overlay_iter;
|
std::vector<OverlayBasePtr>::iterator overlay_iter;
|
||||||
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
for (overlay_iter = mOverlays.begin(); overlay_iter != mOverlays.end(); overlay_iter++) {
|
||||||
if ( (*overlay_iter)->OnMouseButtonDown (button, xpos, ypos))
|
if ( (*overlay_iter)->OnMouseButtonDown (button, xpos, ypos))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _VIEWBASE_H
|
#define _VIEWBASE_H
|
||||||
|
|
||||||
#include "Engine.h"
|
#include "Engine.h"
|
||||||
|
#include "OverlayBase.h"
|
||||||
|
|
||||||
// forward declarations for the OGLFT fonts
|
// forward declarations for the OGLFT fonts
|
||||||
namespace OGLFT {
|
namespace OGLFT {
|
||||||
|
@ -13,13 +14,14 @@ namespace Engine {
|
||||||
class Module;
|
class Module;
|
||||||
class ModelBase;
|
class ModelBase;
|
||||||
class CameraBase;
|
class CameraBase;
|
||||||
class OverlayBase;
|
|
||||||
|
|
||||||
/** \brief Performs the actual drawing based on Camera and Model
|
/** \brief Performs the actual drawing based on Camera and Model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ViewBase : public Module{
|
class ViewBase : public Module{
|
||||||
public:
|
public:
|
||||||
|
virtual ~ViewBase() {};
|
||||||
|
|
||||||
/** \brief Resizes the View */
|
/** \brief Resizes the View */
|
||||||
void Resize (int width, int height);
|
void Resize (int width, int height);
|
||||||
|
|
||||||
|
@ -45,7 +47,7 @@ class ViewBase : public Module{
|
||||||
bool GetDrawGrid () { return mDrawGrid; };
|
bool GetDrawGrid () { return mDrawGrid; };
|
||||||
void SetGridSize (int x, int z) { mGridSizeX = x; mGridSizeZ = z; }
|
void SetGridSize (int x, int z) { mGridSizeX = x; mGridSizeZ = z; }
|
||||||
|
|
||||||
void AddOverlay (OverlayBase *overlay) { mOverlays.push_back (overlay); };
|
void AddOverlay (OverlayBasePtr overlay) { mOverlays.push_back (overlay); };
|
||||||
|
|
||||||
/* Input forwarding for the overlays */
|
/* Input forwarding for the overlays */
|
||||||
bool SendKeyDown (const SDL_keysym &keysym);
|
bool SendKeyDown (const SDL_keysym &keysym);
|
||||||
|
@ -55,9 +57,9 @@ class ViewBase : public Module{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \brief Initializes the system */
|
/** \brief Initializes the system */
|
||||||
int OnInit (int argc, char* argv[]);
|
virtual int OnInit (int argc, char* argv[]);
|
||||||
/** \brief Destroys the system (must be called!) */
|
/** \brief Destroys the system (must be called!) */
|
||||||
void OnDestroy ();
|
virtual void OnDestroy ();
|
||||||
|
|
||||||
/** \brief Updates the camera for further drawing */
|
/** \brief Updates the camera for further drawing */
|
||||||
virtual void UpdateCamera ();
|
virtual void UpdateCamera ();
|
||||||
|
@ -71,7 +73,7 @@ class ViewBase : public Module{
|
||||||
ModelBase *mModel;
|
ModelBase *mModel;
|
||||||
CameraBase *mCamera;
|
CameraBase *mCamera;
|
||||||
|
|
||||||
std::vector<OverlayBase*> mOverlays;
|
std::vector<OverlayBasePtr> mOverlays;
|
||||||
|
|
||||||
/** \brief The height of the canvas we're drawing on */
|
/** \brief The height of the canvas we're drawing on */
|
||||||
unsigned int mWindowHeight;
|
unsigned int mWindowHeight;
|
||||||
|
|
Loading…
Reference in New Issue