|
|
|
@ -25,6 +25,14 @@
|
|
|
|
|
|
|
|
|
|
#include <osg/Quat>
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
float divOrMax(float dividend, float divisor)
|
|
|
|
|
{
|
|
|
|
|
return divisor == 0 ? std::numeric_limits<float>::max() * std::numeric_limits<float>::epsilon() : dividend / divisor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWMechanics::AiPackage::AiPackage(AiPackageTypeId typeId, const Options& options) :
|
|
|
|
|
mTypeId(typeId),
|
|
|
|
|
mOptions(options),
|
|
|
|
@ -416,14 +424,15 @@ DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld::
|
|
|
|
|
const MWWorld::Class& actorClass = actor.getClass();
|
|
|
|
|
DetourNavigator::Flags result = DetourNavigator::Flag_none;
|
|
|
|
|
|
|
|
|
|
if (actorClass.isPureWaterCreature(actor)
|
|
|
|
|
|| (getTypeId() != AiPackageTypeId::Wander
|
|
|
|
|
&& ((allowToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow)
|
|
|
|
|
|| actorClass.canSwim(actor)
|
|
|
|
|
|| hasWaterWalking(actor))))
|
|
|
|
|
if ((actorClass.isPureWaterCreature(actor)
|
|
|
|
|
|| (getTypeId() != AiPackageTypeId::Wander
|
|
|
|
|
&& ((allowToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow)
|
|
|
|
|
|| actorClass.canSwim(actor)
|
|
|
|
|
|| hasWaterWalking(actor)))
|
|
|
|
|
) && actorClass.getSwimSpeed(actor) > 0)
|
|
|
|
|
result |= DetourNavigator::Flag_swim;
|
|
|
|
|
|
|
|
|
|
if (actorClass.canWalk(actor))
|
|
|
|
|
if (actorClass.canWalk(actor) && actor.getClass().getWalkSpeed(actor) > 0)
|
|
|
|
|
result |= DetourNavigator::Flag_walk;
|
|
|
|
|
|
|
|
|
|
if (actorClass.isBipedal(actor) && getTypeId() != AiPackageTypeId::Wander)
|
|
|
|
@ -439,15 +448,15 @@ DetourNavigator::AreaCosts MWMechanics::AiPackage::getAreaCosts(const MWWorld::P
|
|
|
|
|
const MWWorld::Class& actorClass = actor.getClass();
|
|
|
|
|
|
|
|
|
|
if (flags & DetourNavigator::Flag_swim)
|
|
|
|
|
costs.mWater = costs.mWater / actorClass.getSwimSpeed(actor);
|
|
|
|
|
costs.mWater = divOrMax(costs.mWater, actorClass.getSwimSpeed(actor));
|
|
|
|
|
|
|
|
|
|
if (flags & DetourNavigator::Flag_walk)
|
|
|
|
|
{
|
|
|
|
|
float walkCost;
|
|
|
|
|
if (getTypeId() == AiPackageTypeId::Wander)
|
|
|
|
|
walkCost = 1.0 / actorClass.getWalkSpeed(actor);
|
|
|
|
|
walkCost = divOrMax(1.0, actorClass.getWalkSpeed(actor));
|
|
|
|
|
else
|
|
|
|
|
walkCost = 1.0 / actorClass.getRunSpeed(actor);
|
|
|
|
|
walkCost = divOrMax(1.0, actorClass.getRunSpeed(actor));
|
|
|
|
|
costs.mDoor = costs.mDoor * walkCost;
|
|
|
|
|
costs.mPathgrid = costs.mPathgrid * walkCost;
|
|
|
|
|
costs.mGround = costs.mGround * walkCost;
|
|
|
|
|