mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 01:15:33 +00:00
Changes to move the mutable ESM::Position data to RefData
This commit is contained in:
parent
9794c4b928
commit
9aac625000
29 changed files with 59 additions and 43 deletions
|
@ -21,7 +21,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -16,10 +16,7 @@ namespace MWClass
|
|||
{
|
||||
// TODO check stacking
|
||||
|
||||
ESMS::LiveCellRef<T, MWWorld::RefData> cellRef;
|
||||
|
||||
cellRef.base = ptr.get<T>()->base;
|
||||
cellRef.ref = ptr.getCellRef();
|
||||
ESMS::LiveCellRef<T, MWWorld::RefData> cellRef(ptr.getCellRef(), ptr.get<T>()->base);
|
||||
cellRef.mData = ptr.getRefData();
|
||||
|
||||
containerStore.list.push_back (cellRef);
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh("meshes\\" + model);
|
||||
cellRender.insertActorPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace MWClass
|
|||
std::string hairModel = "meshes\\" +
|
||||
environment.mWorld->getStore().bodyParts.find(hairID)->model;
|
||||
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
|
||||
|
||||
//TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, true);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData, true);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
const std::string &model = ref->base->model;
|
||||
if (!model.empty())
|
||||
{
|
||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||
MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
|
||||
cellRender.insertMesh ("meshes\\" + model);
|
||||
cellRender.insertObjectPhysics();
|
||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace MWRender
|
|||
virtual ~CellRenderImp() {}
|
||||
|
||||
/// start inserting a new reference.
|
||||
virtual void insertBegin (ESM::CellRef &ref, bool static_ = false) = 0;
|
||||
virtual void insertBegin (ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false) = 0;
|
||||
|
||||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0;
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
|
@ -71,10 +71,10 @@ namespace MWRender
|
|||
|
||||
public:
|
||||
|
||||
Rendering (CellRenderImp& cellRender, ESM::CellRef &ref, bool static_ = false)
|
||||
Rendering (CellRenderImp& cellRender, ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false)
|
||||
: mCellRender (cellRender), mEnd (false)
|
||||
{
|
||||
mCellRender.insertBegin (ref, static_);
|
||||
mCellRender.insertBegin (ref, refData, static_);
|
||||
}
|
||||
|
||||
~Rendering()
|
||||
|
|
|
@ -43,7 +43,7 @@ ExteriorCellRender::ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell,
|
|||
|
||||
|
||||
|
||||
void ExteriorCellRender::insertBegin (ESM::CellRef &ref, bool static_)
|
||||
void ExteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_)
|
||||
{
|
||||
assert (!mInsert);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace MWRender
|
|||
Ogre::ColourValue mAmbientColor;
|
||||
|
||||
/// start inserting a new reference.
|
||||
virtual void insertBegin (ESM::CellRef &ref, bool static_ = false);
|
||||
virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false);
|
||||
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
|
||||
|
|
|
@ -35,14 +35,14 @@ bool InteriorCellRender::lightOutQuadInLin = false;
|
|||
|
||||
// start inserting a new reference.
|
||||
|
||||
void InteriorCellRender::insertBegin (ESM::CellRef &ref, bool static_)
|
||||
void InteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_)
|
||||
{
|
||||
assert (!insert);
|
||||
|
||||
// Create and place scene node for this object
|
||||
insert = base->createChildSceneNode();
|
||||
|
||||
const float *f = ref.pos.pos;
|
||||
const float *f = refData.getPosition().pos;
|
||||
insert->setPosition(f[0], f[1], f[2]);
|
||||
insert->setScale(ref.scale, ref.scale, ref.scale);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace MWRender
|
|||
Ogre::ColourValue ambientColor;
|
||||
|
||||
/// start inserting a new reference.
|
||||
virtual void insertBegin (ESM::CellRef &ref, bool static_ = false);
|
||||
virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false);
|
||||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
|
||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
||||
/// insert a mesh related to the most recent insertBegin call.
|
||||
|
|
|
@ -196,8 +196,10 @@ namespace MWScript
|
|||
|
||||
double diff[3];
|
||||
|
||||
const float* const pos1 = ref.getRefData().getPosition().pos;
|
||||
const float* const pos2 = ref2.getRefData().getPosition().pos;
|
||||
for (int i=0; i<3; ++i)
|
||||
diff[i] = ref.getCellRef().pos.pos[i] - ref2.getCellRef().pos.pos[i];
|
||||
diff[i] = pos1[i] - pos2[i];
|
||||
|
||||
return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,10 @@ namespace MWWorld
|
|||
mName = player->name;
|
||||
mMale = !(player->flags & ESM::NPC::Female);
|
||||
mRace = player->race;
|
||||
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
|
||||
|
||||
float* playerPos = mPlayer.mData.getPosition().pos;
|
||||
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
||||
|
||||
std::cout << renderer->getHandle();
|
||||
mPlayer.mData.setHandle (renderer->getHandle());
|
||||
/// \todo Do not make a copy of classes defined in esm/p records.
|
||||
|
|
|
@ -41,9 +41,11 @@ namespace MWWorld
|
|||
|
||||
boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
|
||||
|
||||
public:
|
||||
ESM::Position mPosition;
|
||||
|
||||
RefData() : mHasLocals (false), mEnabled (true), mCount (1) {}
|
||||
public:
|
||||
RefData(const ESMS::CellRef& cr) : mHasLocals (false), mEnabled (true),
|
||||
mCount (1), mPosition(cr.pos) {}
|
||||
|
||||
std::string getHandle()
|
||||
{
|
||||
|
@ -113,6 +115,11 @@ namespace MWWorld
|
|||
{
|
||||
return mContainerStore;
|
||||
}
|
||||
|
||||
ESM::Position& getPosition()
|
||||
{
|
||||
return mPosition;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -549,9 +549,9 @@ namespace MWWorld
|
|||
|
||||
void World::moveObjectImp (Ptr ptr, float x, float y, float z)
|
||||
{
|
||||
ptr.getCellRef().pos.pos[0] = x;
|
||||
ptr.getCellRef().pos.pos[1] = y;
|
||||
ptr.getCellRef().pos.pos[2] = z;
|
||||
ptr.getRefData().getPosition().pos[0] = x;
|
||||
ptr.getRefData().getPosition().pos[1] = y;
|
||||
ptr.getRefData().getPosition().pos[2] = z;
|
||||
|
||||
if (ptr==mPlayer->getPlayer())
|
||||
{
|
||||
|
@ -568,7 +568,7 @@ namespace MWWorld
|
|||
|
||||
if (currentCell->cell->data.gridX!=cellX || currentCell->cell->data.gridY!=cellY)
|
||||
{
|
||||
mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos, false);
|
||||
mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getRefData().getPosition(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,9 +26,20 @@ namespace ESMS
|
|||
using namespace ESM;
|
||||
|
||||
/// A reference to one object (of any type) in a cell.
|
||||
///
|
||||
/// Constructing this with a CellRef instance in the constructor means that
|
||||
/// in practice (where D is RefData) the possibly mutable data is copied
|
||||
/// across to mData. If later adding data (such as position) to CellRef
|
||||
/// this would have to be manually copied across.
|
||||
template <typename X, typename D>
|
||||
struct LiveCellRef
|
||||
{
|
||||
LiveCellRef(const CellRef& cref, const X* b = NULL) : base(b), ref(cref),
|
||||
mData(ref) {}
|
||||
|
||||
|
||||
LiveCellRef(const X* b = NULL) : base(b), mData(ref) {}
|
||||
|
||||
// The object that this instance is based on.
|
||||
const X* base;
|
||||
|
||||
|
@ -59,11 +70,7 @@ namespace ESMS
|
|||
if(obj == NULL)
|
||||
throw std::runtime_error("Error resolving cell reference " + ref.refID);
|
||||
|
||||
LiveRef lr;
|
||||
lr.ref = ref;
|
||||
lr.base = obj;
|
||||
|
||||
list.push_back(lr);
|
||||
list.push_back(LiveRef(ref, obj));
|
||||
}
|
||||
|
||||
LiveRef *find (const std::string& name)
|
||||
|
|
Loading…
Reference in a new issue