Merge branch 'minor_aicombat' into 'master'

Minor optimization in aicombat.cpp

See merge request OpenMW/openmw!737

(cherry picked from commit f1d19035cccfff2523faad0d4e4d96cd3ddae2e6)

bbbfc520 Minor optimization in aicombat.cpp
237b34a6 Fix style
a14911cb Fix indentation
pull/593/head
Alexei Dobrohotov 4 years ago committed by psi29a
parent add04a4ea0
commit e3bb45fd61

@ -715,16 +715,18 @@ osg::Vec3f AimDirToMovingTarget(const MWWorld::Ptr& actor, const MWWorld::Ptr& t
float t_collision;
float projVelDirSquared = projSpeed * projSpeed - velPerp * velPerp;
if (projVelDirSquared > 0)
{
osg::Vec3f vTargetMoveDirNormalized = vTargetMoveDir;
vTargetMoveDirNormalized.normalize();
osg::Vec3f vTargetMoveDirNormalized = vTargetMoveDir;
vTargetMoveDirNormalized.normalize();
float projDistDiff = vDirToTarget * vTargetMoveDirNormalized; // dot product
projDistDiff = std::sqrt(distToTarget * distToTarget - projDistDiff * projDistDiff);
float projDistDiff = vDirToTarget * vTargetMoveDirNormalized; // dot product
projDistDiff = std::sqrt(distToTarget * distToTarget - projDistDiff * projDistDiff);
if (projVelDirSquared > 0)
t_collision = projDistDiff / (std::sqrt(projVelDirSquared) - velDir);
else t_collision = 0; // speed of projectile is not enough to reach moving target
}
else
t_collision = 0; // speed of projectile is not enough to reach moving target
return vDirToTarget + vTargetMoveDir * t_collision;
}

Loading…
Cancel
Save