1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-06 16:15:33 +00:00

checkWayIsClear: remove PATHFIND_CAUTION_DIST check

This commit is contained in:
mrcheko 2016-07-16 19:07:48 +03:00
parent b4e94e2aae
commit 59a1a6d117
2 changed files with 8 additions and 16 deletions

View file

@ -106,22 +106,16 @@ namespace MWMechanics
bool checkWayIsClear(const osg::Vec3f& from, const osg::Vec3f& to, float offsetXY) 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;
osg::Vec3f dir = to - from; dir.normalize();
dir.z() = 0; float verticalOffset = 200; // instead of '200' here we want the height of the actor
dir.normalize(); osg::Vec3f _from = from + dir*offsetXY + osg::Z_AXIS * verticalOffset;
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 // 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); 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 (std::abs(from.z() - h) <= PATHFIND_Z_REACH);
return true;
}
return false;
} }
PathFinder::PathFinder() PathFinder::PathFinder()

View file

@ -23,8 +23,6 @@ namespace MWMechanics
const float PATHFIND_Z_REACH = 50.0f; const float PATHFIND_Z_REACH = 50.0f;
//static const float sMaxSlope = 49.0f; // duplicate as in physicssystem //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 // distance after which actor (failed previously to shortcut) will try again
const float PATHFIND_SHORTCUT_RETRY_DIST = 300.0f; const float PATHFIND_SHORTCUT_RETRY_DIST = 300.0f;