mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 17:09:40 +00:00
Added const reference to esmstore to some methods down to CellRenderImp.
Body part mesh names will be now obtained by the bodypart id.
This commit is contained in:
parent
fb3bf91dfb
commit
389a28a836
5 changed files with 47 additions and 37 deletions
|
@ -5,7 +5,7 @@
|
||||||
using namespace MWRender;
|
using namespace MWRender;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void insertObj(CellRenderImp& cellRender, T& liveRef)
|
void insertObj(CellRenderImp& cellRender, T& liveRef, const ESMS::ESMStore& store)
|
||||||
{
|
{
|
||||||
assert (liveRef.base != NULL);
|
assert (liveRef.base != NULL);
|
||||||
const std::string &model = liveRef.base->model;
|
const std::string &model = liveRef.base->model;
|
||||||
|
@ -18,7 +18,7 @@ void insertObj(CellRenderImp& cellRender, T& liveRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>& liveRef)
|
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>& liveRef, const ESMS::ESMStore& store)
|
||||||
{
|
{
|
||||||
assert (liveRef.base != NULL);
|
assert (liveRef.base != NULL);
|
||||||
const std::string &model = liveRef.base->model;
|
const std::string &model = liveRef.base->model;
|
||||||
|
@ -41,52 +41,56 @@ void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::Light, MWWorld:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>& liveRef )
|
void insertObj(CellRenderImp& cellRender, ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>& liveRef, const ESMS::ESMStore& store)
|
||||||
{
|
{
|
||||||
std::string skinName = "meshes\\b\\B_N_" //some constants (seems so)
|
std::string headID = liveRef.base->head;
|
||||||
+ liveRef.base->race
|
|
||||||
+ "_"
|
//get the part of the bodypart id which describes the race and the gender
|
||||||
+ ((liveRef.base->flags & ESM::NPC::Female ) ? "F" : "M");
|
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
||||||
|
std::string headModel = "meshes\\" + store.bodyParts.find(headID)->model;
|
||||||
|
|
||||||
cellRender.insertBegin(liveRef.ref);
|
cellRender.insertBegin(liveRef.ref);
|
||||||
cellRender.insertMesh(skinName + "_Skins.nif");
|
cellRender.insertMesh(headModel);
|
||||||
cellRender.insertMesh("meshes\\B\\" + liveRef.base->head + ".nif");
|
|
||||||
|
//TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the right place
|
||||||
|
cellRender.insertMesh("meshes\\" + store.bodyParts.find(bodyRaceID + "chest")->model);
|
||||||
|
|
||||||
liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled()));
|
liveRef.mData.setHandle (cellRender.insertEnd (liveRef.mData.isEnabled()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void insertCellRefList (CellRenderImp& cellRender, T& cellRefList)
|
void insertCellRefList (CellRenderImp& cellRender, const ESMS::ESMStore& store, T& cellRefList)
|
||||||
{
|
{
|
||||||
for(typename T::List::iterator it = cellRefList.list.begin();
|
for(typename T::List::iterator it = cellRefList.list.begin();
|
||||||
it != cellRefList.list.end(); it++)
|
it != cellRefList.list.end(); it++)
|
||||||
{
|
{
|
||||||
insertObj (cellRender, *it);
|
insertObj (cellRender, *it, store);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell)
|
void CellRenderImp::insertCell(ESMS::CellStore<MWWorld::RefData> &cell, const ESMS::ESMStore& store)
|
||||||
{
|
{
|
||||||
// Loop through all references in the cell
|
// Loop through all references in the cell
|
||||||
insertCellRefList (*this, cell.activators);
|
insertCellRefList (*this, store, cell.activators);
|
||||||
insertCellRefList (*this, cell.potions);
|
insertCellRefList (*this, store, cell.potions);
|
||||||
insertCellRefList (*this, cell.appas);
|
insertCellRefList (*this, store, cell.appas);
|
||||||
insertCellRefList (*this, cell.armors);
|
insertCellRefList (*this, store, cell.armors);
|
||||||
insertCellRefList (*this, cell.books);
|
insertCellRefList (*this, store, cell.books);
|
||||||
insertCellRefList (*this, cell.clothes);
|
insertCellRefList (*this, store, cell.clothes);
|
||||||
insertCellRefList (*this, cell.containers);
|
insertCellRefList (*this, store, cell.containers);
|
||||||
insertCellRefList (*this, cell.creatures);
|
insertCellRefList (*this, store, cell.creatures);
|
||||||
insertCellRefList (*this, cell.doors);
|
insertCellRefList (*this, store, cell.doors);
|
||||||
insertCellRefList (*this, cell.ingreds);
|
insertCellRefList (*this, store, cell.ingreds);
|
||||||
// insertCellRefList (*this, cell.creatureLists);
|
// insertCellRefList (*this, store, cell.creatureLists);
|
||||||
// insertCellRefList (*this, cell.itemLists);
|
// insertCellRefList (*this, store, cell.itemLists);
|
||||||
insertCellRefList (*this, cell.lights);
|
insertCellRefList (*this, store, cell.lights);
|
||||||
insertCellRefList (*this, cell.lockpicks);
|
insertCellRefList (*this, store, cell.lockpicks);
|
||||||
insertCellRefList (*this, cell.miscItems);
|
insertCellRefList (*this, store, cell.miscItems);
|
||||||
insertCellRefList (*this, cell.npcs);
|
insertCellRefList (*this, store, cell.npcs);
|
||||||
insertCellRefList (*this, cell.probes);
|
insertCellRefList (*this, store, cell.probes);
|
||||||
insertCellRefList (*this, cell.repairs);
|
insertCellRefList (*this, store, cell.repairs);
|
||||||
insertCellRefList (*this, cell.statics);
|
insertCellRefList (*this, store, cell.statics);
|
||||||
insertCellRefList (*this, cell.weapons);
|
insertCellRefList (*this, store, cell.weapons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@ namespace ESM
|
||||||
class CellRef;
|
class CellRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ESMS
|
||||||
|
{
|
||||||
|
class ESMStore;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
/// Base class for cell render, that implements inserting references into a cell in a
|
/// Base class for cell render, that implements inserting references into a cell in a
|
||||||
|
@ -35,7 +40,7 @@ namespace MWRender
|
||||||
/// finish inserting a new reference and return a handle to it.
|
/// finish inserting a new reference and return a handle to it.
|
||||||
virtual std::string insertEnd (bool Enable) = 0;
|
virtual std::string insertEnd (bool Enable) = 0;
|
||||||
|
|
||||||
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell);
|
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell, const ESMS::ESMStore& store);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ void InteriorCellRender::show()
|
||||||
configureAmbient();
|
configureAmbient();
|
||||||
configureFog();
|
configureFog();
|
||||||
|
|
||||||
insertCell(cell);
|
insertCell(cell, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteriorCellRender::hide()
|
void InteriorCellRender::hide()
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace MWRender
|
||||||
static bool lightOutQuadInLin;
|
static bool lightOutQuadInLin;
|
||||||
|
|
||||||
ESMS::CellStore<MWWorld::RefData> &cell;
|
ESMS::CellStore<MWWorld::RefData> &cell;
|
||||||
|
const ESMS::ESMStore &store;
|
||||||
MWScene &scene;
|
MWScene &scene;
|
||||||
|
|
||||||
/// The scene node that contains all objects belonging to this
|
/// The scene node that contains all objects belonging to this
|
||||||
|
@ -78,8 +79,8 @@ namespace MWRender
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWScene &_scene)
|
InteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, const ESMS::ESMStore& _store, MWScene &_scene)
|
||||||
: cell(_cell), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
|
: cell(_cell), store(_store), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
|
||||||
|
|
||||||
virtual ~InteriorCellRender() { destroy(); }
|
virtual ~InteriorCellRender() { destroy(); }
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ namespace MWWorld
|
||||||
// This connects the cell data with the rendering scene.
|
// This connects the cell data with the rendering scene.
|
||||||
std::pair<CellRenderCollection::iterator, bool> result =
|
std::pair<CellRenderCollection::iterator, bool> result =
|
||||||
mActiveCells.insert (std::make_pair (cell,
|
mActiveCells.insert (std::make_pair (cell,
|
||||||
new MWRender::InteriorCellRender (*cell, mScene)));
|
new MWRender::InteriorCellRender (*cell, mStore, mScene)));
|
||||||
|
|
||||||
if (result.second)
|
if (result.second)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue