diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 5f44545e9..c5970a32c 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -1016,7 +1018,11 @@ namespace MWWorld Ogre::Vector3 relativePos = it->first.getRefData().getBaseNode()-> convertWorldToLocalPosition(ptr.getRefData().getBaseNode()->_getDerivedPosition()); - float axisToCheck = (dimensions.x > dimensions.y) ? relativePos.y : -relativePos.x; + float axisToCheck; + if (dimensions.x > dimensions.y) + axisToCheck = relativePos.y * boost::math::sign((min+max).y); + else + axisToCheck = relativePos.x * boost::math::sign((min+max).x); if (axisToCheck >= 0) targetRot = std::min(std::max(0.f, oldRot + diff*0.5f), 90.f); else