|
|
|
@ -73,25 +73,25 @@ namespace MWMechanics
|
|
|
|
|
const MWWorld::Ptr follower = MWBase::Environment::get().getWorld()->getPtr(mTargetActorRefId, false);
|
|
|
|
|
const osg::Vec3f leaderPos = actor.getRefData().getPosition().asVec3();
|
|
|
|
|
const osg::Vec3f followerPos = follower.getRefData().getPosition().asVec3();
|
|
|
|
|
const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(actor);
|
|
|
|
|
const float maxHalfExtent = std::max(halfExtents.x(), std::max(halfExtents.y(), halfExtents.z()));
|
|
|
|
|
|
|
|
|
|
if ((leaderPos - followerPos).length2() <= mMaxDist * mMaxDist)
|
|
|
|
|
{
|
|
|
|
|
const osg::Vec3f dest(mX, mY, mZ);
|
|
|
|
|
if (pathTo(actor, dest, duration)) //Returns true on path complete
|
|
|
|
|
if (pathTo(actor, dest, duration, maxHalfExtent)) //Returns true on path complete
|
|
|
|
|
{
|
|
|
|
|
mRemainingDuration = mDuration;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(actor);
|
|
|
|
|
mMaxDist = std::max(halfExtents.x(), std::max(halfExtents.y(), halfExtents.z())) + 450.0f;
|
|
|
|
|
mMaxDist = maxHalfExtent + 450.0f;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Stop moving if the player is too far away
|
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, "idle3", 0, 1);
|
|
|
|
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
|
|
|
|
const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(actor);
|
|
|
|
|
mMaxDist = std::max(halfExtents.x(), std::max(halfExtents.y(), halfExtents.z())) + 250.0f;
|
|
|
|
|
mMaxDist = maxHalfExtent + 250.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|