mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 21:45:32 +00:00
Add support for placing BodyParts in a cell (Bug #3118)
This commit is contained in:
parent
994ad3e004
commit
0720a19fc0
8 changed files with 106 additions and 2 deletions
|
@ -75,7 +75,7 @@ add_openmw_dir (mwphysics
|
|||
|
||||
add_openmw_dir (mwclass
|
||||
classes activator creature npc weapon armor potion apparatus book clothing container door
|
||||
ingredient creaturelevlist itemlevlist light lockpick misc probe repair static actor
|
||||
ingredient creaturelevlist itemlevlist light lockpick misc probe repair static actor bodypart
|
||||
)
|
||||
|
||||
add_openmw_dir (mwmechanics
|
||||
|
|
52
apps/openmw/mwclass/bodypart.cpp
Normal file
52
apps/openmw/mwclass/bodypart.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include "bodypart.hpp"
|
||||
|
||||
#include "../mwrender/renderinginterface.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
||||
MWWorld::Ptr BodyPart::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::BodyPart> *ref = ptr.get<ESM::BodyPart>();
|
||||
|
||||
return MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
}
|
||||
|
||||
void BodyPart::insertObjectRendering(const MWWorld::Ptr &ptr, const std::string &model, MWRender::RenderingInterface &renderingInterface) const
|
||||
{
|
||||
if (!model.empty()) {
|
||||
renderingInterface.getObjects().insertModel(ptr, model);
|
||||
}
|
||||
}
|
||||
|
||||
void BodyPart::insertObject(const MWWorld::Ptr &ptr, const std::string &model, MWPhysics::PhysicsSystem &physics) const
|
||||
{
|
||||
}
|
||||
|
||||
std::string BodyPart::getName(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void BodyPart::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<MWWorld::Class> instance (new BodyPart);
|
||||
|
||||
registerClass (typeid (ESM::BodyPart).name(), instance);
|
||||
}
|
||||
|
||||
std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::BodyPart> *ref = ptr.get<ESM::BodyPart>();
|
||||
|
||||
const std::string &model = ref->mBase->mModel;
|
||||
if (!model.empty()) {
|
||||
return "meshes\\" + model;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
31
apps/openmw/mwclass/bodypart.hpp
Normal file
31
apps/openmw/mwclass/bodypart.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef GAME_MWCLASS_BODYPART_H
|
||||
#define GAME_MWCLASS_BODYPART_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
||||
class BodyPart : public MWWorld::Class
|
||||
{
|
||||
virtual MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const;
|
||||
|
||||
public:
|
||||
|
||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const;
|
||||
|
||||
virtual std::string getName (const MWWorld::ConstPtr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -20,6 +20,7 @@
|
|||
#include "probe.hpp"
|
||||
#include "repair.hpp"
|
||||
#include "static.hpp"
|
||||
#include "bodypart.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
|
@ -45,5 +46,6 @@ namespace MWClass
|
|||
Probe::registerSelf();
|
||||
Repair::registerSelf();
|
||||
Static::registerSelf();
|
||||
BodyPart::registerSelf();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -591,6 +591,7 @@ namespace MWWorld
|
|||
case ESM::REC_REPA: mRepairs.load(ref, deleted, store); break;
|
||||
case ESM::REC_STAT: mStatics.load(ref, deleted, store); break;
|
||||
case ESM::REC_WEAP: mWeapons.load(ref, deleted, store); break;
|
||||
case ESM::REC_BODY: mBodyParts.load(ref, deleted, store); break;
|
||||
|
||||
case 0: std::cerr << "Cell reference " + ref.mRefID + " not found!\n"; break;
|
||||
|
||||
|
@ -659,6 +660,7 @@ namespace MWWorld
|
|||
writeReferenceCollection<ESM::ObjectState> (writer, mRepairs);
|
||||
writeReferenceCollection<ESM::ObjectState> (writer, mStatics);
|
||||
writeReferenceCollection<ESM::ObjectState> (writer, mWeapons);
|
||||
writeReferenceCollection<ESM::ObjectState> (writer, mBodyParts);
|
||||
|
||||
for (MovedRefTracker::const_iterator it = mMovedToAnotherCell.begin(); it != mMovedToAnotherCell.end(); ++it)
|
||||
{
|
||||
|
@ -794,6 +796,11 @@ namespace MWWorld
|
|||
readReferenceCollection<ESM::ObjectState> (reader, mWeapons, cref, contentFileMap);
|
||||
break;
|
||||
|
||||
case ESM::REC_BODY:
|
||||
|
||||
readReferenceCollection<ESM::ObjectState> (reader, mBodyParts, cref, contentFileMap);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw std::runtime_error ("unknown type in cell reference section");
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <components/esm/loadweap.hpp>
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
#include <components/esm/loadmisc.hpp>
|
||||
#include <components/esm/loadbody.hpp>
|
||||
|
||||
#include "../mwmechanics/pathgrid.hpp" // TODO: maybe belongs in mwworld
|
||||
|
||||
|
@ -97,6 +98,7 @@ namespace MWWorld
|
|||
CellRefList<ESM::Repair> mRepairs;
|
||||
CellRefList<ESM::Static> mStatics;
|
||||
CellRefList<ESM::Weapon> mWeapons;
|
||||
CellRefList<ESM::BodyPart> mBodyParts;
|
||||
|
||||
typedef std::map<LiveCellRefBase*, MWWorld::CellStore*> MovedRefTracker;
|
||||
// References owned by a different cell that have been moved here.
|
||||
|
@ -152,6 +154,7 @@ namespace MWWorld
|
|||
forEachImp (visitor, mRepairs) &&
|
||||
forEachImp (visitor, mStatics) &&
|
||||
forEachImp (visitor, mWeapons) &&
|
||||
forEachImp (visitor, mBodyParts) &&
|
||||
forEachImp (visitor, mCreatures) &&
|
||||
forEachImp (visitor, mNpcs) &&
|
||||
forEachImp (visitor, mCreatureLists);
|
||||
|
@ -518,6 +521,13 @@ namespace MWWorld
|
|||
return mWeapons;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline CellRefList<ESM::BodyPart>& CellStore::get<ESM::BodyPart>()
|
||||
{
|
||||
mHasState = true;
|
||||
return mBodyParts;
|
||||
}
|
||||
|
||||
bool operator== (const CellStore& left, const CellStore& right);
|
||||
bool operator!= (const CellStore& left, const CellStore& right);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ static bool isCacheableRecord(int id)
|
|||
id == ESM::REC_BOOK || id == ESM::REC_CLOT || id == ESM::REC_CONT || id == ESM::REC_CREA ||
|
||||
id == ESM::REC_DOOR || id == ESM::REC_INGR || id == ESM::REC_LEVC || id == ESM::REC_LEVI ||
|
||||
id == ESM::REC_LIGH || id == ESM::REC_LOCK || id == ESM::REC_MISC || id == ESM::REC_NPC_ ||
|
||||
id == ESM::REC_PROB || id == ESM::REC_REPA || id == ESM::REC_STAT || id == ESM::REC_WEAP)
|
||||
id == ESM::REC_PROB || id == ESM::REC_REPA || id == ESM::REC_STAT || id == ESM::REC_WEAP ||
|
||||
id == ESM::REC_BODY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const std::string&
|
|||
case ESM::REC_REPA: create(store.get<ESM::Repair>(), lowerName, mRef, mPtr); break;
|
||||
case ESM::REC_STAT: create(store.get<ESM::Static>(), lowerName, mRef, mPtr); break;
|
||||
case ESM::REC_WEAP: create(store.get<ESM::Weapon>(), lowerName, mRef, mPtr); break;
|
||||
case ESM::REC_BODY: create(store.get<ESM::BodyPart>(), lowerName, mRef, mPtr); break;
|
||||
|
||||
case 0:
|
||||
throw std::logic_error("failed to create manual cell ref for " + lowerName + " (unknown ID)");
|
||||
|
|
Loading…
Reference in a new issue