forked from teamnwah/openmw-tes3coop
Add support for placing BodyParts in a cell (Bug #3118)
parent
a9f0f30bb8
commit
1905f0bf2d
@ -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 "";
|
||||
}
|
||||
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue