From 41ad23ebdca2b90841210f45c34d365062483999 Mon Sep 17 00:00:00 2001 From: Roman Siromakha Date: Tue, 27 Aug 2019 20:55:03 +0200 Subject: [PATCH] Revert "[WIP] Open door when it is on the way to a next path point (bug #5073)" --- apps/openmw/mwbase/world.hpp | 2 -- apps/openmw/mwmechanics/aipackage.cpp | 25 ++----------------------- apps/openmw/mwmechanics/aipackage.hpp | 2 -- apps/openmw/mwworld/worldimp.cpp | 20 -------------------- apps/openmw/mwworld/worldimp.hpp | 2 -- 5 files changed, 2 insertions(+), 49 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 8c6829eb3..955e77168 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -614,8 +614,6 @@ namespace MWBase /// Return physical half extents of the given actor to be used in pathfinding virtual osg::Vec3f getPathfindingHalfExtents(const MWWorld::ConstPtr& actor) const = 0; - - virtual bool hasCollisionWithDoor(const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const = 0; }; } diff --git a/apps/openmw/mwmechanics/aipackage.cpp b/apps/openmw/mwmechanics/aipackage.cpp index c834f6984..646b37669 100644 --- a/apps/openmw/mwmechanics/aipackage.cpp +++ b/apps/openmw/mwmechanics/aipackage.cpp @@ -13,8 +13,6 @@ #include "../mwworld/cellstore.hpp" #include "../mwworld/inventorystore.hpp" -#include "../mwphysics/collisiontype.hpp" - #include "pathgrid.hpp" #include "creaturestats.hpp" #include "movement.hpp" @@ -226,13 +224,6 @@ void MWMechanics::AiPackage::evadeObstacles(const MWWorld::Ptr& actor) void MWMechanics::AiPackage::openDoors(const MWWorld::Ptr& actor) { - // note: AiWander currently does not open doors - if (getTypeId() == TypeIdWander) - return; - - if (mPathFinder.getPathSize() == 0) - return; - MWBase::World* world = MWBase::Environment::get().getWorld(); static float distance = world->getMaxActivationDistance(); @@ -240,11 +231,9 @@ void MWMechanics::AiPackage::openDoors(const MWWorld::Ptr& actor) if (door == MWWorld::Ptr()) return; - if (!door.getCellRef().getTeleport() && door.getClass().getDoorState(door) == MWWorld::DoorState::Idle) + // note: AiWander currently does not open doors + if (getTypeId() != TypeIdWander && !door.getCellRef().getTeleport() && door.getClass().getDoorState(door) == MWWorld::DoorState::Idle) { - if (!isDoorOnTheWay(actor, door)) - return; - if ((door.getCellRef().getTrap().empty() && door.getCellRef().getLockLevel() <= 0 )) { world->activate(door, actor); @@ -413,13 +402,3 @@ DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld:: return result; } - -bool MWMechanics::AiPackage::isDoorOnTheWay(const MWWorld::Ptr& actor, const MWWorld::Ptr& door) const -{ - const auto world = MWBase::Environment::get().getWorld(); - const auto halfExtents = world->getHalfExtents(actor); - const auto position = actor.getRefData().getPosition().asVec3() + osg::Vec3f(0, 0, halfExtents.z()); - const auto destination = mPathFinder.getPath().front() + osg::Vec3f(0, 0, halfExtents.z()); - - return world->hasCollisionWithDoor(door, position, destination); -} diff --git a/apps/openmw/mwmechanics/aipackage.hpp b/apps/openmw/mwmechanics/aipackage.hpp index 0f7b5cf1d..6bb12342a 100644 --- a/apps/openmw/mwmechanics/aipackage.hpp +++ b/apps/openmw/mwmechanics/aipackage.hpp @@ -147,8 +147,6 @@ namespace MWMechanics private: bool isNearInactiveCell(osg::Vec3f position); - - bool isDoorOnTheWay(const MWWorld::Ptr& actor, const MWWorld::Ptr& door) const; }; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 908e5c052..3ea994683 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include @@ -3830,23 +3829,4 @@ namespace MWWorld return getHalfExtents(actor); } - bool World::hasCollisionWithDoor(const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const - { - const auto object = mPhysics->getObject(door); - - if (!object) - return false; - - btVector3 aabbMin; - btVector3 aabbMax; - object->getShapeInstance()->getCollisionShape()->getAabb(btTransform::getIdentity(), aabbMin, aabbMax); - - const auto toLocal = object->getCollisionObject()->getWorldTransform().inverse(); - const auto localFrom = toLocal(Misc::Convert::toBullet(position)); - const auto localTo = toLocal(Misc::Convert::toBullet(destination)); - - btScalar hitDistance = 1; - btVector3 hitNormal; - return btRayAabb(localFrom, localTo, aabbMin, aabbMax, hitDistance, hitNormal); - } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index bd34087ac..76d015477 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -719,8 +719,6 @@ namespace MWWorld /// Return physical half extents of the given actor to be used in pathfinding osg::Vec3f getPathfindingHalfExtents(const MWWorld::ConstPtr& actor) const override; - - bool hasCollisionWithDoor(const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const override; }; }