2010-08-03 13:24:44 +00:00
|
|
|
|
|
|
|
#include "static.hpp"
|
|
|
|
|
|
|
|
#include <components/esm/loadstat.hpp>
|
|
|
|
|
2010-08-14 08:02:54 +00:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2012-07-03 11:15:20 +00:00
|
|
|
#include "../mwworld/physicssystem.hpp"
|
2010-08-14 08:02:54 +00:00
|
|
|
|
2012-01-27 14:11:02 +00:00
|
|
|
#include "../mwrender/objects.hpp"
|
2012-07-03 11:15:20 +00:00
|
|
|
#include "../mwrender/renderinginterface.hpp"
|
2010-08-14 08:02:54 +00:00
|
|
|
|
2010-08-03 13:24:44 +00:00
|
|
|
namespace MWClass
|
|
|
|
{
|
2011-11-12 04:01:12 +00:00
|
|
|
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
2010-08-14 08:02:54 +00:00
|
|
|
{
|
2012-07-24 16:22:11 +00:00
|
|
|
const std::string model = getModel(ptr);
|
|
|
|
if (!model.empty()) {
|
2011-11-19 06:01:19 +00:00
|
|
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
2012-02-06 08:42:24 +00:00
|
|
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true);
|
2012-07-24 16:22:11 +00:00
|
|
|
objects.insertMesh(ptr, model);
|
2010-08-14 08:02:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
2012-07-24 16:22:11 +00:00
|
|
|
{
|
|
|
|
const std::string model = getModel(ptr);
|
|
|
|
if(!model.empty()) {
|
|
|
|
physics.insertObjectPhysics(ptr, model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Static::getModel(const MWWorld::Ptr &ptr) const
|
2011-11-12 04:01:12 +00:00
|
|
|
{
|
2012-06-29 16:54:23 +00:00
|
|
|
MWWorld::LiveCellRef<ESM::Static> *ref =
|
2011-11-12 04:01:12 +00:00
|
|
|
ptr.get<ESM::Static>();
|
2012-07-24 16:22:11 +00:00
|
|
|
assert(ref->base != NULL);
|
2011-11-12 04:01:12 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
const std::string &model = ref->base->mModel;
|
2012-07-24 16:22:11 +00:00
|
|
|
if (!model.empty()) {
|
|
|
|
return "meshes\\" + model;
|
2011-11-12 04:01:12 +00:00
|
|
|
}
|
2012-07-24 16:22:11 +00:00
|
|
|
return "";
|
2011-11-12 04:01:12 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 15:11:41 +00:00
|
|
|
std::string Static::getName (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2010-08-03 13:24:44 +00:00
|
|
|
void Static::registerSelf()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Class> instance (new Static);
|
|
|
|
|
|
|
|
registerClass (typeid (ESM::Static).name(), instance);
|
|
|
|
}
|
2012-07-25 13:18:17 +00:00
|
|
|
|
|
|
|
MWWorld::Ptr
|
2012-07-26 12:14:11 +00:00
|
|
|
Static::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
2012-07-25 13:18:17 +00:00
|
|
|
{
|
|
|
|
MWWorld::LiveCellRef<ESM::Static> *ref =
|
|
|
|
ptr.get<ESM::Static>();
|
|
|
|
|
|
|
|
return MWWorld::Ptr(&cell.statics.insert(*ref), &cell);
|
|
|
|
}
|
2010-08-03 13:24:44 +00:00
|
|
|
}
|