mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 17:45:34 +00:00
Use half extents for destination distance tolerance in AiEscort
For actors moving in water destination may be located at such z coordinate that they can't reach.
This commit is contained in:
parent
f32e1790bc
commit
453e94ea9f
1 changed files with 5 additions and 5 deletions
|
@ -73,25 +73,25 @@ namespace MWMechanics
|
||||||
const MWWorld::Ptr follower = MWBase::Environment::get().getWorld()->getPtr(mTargetActorRefId, false);
|
const MWWorld::Ptr follower = MWBase::Environment::get().getWorld()->getPtr(mTargetActorRefId, false);
|
||||||
const osg::Vec3f leaderPos = actor.getRefData().getPosition().asVec3();
|
const osg::Vec3f leaderPos = actor.getRefData().getPosition().asVec3();
|
||||||
const osg::Vec3f followerPos = follower.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)
|
if ((leaderPos - followerPos).length2() <= mMaxDist * mMaxDist)
|
||||||
{
|
{
|
||||||
const osg::Vec3f dest(mX, mY, mZ);
|
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;
|
mRemainingDuration = mDuration;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(actor);
|
mMaxDist = maxHalfExtent + 450.0f;
|
||||||
mMaxDist = std::max(halfExtents.x(), std::max(halfExtents.y(), halfExtents.z())) + 450.0f;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Stop moving if the player is too far away
|
// Stop moving if the player is too far away
|
||||||
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, "idle3", 0, 1);
|
MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, "idle3", 0, 1);
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(actor);
|
mMaxDist = maxHalfExtent + 250.0f;
|
||||||
mMaxDist = std::max(halfExtents.x(), std::max(halfExtents.y(), halfExtents.z())) + 250.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue