mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 20:15:33 +00:00
integrated insertObject function into class hierarchy
This commit is contained in:
parent
1d91ac9d9e
commit
de2eeb4cde
7 changed files with 71 additions and 45 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include <cassert>
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
using namespace MWRender;
|
||||
|
||||
template<typename T>
|
||||
|
@ -59,37 +62,45 @@ void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::NPC, MWWorld::R
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void insertCellRefList (CellRenderImp& cellRender, const ESMS::ESMStore& store, T& cellRefList)
|
||||
void insertCellRefList (CellRenderImp& cellRender, MWWorld::Environment& environment,
|
||||
T& cellRefList, ESMS::CellStore<MWWorld::RefData> &cell)
|
||||
{
|
||||
for(typename T::List::iterator it = cellRefList.list.begin();
|
||||
it != cellRefList.list.end(); it++)
|
||||
if (!cellRefList.list.empty())
|
||||
{
|
||||
if (it->mData.getCount())
|
||||
insertObj (cellRender, *it, store);
|
||||
const MWWorld::Class& class_ =
|
||||
MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell));
|
||||
|
||||
for (typename T::List::iterator it = cellRefList.list.begin();
|
||||
it != cellRefList.list.end(); it++)
|
||||
{
|
||||
if (it->mData.getCount())
|
||||
class_.insertObj (MWWorld::Ptr (&*it, &cell), cellRender, environment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell, const ESMS::ESMStore& store)
|
||||
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell,
|
||||
MWWorld::Environment& environment)
|
||||
{
|
||||
// Loop through all references in the cell
|
||||
insertCellRefList (*this, store, cell.activators);
|
||||
insertCellRefList (*this, store, cell.potions);
|
||||
insertCellRefList (*this, store, cell.appas);
|
||||
insertCellRefList (*this, store, cell.armors);
|
||||
insertCellRefList (*this, store, cell.books);
|
||||
insertCellRefList (*this, store, cell.clothes);
|
||||
insertCellRefList (*this, store, cell.containers);
|
||||
insertCellRefList (*this, store, cell.creatures);
|
||||
insertCellRefList (*this, store, cell.doors);
|
||||
insertCellRefList (*this, store, cell.ingreds);
|
||||
// insertCellRefList (*this, store, cell.creatureLists);
|
||||
// insertCellRefList (*this, store, cell.itemLists);
|
||||
insertCellRefList (*this, store, cell.lights);
|
||||
insertCellRefList (*this, store, cell.lockpicks);
|
||||
insertCellRefList (*this, store, cell.miscItems);
|
||||
insertCellRefList (*this, store, cell.npcs);
|
||||
insertCellRefList (*this, store, cell.probes);
|
||||
insertCellRefList (*this, store, cell.repairs);
|
||||
insertCellRefList (*this, store, cell.statics);
|
||||
insertCellRefList (*this, store, cell.weapons);
|
||||
insertCellRefList (*this, environment, cell.activators, cell);
|
||||
insertCellRefList (*this, environment, cell.potions, cell);
|
||||
insertCellRefList (*this, environment, cell.appas, cell);
|
||||
insertCellRefList (*this, environment, cell.armors, cell);
|
||||
insertCellRefList (*this, environment, cell.books, cell);
|
||||
insertCellRefList (*this, environment, cell.clothes, cell);
|
||||
insertCellRefList (*this, environment, cell.containers, cell);
|
||||
insertCellRefList (*this, environment, cell.creatures, cell);
|
||||
insertCellRefList (*this, environment, cell.doors, cell);
|
||||
insertCellRefList (*this, environment, cell.ingreds, cell);
|
||||
// insertCellRefList (*this, environment, cell.creatureLists, cell);
|
||||
// insertCellRefList (*this, environment, cell.itemLists, cell);
|
||||
insertCellRefList (*this, environment, cell.lights, cell);
|
||||
insertCellRefList (*this, environment, cell.lockpicks, cell);
|
||||
insertCellRefList (*this, environment, cell.miscItems, cell);
|
||||
insertCellRefList (*this, environment, cell.npcs, cell);
|
||||
insertCellRefList (*this, environment, cell.probes, cell);
|
||||
insertCellRefList (*this, environment, cell.repairs, cell);
|
||||
insertCellRefList (*this, environment, cell.statics, cell);
|
||||
insertCellRefList (*this, environment, cell.weapons, cell);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace ESM
|
|||
class CellRef;
|
||||
}
|
||||
|
||||
namespace ESMS
|
||||
namespace MWWorld
|
||||
{
|
||||
class ESMStore;
|
||||
class Environment;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
|
@ -33,14 +33,14 @@ namespace MWRender
|
|||
|
||||
/// 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 (bool Enable) = 0;
|
||||
|
||||
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, const ESMS::ESMStore& store);
|
||||
|
||||
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, MWWorld::Environment& environment);
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -174,19 +174,12 @@ void InteriorCellRender::setAmbientMode()
|
|||
|
||||
void InteriorCellRender::show()
|
||||
{
|
||||
// If already loaded, just make the cell visible.
|
||||
if(base)
|
||||
{
|
||||
base->setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
base = scene.getRoot()->createChildSceneNode();
|
||||
|
||||
configureAmbient();
|
||||
configureFog();
|
||||
|
||||
insertCell(cell, store);
|
||||
insertCell(cell, mEnvironment);
|
||||
}
|
||||
|
||||
void InteriorCellRender::hide()
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "cell.hpp"
|
||||
#include "cellimp.hpp"
|
||||
#include "components/esm_store/cell_store.hpp"
|
||||
|
||||
#include "OgreColourValue.h"
|
||||
|
||||
|
@ -12,6 +11,11 @@ namespace Ogre
|
|||
class SceneNode;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class MWScene;
|
||||
|
@ -43,7 +47,7 @@ namespace MWRender
|
|||
static bool lightOutQuadInLin;
|
||||
|
||||
ESMS::CellStore<MWWorld::RefData> &cell;
|
||||
const ESMS::ESMStore &store;
|
||||
MWWorld::Environment &mEnvironment;
|
||||
MWScene &scene;
|
||||
|
||||
/// The scene node that contains all objects belonging to this
|
||||
|
@ -79,8 +83,9 @@ namespace MWRender
|
|||
|
||||
public:
|
||||
|
||||
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, const ESMS::ESMStore& _store, MWScene &_scene)
|
||||
: cell(_cell), store(_store), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
|
||||
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
|
||||
MWScene &_scene)
|
||||
: cell(_cell), mEnvironment (environment), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
|
||||
|
||||
virtual ~InteriorCellRender() { destroy(); }
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@ namespace MWWorld
|
|||
|
||||
Class::~Class() {}
|
||||
|
||||
void Class::insertObj (const Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have creature stats");
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
#include "containerstore.hpp"
|
||||
#include "refdata.hpp"
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class CellRenderImp;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
struct CreatureStats;
|
||||
|
@ -18,6 +23,7 @@ namespace MWMechanics
|
|||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
class Environment;
|
||||
|
||||
/// \brief Base class for referenceable esm records
|
||||
class Class
|
||||
|
@ -36,6 +42,10 @@ namespace MWWorld
|
|||
|
||||
virtual ~Class();
|
||||
|
||||
virtual void insertObj (const Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
MWWorld::Environment& environment) const;
|
||||
///< Add reference into a cell for rendering (default implementation: don't render anything).
|
||||
|
||||
virtual std::string getName (const Ptr& ptr) const = 0;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -537,6 +537,7 @@ namespace MWWorld
|
|||
active->second->destroy();
|
||||
delete active->second;
|
||||
mActiveCells.erase (active);
|
||||
// TODO remove sounds
|
||||
}
|
||||
|
||||
// register local scripts
|
||||
|
@ -551,7 +552,7 @@ namespace MWWorld
|
|||
// This connects the cell data with the rendering scene.
|
||||
std::pair<CellRenderCollection::iterator, bool> result =
|
||||
mActiveCells.insert (std::make_pair (cell,
|
||||
new MWRender::InteriorCellRender (*cell, mStore, mScene)));
|
||||
new MWRender::InteriorCellRender (*cell, mEnvironment, mScene)));
|
||||
|
||||
if (result.second)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue