diff --git a/apps/openmw/mwrender/mwscene.cpp b/apps/openmw/mwrender/mwscene.cpp index 15163d7a2..133607797 100644 --- a/apps/openmw/mwrender/mwscene.cpp +++ b/apps/openmw/mwrender/mwscene.cpp @@ -9,6 +9,10 @@ #include "OgreCamera.h" #include "OgreTextureManager.h" +#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone +#include "../mwworld/ptr.hpp" +#include + using namespace MWRender; using namespace Ogre; @@ -36,7 +40,7 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend) mRaySceneQuery = rend.getScene()->createRayQuery(Ray()); } -std::pair MWScene::getFacedHandle() +std::pair MWScene::getFacedHandle (MWWorld::World& world) { std::string handle = ""; float distance = -1; @@ -57,10 +61,14 @@ std::pair MWScene::getFacedHandle() { // there seem to be omnipresent objects like the caelum sky dom, // the distance of these objects is always 0 so this if excludes these - // TODO: Check if the object can be focused (ignore walls etc.. - // in this state of openmw not possible) if ( itr->movable && itr->distance >= 0.1) { + // horrible hack to exclude statics. this must be removed as soon as a replacement for the + // AABB raycasting is implemented (we should not ignore statics) + MWWorld::Ptr ptr = world.getPtrViaHandle (itr->movable->getParentSceneNode()->getName()); + if (ptr.getType()==typeid (ESM::Static)) + break; + if ( nearest == result.end() ) //if no object is set { nearest = itr; @@ -80,4 +88,3 @@ std::pair MWScene::getFacedHandle() return std::pair(handle, distance); } - diff --git a/apps/openmw/mwrender/mwscene.hpp b/apps/openmw/mwrender/mwscene.hpp index ce04efc92..9d2a51bae 100644 --- a/apps/openmw/mwrender/mwscene.hpp +++ b/apps/openmw/mwrender/mwscene.hpp @@ -13,6 +13,11 @@ namespace Ogre class RaySceneQuery; } +namespace MWWorld +{ + class World; +} + namespace MWRender { /** Class responsible for Morrowind-specific interfaces to OGRE. @@ -43,7 +48,7 @@ namespace MWRender //pair //name is empty and distance = -1 if there is no object which //can be faced - std::pair getFacedHandle(); + std::pair getFacedHandle (MWWorld::World& world); }; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 2c8c4a542..24f01e5a7 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -648,7 +648,7 @@ namespace MWWorld std::string World::getFacedHandle() { - std::pair result = mScene.getFacedHandle(); + std::pair result = mScene.getFacedHandle (*this); if (result.first.empty() || result.second>getStore().gameSettings.find ("iMaxActivateDist")->i)