mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 22:19:54 +00:00
f031a191b8
Since actors can be active in 3x3 grid around the player, we need to first load all statics in a 5x5 grid around the player. Split load and unloading in 2 phases. Add an mInactiveCells set into the scene, which contains all cells inside the aforementioned 5x5 grid. These cells contains only heightfields and physics objects of static class.
71 lines
1.9 KiB
C++
71 lines
1.9 KiB
C++
#include "static.hpp"
|
|
|
|
#include <components/esm/loadstat.hpp>
|
|
#include <components/sceneutil/positionattitudetransform.hpp>
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
#include "../mwphysics/physicssystem.hpp"
|
|
#include "../mwworld/cellstore.hpp"
|
|
|
|
#include "../mwrender/objects.hpp"
|
|
#include "../mwrender/renderinginterface.hpp"
|
|
#include "../mwrender/vismask.hpp"
|
|
|
|
namespace MWClass
|
|
{
|
|
|
|
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
|
{
|
|
if (!model.empty())
|
|
{
|
|
renderingInterface.getObjects().insertModel(ptr, model);
|
|
ptr.getRefData().getBaseNode()->setNodeMask(MWRender::Mask_Static);
|
|
}
|
|
}
|
|
|
|
void Static::insertObject(const MWWorld::Ptr& ptr, const std::string& model, osg::Quat rotation, MWPhysics::PhysicsSystem& physics) const
|
|
{
|
|
if(!model.empty())
|
|
physics.addObject(ptr, model, rotation);
|
|
}
|
|
|
|
std::string Static::getModel(const MWWorld::ConstPtr &ptr) const
|
|
{
|
|
const MWWorld::LiveCellRef<ESM::Static> *ref = ptr.get<ESM::Static>();
|
|
|
|
const std::string &model = ref->mBase->mModel;
|
|
if (!model.empty()) {
|
|
return "meshes\\" + model;
|
|
}
|
|
return "";
|
|
}
|
|
|
|
std::string Static::getName (const MWWorld::ConstPtr& ptr) const
|
|
{
|
|
return "";
|
|
}
|
|
|
|
bool Static::hasToolTip(const MWWorld::ConstPtr& ptr) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
void Static::registerSelf()
|
|
{
|
|
std::shared_ptr<Class> instance (new Static);
|
|
|
|
registerClass (typeid (ESM::Static).name(), instance);
|
|
}
|
|
|
|
MWWorld::Ptr Static::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
|
{
|
|
const MWWorld::LiveCellRef<ESM::Static> *ref = ptr.get<ESM::Static>();
|
|
|
|
return MWWorld::Ptr(cell.insert(ref), &cell);
|
|
}
|
|
|
|
bool Static::isStatic() const
|
|
{
|
|
return true;
|
|
}
|
|
}
|