From 59a1a6d117da291c7db953fab14963f63486fe44 Mon Sep 17 00:00:00 2001 From: mrcheko Date: Sat, 16 Jul 2016 19:07:48 +0300 Subject: [PATCH] checkWayIsClear: remove PATHFIND_CAUTION_DIST check --- apps/openmw/mwmechanics/pathfinding.cpp | 22 ++++++++-------------- apps/openmw/mwmechanics/pathfinding.hpp | 2 -- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 2a452907d..ef60a85a4 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -106,22 +106,16 @@ namespace MWMechanics bool checkWayIsClear(const osg::Vec3f& from, const osg::Vec3f& to, float offsetXY) { - if((to - from).length() >= PATHFIND_CAUTION_DIST || std::abs(from.z() - to.z()) <= PATHFIND_Z_REACH) - { - osg::Vec3f dir = to - from; - dir.z() = 0; - dir.normalize(); - float verticalOffset = 200; // instead of '200' here we want the height of the actor - osg::Vec3f _from = from + dir*offsetXY + osg::Z_AXIS * verticalOffset; + osg::Vec3f dir = to - from; + dir.z() = 0; + dir.normalize(); + float verticalOffset = 200; // instead of '200' here we want the height of the actor + osg::Vec3f _from = from + dir*offsetXY + osg::Z_AXIS * verticalOffset; - // cast up-down ray and find height in world space of hit - float h = _from.z() - MWBase::Environment::get().getWorld()->getDistToNearestRayHit(_from, -osg::Z_AXIS, verticalOffset + PATHFIND_Z_REACH + 1); + // cast up-down ray and find height of hit in world space + float h = _from.z() - MWBase::Environment::get().getWorld()->getDistToNearestRayHit(_from, -osg::Z_AXIS, verticalOffset + PATHFIND_Z_REACH + 1); - if(std::abs(from.z() - h) <= PATHFIND_Z_REACH) - return true; - } - - return false; + return (std::abs(from.z() - h) <= PATHFIND_Z_REACH); } PathFinder::PathFinder() diff --git a/apps/openmw/mwmechanics/pathfinding.hpp b/apps/openmw/mwmechanics/pathfinding.hpp index 05f846991..64608979b 100644 --- a/apps/openmw/mwmechanics/pathfinding.hpp +++ b/apps/openmw/mwmechanics/pathfinding.hpp @@ -23,8 +23,6 @@ namespace MWMechanics const float PATHFIND_Z_REACH = 50.0f; //static const float sMaxSlope = 49.0f; // duplicate as in physicssystem - // distance at which actor pays more attention to decide whether to shortcut or stick to pathgrid - const float PATHFIND_CAUTION_DIST = 500.0f; // distance after which actor (failed previously to shortcut) will try again const float PATHFIND_SHORTCUT_RETRY_DIST = 300.0f;