From 0c2317ce9d7f9fb2877605301d53785dc3b472ac Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 29 Mar 2012 19:20:09 +0200 Subject: [PATCH] player arrow works again --- apps/openmw/mwrender/localmap.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 47b8171a5e..ef21e26583 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -11,7 +11,8 @@ using namespace MWRender; using namespace Ogre; -LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWWorld::Environment* env) +LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWWorld::Environment* env) : + mInterior(false), mCellX(0), mCellY(0) { mRendering = rend; mEnvironment = env; @@ -93,6 +94,8 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell) { mInterior = false; + mCameraRotNode->setOrientation(Quaternion::IDENTITY); + std::string name = "Cell_"+coordStr(cell->cell->data.gridX, cell->cell->data.gridY); int x = cell->cell->data.gridX; @@ -235,7 +238,12 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& // retrieve the x,y grid coordinates the player is in int x,y; - Vector2 pos(position.x, position.z); + Vector3 _pos(position.x, 0, position.z); + _pos = mCameraRotNode->convertWorldToLocalPosition(_pos); + Vector2 pos(_pos.x, _pos.z); + + Vector3 playerdirection = mCameraRotNode->convertWorldToLocalPosition(direction); + if (!mInterior) { x = std::ceil(pos.x / sSize)-1; @@ -273,7 +281,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& texName = mInteriorName + "_" + coordStr(x,y); } mEnvironment->mWindowManager->setPlayerPos(u, v); - mEnvironment->mWindowManager->setPlayerDir(direction.x, -direction.z); + mEnvironment->mWindowManager->setPlayerDir(playerdirection.x, -playerdirection.z); // explore radius (squared) const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution;