From a25ee360dc000a5a8b42f6523794a19f19b4e31a Mon Sep 17 00:00:00 2001 From: gus Date: Sat, 3 Aug 2013 12:16:51 +0200 Subject: [PATCH] use angles and GMST. not sure this work as it should --- apps/openmw/mwworld/physicssystem.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 2615842e9..071321223 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -15,9 +15,12 @@ #include -//#include "../mwbase/world.hpp" // FIXME +#include "../mwbase/world.hpp" // FIXME #include "../mwbase/environment.hpp" +#include +#include "../mwworld/esmstore.hpp" + #include "ptr.hpp" #include "class.hpp" @@ -319,8 +322,23 @@ namespace MWWorld result.second *= queryDistance; std::pair result2 = mEngine->sphereTest(queryDistance,origin); - std::cout << "physic system: getFacedHandle" << result2.first << result2.second.length(); - return std::make_pair (result2.first,result2.second.length()); + //std::cout << "physic system: getFacedHandle" << result2.first << result2.second.length(); + if(result2.first == "") return std::make_pair("",0); + btVector3 a = result2.second - origin; + Ogre::Vector3 a_ = Ogre::Vector3(a.x(),a.y(),a.z()); + a_ = orient_.Inverse()*a_; + Ogre::Vector2 a_xy = Ogre::Vector2(a_.x,a_.y); + Ogre::Vector2 a_yz = Ogre::Vector2(a_.y,a_.z); + float axy = a_xy.angleBetween(Ogre::Vector2::UNIT_Y).valueDegrees(); + float az = a_yz.angleBetween(Ogre::Vector2::UNIT_X).valueDegrees(); + std::cout << axy << " " << az << "\n"; + //MWBase::Environment::get().getWorld()->getStore(); + float fCombatAngleXY = MWBase::Environment::get().getWorld()->getStore().get().find("fCombatAngleXY")->getFloat(); + float fCombatAngleZ = MWBase::Environment::get().getWorld()->getStore().get().find("fCombatAngleZ")->getFloat(); + if(abs(axy) < fCombatAngleXY && abs(az) < fCombatAngleZ) + return std::make_pair (result2.first,result2.second.length()); + else + return std::make_pair("",0); //return result; }