re-routed player movement through MWWorld::World

actorid
Marc Zinnschlag 15 years ago
parent fe3b6230fc
commit 0d20719158

@ -14,6 +14,7 @@ set(GAMEREND
mwrender/cellimp.cpp
mwrender/interior.cpp
mwrender/exterior.cpp
mwrender/playerpos.cpp
mwrender/sky.cpp)
set(GAMEREND_HEADER
mwrender/cell.hpp

@ -8,6 +8,11 @@
#include "../mwworld/refdata.hpp"
#include "../mwworld/ptr.hpp"
namespace MWWorld
{
class World;
}
namespace MWRender
{
// This class keeps track of the player position. It takes care of
@ -18,29 +23,18 @@ namespace MWRender
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
MWWorld::Ptr::CellStore *mCellStore;
Ogre::Camera *camera;
MWWorld::World& mWorld;
public:
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player) :
mCellStore (0), camera(cam)
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
mCellStore (0), camera(cam), mWorld (world)
{
mPlayer.base = player;
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
}
// Set the player position. Uses Morrowind coordinates.
void setPos(float _x, float _y, float _z, bool updateCamera = false)
{
mPlayer.ref.pos.pos[0] = _x;
mPlayer.ref.pos.pos[1] = _y;
mPlayer.ref.pos.pos[2] = _z;
if (updateCamera)
camera->setPosition (Ogre::Vector3 (
mPlayer.ref.pos.pos[0],
mPlayer.ref.pos.pos[2],
-mPlayer.ref.pos.pos[1]));
// TODO: Update sound listener
}
void setPos(float _x, float _y, float _z, bool updateCamera = false);
void setCell (MWWorld::Ptr::CellStore *cellStore)
{

@ -287,7 +287,7 @@ namespace MWWorld
mEsm.open (masterPath.file_string());
mStore.load (mEsm);
mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"));
mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"), *this);
// global variables
mGlobalVariables = new Globals (mStore);
@ -685,4 +685,14 @@ namespace MWWorld
}
}
}
void World::moveObject (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;
// TODO cell change for non-player ref
// TODO cell change for player ref
}
}

@ -145,6 +145,8 @@ namespace MWWorld
///< Return handle of the object the player is looking at
void deleteObject (Ptr ptr);
void moveObject (Ptr ptr, float x, float y, float z);
};
}

Loading…
Cancel
Save