# HG changeset patch
# User vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
# Date 1265956490 0
# Node ID 9d94f4676d179a45bfc5587ed00ed2596e7a5c9b
# Parent 293e812316c0840dbb5fa9a80b8421a82ea802bf
Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
diff -r 293e812316c0 -r 9d94f4676d17 demos/rio_de_hola/maps/shrine.xml
--- a/demos/rio_de_hola/maps/shrine.xml Thu Feb 11 04:18:42 2010 +0000
+++ b/demos/rio_de_hola/maps/shrine.xml Fri Feb 12 06:34:50 2010 +0000
@@ -6110,8 +6110,8 @@
-
+
-
+
diff -r 293e812316c0 -r 9d94f4676d17 demos/rio_de_hola/maps/tourist_beach.xml
--- a/demos/rio_de_hola/maps/tourist_beach.xml Thu Feb 11 04:18:42 2010 +0000
+++ b/demos/rio_de_hola/maps/tourist_beach.xml Fri Feb 12 06:34:50 2010 +0000
@@ -4792,8 +4792,8 @@
-
+
-
+
diff -r 293e812316c0 -r 9d94f4676d17 demos/rio_de_hola/scripts/world.py
--- a/demos/rio_de_hola/scripts/world.py Thu Feb 11 04:18:42 2010 +0000
+++ b/demos/rio_de_hola/scripts/world.py Fri Feb 12 06:34:50 2010 +0000
@@ -75,7 +75,6 @@
self.engine = engine
self.eventmanager = engine.getEventManager()
self.model = engine.getModel()
- self.view = self.engine.getView()
self.filename = ''
self.pump_ctr = 0 # for testing purposis
self.ctrldown = False
@@ -199,13 +198,13 @@
camera_prefix = camera_prefix.rpartition('/')[2] # Remove path
camera_prefix += '_'
- for cam in self.view.getCameras():
+ for cam in self.map.getCameras():
camera_id = cam.getId().replace(camera_prefix, '')
self.cameras[camera_id] = cam
+ cam.resetRenderers()
self.cameras['main'].attach(self.hero.agent)
- self.view.resetRenderers()
# Floating text renderers currntly only support one font.
# ... so we set that up.
# You'll se that for our demo we use a image font, so we have to specify the font glyphs
@@ -274,7 +273,6 @@
c.setEnabled(not c.isEnabled())
elif keystr == 'r':
self.model.deleteMaps()
- self.view.clearCameras()
self.load(self.filename)
elif keystr == 'o':
self.target_rotation = (self.target_rotation + 90) % 360
diff -r 293e812316c0 -r 9d94f4676d17 engine/core/controller/engine.cpp
--- a/engine/core/controller/engine.cpp Thu Feb 11 04:18:42 2010 +0000
+++ b/engine/core/controller/engine.cpp Fri Feb 12 06:34:50 2010 +0000
@@ -63,7 +63,6 @@
#include "pathfinder/routepather/routepather.h"
#include "model/metamodel/grids/hexgrid.h"
#include "model/metamodel/grids/squaregrid.h"
-#include "view/view.h"
#include "view/renderers/camerazonerenderer.h"
#include "view/renderers/quadtreerenderer.h"
#include "view/renderers/gridrenderer.h"
@@ -101,7 +100,6 @@
m_vfs(0),
m_model(0),
m_gui_graphics(0),
- m_view(0),
m_logmanager(0),
m_cursor(0),
m_settings() {
@@ -231,27 +229,25 @@
m_soundmanager = new SoundManager(m_soundclippool);
m_soundmanager->setVolume(static_cast(m_settings.getInitialVolume()) / 10);
+ FL_LOG(_log, "Creating renderers");
+ m_renderers.push_back(new CameraZoneRenderer(m_renderbackend, 0, m_imagepool));
+ m_renderers.push_back(new InstanceRenderer(m_renderbackend, 10, m_imagepool, m_animpool));
+ m_renderers.push_back(new GridRenderer(m_renderbackend, 20));
+ m_renderers.push_back(new CellSelectionRenderer(m_renderbackend, 30));
+ m_renderers.push_back(new BlockingInfoRenderer(m_renderbackend, 40));
+ m_renderers.push_back(new FloatingTextRenderer(m_renderbackend, 50, dynamic_cast(m_defaultfont)));
+ m_renderers.push_back(new QuadTreeRenderer(m_renderbackend, 60));
+ m_renderers.push_back(new CoordinateRenderer(m_renderbackend, 70, dynamic_cast(m_defaultfont)));
+ m_renderers.push_back(new GenericRenderer(m_renderbackend, 80, m_imagepool, m_animpool));
+
FL_LOG(_log, "Creating model");
- m_model = new Model();
+ m_model = new Model(m_renderbackend, m_renderers, m_imagepool, m_animpool);
FL_LOG(_log, "Adding pathers to model");
-// m_model->adoptPather(new LinearPather());
m_model->adoptPather(new RoutePather());
FL_LOG(_log, "Adding grid prototypes to model");
m_model->adoptCellGrid(new SquareGrid());
m_model->adoptCellGrid(new HexGrid());
- FL_LOG(_log, "Creating view");
- m_view = new View(m_renderbackend, m_imagepool, m_animpool);
- FL_LOG(_log, "Creating renderers to view");
- m_view->addRenderer(new CameraZoneRenderer(m_renderbackend, 0, m_imagepool));
- m_view->addRenderer(new InstanceRenderer(m_renderbackend, 10, m_imagepool, m_animpool));
- m_view->addRenderer(new GridRenderer(m_renderbackend, 20));
- m_view->addRenderer(new CellSelectionRenderer(m_renderbackend, 30));
- m_view->addRenderer(new BlockingInfoRenderer(m_renderbackend, 40));
- m_view->addRenderer(new FloatingTextRenderer(m_renderbackend, 50, dynamic_cast(m_defaultfont)));
- m_view->addRenderer(new QuadTreeRenderer(m_renderbackend, 60));
- m_view->addRenderer(new CoordinateRenderer(m_renderbackend, 70, dynamic_cast(m_defaultfont)));
- m_view->addRenderer(new GenericRenderer(m_renderbackend, 80, m_imagepool, m_animpool));
m_cursor = new Cursor(m_imagepool, m_animpool, m_renderbackend);
FL_LOG(_log, "Engine intialized");
}
@@ -265,7 +261,6 @@
void Engine::destroy() {
FL_LOG(_log, "Destructing engine");
delete m_cursor;
- delete m_view;
delete m_model;
delete m_soundmanager;
delete m_guimanager;
@@ -278,6 +273,14 @@
delete m_imagepool;
delete m_eventmanager;
+ // properly remove all the renderers created during init
+ std::vector::iterator rendererIter = m_renderers.begin();
+ for ( ; rendererIter != m_renderers.end(); ++rendererIter)
+ {
+ delete *rendererIter;
+ }
+ m_renderers.clear();
+
m_renderbackend->deinit();
delete m_renderbackend;
@@ -303,7 +306,6 @@
m_renderbackend->startFrame();
m_timemanager->update();
m_model->update();
- m_view->update();
m_guimanager->turn();
m_cursor->draw();
m_renderbackend->endFrame();
diff -r 293e812316c0 -r 9d94f4676d17 engine/core/controller/engine.h
--- a/engine/core/controller/engine.h Thu Feb 11 04:18:42 2010 +0000
+++ b/engine/core/controller/engine.h Fri Feb 12 06:34:50 2010 +0000
@@ -56,12 +56,12 @@
class TimeManager;
class ImagePool;
class AnimationPool;
- class View;
class Model;
class LogManager;
class GuiFont;
class Cursor;
class SoundClipPool;
+ class RendererBase;
/** Engine acts as a controller to the whole system
@@ -143,10 +143,6 @@
*/
Model* getModel() const { return m_model; }
- /** Provides access point to the View
- */
- View* getView() const { return m_view; }
-
/** Provides access point to the LogManager
*/
LogManager* getLogManager() const { return m_logmanager; }
@@ -177,7 +173,6 @@
VFS* m_vfs;
Model* m_model;
gcn::Graphics* m_gui_graphics;
- View* m_view;
LogManager* m_logmanager;
GuiFont* m_defaultfont;
Cursor* m_cursor;
@@ -185,6 +180,8 @@
EngineSettings m_settings;
+ std::vector m_renderers;
+
#ifdef USE_COCOA
objc_object *m_autoreleasePool;
#endif
diff -r 293e812316c0 -r 9d94f4676d17 engine/core/controller/engine.i
--- a/engine/core/controller/engine.i Thu Feb 11 04:18:42 2010 +0000
+++ b/engine/core/controller/engine.i Fri Feb 12 06:34:50 2010 +0000
@@ -33,12 +33,12 @@
class AnimationPool;
class SoundClipPool;
class RenderBackend;
- class View;
class Model;
class LogManager;
class GuiFont;
class VFS;
class Cursor;
+ class RendererBase;
class EngineSettings {
public:
@@ -99,7 +99,6 @@
AnimationPool* getAnimationPool();
SoundClipPool* getSoundClipPool();
RenderBackend* getRenderBackend();
- View* getView();
Model* getModel();
LogManager* getLogManager();
GuiFont* getDefaultFont();
diff -r 293e812316c0 -r 9d94f4676d17 engine/core/model/model.cpp
--- a/engine/core/model/model.cpp Thu Feb 11 04:18:42 2010 +0000
+++ b/engine/core/model/model.cpp Fri Feb 12 06:34:50 2010 +0000
@@ -35,16 +35,26 @@
#include "structures/layer.h"
#include "structures/instance.h"
#include "util/base/exception.h"
+#include "view/rendererbase.h"
+#include "video/renderbackend.h"
+#include "video/imagepool.h"
+#include "video/animationpool.h"
#include "model.h"
namespace FIFE {
- Model::Model():
+ Model::Model(RenderBackend* renderbackend, const std::vector& renderers,
+ ImagePool* imagepool, AnimationPool* animpool):
FifeClass(),
m_last_namespace(NULL),
+ m_renderbackend(renderbackend),
+ m_renderers(renderers),
+ m_imagepool(imagepool),
+ m_animpool(animpool),
m_timeprovider(NULL) {
- }
+
+ }
Model::~Model() {
purge(m_maps);
@@ -58,11 +68,12 @@
Map* Model::createMap(const std::string& identifier) {
std::list