|
|
|
@ -22,27 +22,6 @@
|
|
|
|
|
|
|
|
|
|
#include <osg/Quat>
|
|
|
|
|
|
|
|
|
|
namespace MWMechanics
|
|
|
|
|
{
|
|
|
|
|
static float distance(const osg::Vec2f& lhs, const osg::Vec2f& rhs)
|
|
|
|
|
{
|
|
|
|
|
return (lhs - rhs).length2();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float distanceIgnoreZ(const osg::Vec3f& lhs, const osg::Vec3f& rhs)
|
|
|
|
|
{
|
|
|
|
|
return distance(osg::Vec2f(lhs.x(), lhs.y()), osg::Vec2f(rhs.x(), rhs.y()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float distance(const osg::Vec3f& lhs, const osg::Vec3f& rhs, const MWWorld::Ptr& actor)
|
|
|
|
|
{
|
|
|
|
|
const auto world = MWBase::Environment::get().getWorld();
|
|
|
|
|
if (world->isSwimming(actor) || world->isFlying(actor))
|
|
|
|
|
return distance(lhs, rhs);
|
|
|
|
|
return distanceIgnoreZ(lhs, rhs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWMechanics::AiPackage::~AiPackage() {}
|
|
|
|
|
|
|
|
|
|
MWMechanics::AiPackage::AiPackage() :
|
|
|
|
@ -352,7 +331,7 @@ bool MWMechanics::AiPackage::checkWayIsClearForActor(const osg::Vec3f& startPoin
|
|
|
|
|
bool MWMechanics::AiPackage::doesPathNeedRecalc(const osg::Vec3f& newDest, const MWWorld::Ptr& actor) const
|
|
|
|
|
{
|
|
|
|
|
return mPathFinder.getPath().empty()
|
|
|
|
|
|| distance(mPathFinder.getPath().back(), newDest, actor) > 10
|
|
|
|
|
|| getPathDistance(actor, mPathFinder.getPath().back(), newDest) > 10
|
|
|
|
|
|| mPathFinder.getPathCell() != actor.getCell();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|