diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d91f8b29..2484d6eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,11 +20,12 @@ source_group(game FILES ${GAME} ${GAME_HEADER}) set(GAMEREND apps/openmw/mwrender/mwscene.cpp - apps/openmw/mwrender/cell.cpp + apps/openmw/mwrender/cellimp.cpp apps/openmw/mwrender/interior.cpp apps/openmw/mwrender/sky.cpp) set(GAMEREND_HEADER apps/openmw/mwrender/cell.hpp + apps/openmw/mwrender/cellimp.hpp apps/openmw/mwrender/mwscene.hpp apps/openmw/mwrender/interior.hpp apps/openmw/mwrender/playerpos.hpp diff --git a/apps/openmw/mwrender/cell.hpp b/apps/openmw/mwrender/cell.hpp index 4ef4cc64c..756ec1cda 100644 --- a/apps/openmw/mwrender/cell.hpp +++ b/apps/openmw/mwrender/cell.hpp @@ -1,46 +1,22 @@ -#ifndef _GAME_RENDER_CELL_H -#define _GAME_RENDER_CELL_H +#ifndef GAME_RENDER_CELL_H +#define GAME_RENDER_CELL_H -#include - -namespace ESM +namespace MWRender { - class CellRef; -} - -namespace ESMS -{ - class CellStore; -} - -namespace MWRender -{ - /// Base class for cell render, that implements inserting references into a cell in a - /// cell type- and render-engine-independent way. - - class CellRender - { - public: - CellRender() {} - virtual ~CellRender() {} - - /// start inserting a new reference. - virtual void insertBegin (const ESM::CellRef &ref) = 0; - - /// insert a mesh related to the most recent insertBegin call. - virtual void insertMesh(const std::string &mesh) = 0; + class CellRender + { + public: - /// insert a light related to the most recent insertBegin call. - virtual void insertLight(float r, float g, float b, float radius) = 0; + virtual ~CellRender() {}; - /// finish inserting a new reference and return a handle to it. - virtual std::string insertEnd() = 0; - - void insertCell(const ESMS::CellStore &cell); - - /// placeholder function -> need to do some heavy refactoring on the whole cell stuff - virtual void show() = 0; - }; + /// Make the cell visible. Load the cell if necessary. + virtual void show() = 0; + + /// Remove the cell from rendering, but don't remove it from + /// memory. + virtual void hide() = 0; + }; } #endif + diff --git a/apps/openmw/mwrender/cell.cpp b/apps/openmw/mwrender/cellimp.cpp similarity index 87% rename from apps/openmw/mwrender/cell.cpp rename to apps/openmw/mwrender/cellimp.cpp index 912418459..10d647673 100644 --- a/apps/openmw/mwrender/cell.cpp +++ b/apps/openmw/mwrender/cellimp.cpp @@ -1,4 +1,4 @@ -#include "cell.hpp" +#include "cellimp.hpp" #include @@ -7,7 +7,7 @@ using namespace MWRender; template -void insertObj(CellRender& cellRender, const T& liveRef) +void insertObj(CellRenderImp& cellRender, const T& liveRef) { assert (liveRef.base != NULL); const std::string &model = liveRef.base->model; @@ -20,7 +20,7 @@ void insertObj(CellRender& cellRender, const T& liveRef) } template<> -void insertObj(CellRender& cellRender, const ESMS::LiveCellRef& liveRef) +void insertObj(CellRenderImp& cellRender, const ESMS::LiveCellRef& liveRef) { assert (liveRef.base != NULL); const std::string &model = liveRef.base->model; @@ -43,7 +43,7 @@ void insertObj(CellRender& cellRender, const ESMS::LiveCellRef& live } template -void insertCellRefList (CellRender& cellRender, const T& cellRefList) +void insertCellRefList (CellRenderImp& cellRender, const T& cellRefList) { for(typename T::List::const_iterator it = cellRefList.list.begin(); it != cellRefList.list.end(); it++) @@ -52,7 +52,7 @@ void insertCellRefList (CellRender& cellRender, const T& cellRefList) } } -void CellRender::insertCell(const ESMS::CellStore &cell) +void CellRenderImp::insertCell(const ESMS::CellStore &cell) { // Loop through all references in the cell insertCellRefList (*this, cell.activators); diff --git a/apps/openmw/mwrender/cellimp.hpp b/apps/openmw/mwrender/cellimp.hpp new file mode 100644 index 000000000..da598bd82 --- /dev/null +++ b/apps/openmw/mwrender/cellimp.hpp @@ -0,0 +1,44 @@ +#ifndef _GAME_RENDER_CELLIMP_H +#define _GAME_RENDER_CELLIMP_H + +#include + +namespace ESM +{ + class CellRef; +} + +namespace ESMS +{ + class CellStore; +} + +namespace MWRender +{ + /// Base class for cell render, that implements inserting references into a cell in a + /// cell type- and render-engine-independent way. + + class CellRenderImp + { + public: + CellRenderImp() {} + virtual ~CellRenderImp() {} + + /// start inserting a new reference. + virtual void insertBegin (const ESM::CellRef &ref) = 0; + + /// insert a mesh related to the most recent insertBegin call. + virtual void insertMesh(const std::string &mesh) = 0; + + /// insert a light related to the most recent insertBegin call. + virtual void insertLight(float r, float g, float b, float radius) = 0; + + /// finish inserting a new reference and return a handle to it. + virtual std::string insertEnd() = 0; + + void insertCell(const ESMS::CellStore &cell); + + }; +} + +#endif diff --git a/apps/openmw/mwrender/interior.hpp b/apps/openmw/mwrender/interior.hpp index af527f324..f4876752a 100644 --- a/apps/openmw/mwrender/interior.hpp +++ b/apps/openmw/mwrender/interior.hpp @@ -2,6 +2,7 @@ #define _GAME_RENDER_INTERIOR_H #include "cell.hpp" +#include "cellimp.hpp" #include "components/esm_store/cell_store.hpp" #include "OgreColourValue.h" @@ -23,7 +24,7 @@ namespace MWRender TODO FIXME: Doesn't do full cleanup yet. */ - class InteriorCellRender : public CellRender + class InteriorCellRender : public CellRender, private CellRenderImp { static bool lightConst; @@ -90,7 +91,7 @@ namespace MWRender void hide(); /// Destroy all rendering objects connected with this cell. - void destroy(); + void destroy(); // comment by Zini: shouldn't this go into the destructor? /// Switch through lighting modes. void toggleLight();