mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-03 01:11:32 +00:00
Use z coordinate for path distance when diff by z is greater then actor height
This commit is contained in:
parent
81832f8e17
commit
e4d0af6a6d
1 changed files with 8 additions and 1 deletions
|
@ -81,13 +81,20 @@ namespace
|
||||||
const auto realHalfExtents = world->getHalfExtents(actor);
|
const auto realHalfExtents = world->getHalfExtents(actor);
|
||||||
return 2 * std::max(realHalfExtents.x(), realHalfExtents.y());
|
return 2 * std::max(realHalfExtents.x(), realHalfExtents.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getHeight(const MWWorld::ConstPtr& actor)
|
||||||
|
{
|
||||||
|
const auto world = MWBase::Environment::get().getWorld();
|
||||||
|
const auto halfExtents = world->getHalfExtents(actor);
|
||||||
|
return 2.0 * halfExtents.z();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
float getPathDistance(const MWWorld::Ptr& actor, const osg::Vec3f& lhs, const osg::Vec3f& rhs)
|
float getPathDistance(const MWWorld::Ptr& actor, const osg::Vec3f& lhs, const osg::Vec3f& rhs)
|
||||||
{
|
{
|
||||||
if (canActorMoveByZAxis(actor))
|
if (std::abs(lhs.z() - rhs.z()) > getHeight(actor) || canActorMoveByZAxis(actor))
|
||||||
return distance(lhs, rhs);
|
return distance(lhs, rhs);
|
||||||
return distanceIgnoreZ(lhs, rhs);
|
return distanceIgnoreZ(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue