From c0dd383cd014bbb2919d854fe22a6c5e564f377e Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 30 Apr 2013 09:43:32 +0200 Subject: [PATCH] Fix door collision to work with all possible movement directions --- apps/openmw/mwworld/worldimp.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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