Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[WIP] Open door when it is on the way to a next path point (bug #5073)" #2509

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/openmw/mwbase/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}

Expand Down
25 changes: 2 additions & 23 deletions apps/openmw/mwmechanics/aipackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -226,25 +224,16 @@ 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();

const MWWorld::Ptr door = getNearbyDoor(actor, distance);
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);
Expand Down Expand Up @@ -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);
}
2 changes: 0 additions & 2 deletions apps/openmw/mwmechanics/aipackage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ namespace MWMechanics

private:
bool isNearInactiveCell(osg::Vec3f position);

bool isDoorOnTheWay(const MWWorld::Ptr& actor, const MWWorld::Ptr& door) const;
};
}

Expand Down
20 changes: 0 additions & 20 deletions apps/openmw/mwworld/worldimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <components/misc/constants.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/rng.hpp>
#include <components/misc/convert.hpp>

#include <components/files/collections.hpp>

Expand Down Expand Up @@ -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);
}
}
2 changes: 0 additions & 2 deletions apps/openmw/mwworld/worldimp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}

Expand Down