1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-12 09:39:58 +00:00

split CellRender into CellRender and CellRenderImp

This commit is contained in:
Marc Zinnschlag 2010-07-02 09:24:16 +02:00
parent ce37666dbc
commit ea6d342a24
5 changed files with 69 additions and 47 deletions

View File

@ -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

View File

@ -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 <string>
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

View File

@ -1,4 +1,4 @@
#include "cell.hpp"
#include "cellimp.hpp"
#include <cassert>
@ -7,7 +7,7 @@
using namespace MWRender;
template<typename T>
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<ESM::Light>& liveRef)
void insertObj(CellRenderImp& cellRender, const ESMS::LiveCellRef<ESM::Light>& liveRef)
{
assert (liveRef.base != NULL);
const std::string &model = liveRef.base->model;
@ -43,7 +43,7 @@ void insertObj(CellRender& cellRender, const ESMS::LiveCellRef<ESM::Light>& live
}
template<typename T>
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);

View File

@ -0,0 +1,44 @@
#ifndef _GAME_RENDER_CELLIMP_H
#define _GAME_RENDER_CELLIMP_H
#include <string>
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

View File

@ -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();