From 0d2071915896b0dafb8348f07ee867b161736544 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 21 Aug 2010 12:31:04 +0200 Subject: [PATCH] re-routed player movement through MWWorld::World --- apps/openmw/CMakeLists.txt | 1 + apps/openmw/mwrender/playerpos.hpp | 24 +++++++++--------------- apps/openmw/mwworld/world.cpp | 12 +++++++++++- apps/openmw/mwworld/world.hpp | 2 ++ 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 95cc4179e..48acf94d0 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -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 diff --git a/apps/openmw/mwrender/playerpos.hpp b/apps/openmw/mwrender/playerpos.hpp index 31c085cc0..e83ee216d 100644 --- a/apps/openmw/mwrender/playerpos.hpp +++ b/apps/openmw/mwrender/playerpos.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 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) { diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index f6476799f..c8c661dd8 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -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 + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index c61ea12ad..608f8fb91 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -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); }; }