mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 08:37:12 +00:00
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
This commit is contained in:
parent
add04a4ea0
commit
e3bb45fd61
@ -715,16 +715,18 @@ osg::Vec3f AimDirToMovingTarget(const MWWorld::Ptr& actor, const MWWorld::Ptr& t
|
|||||||
float t_collision;
|
float t_collision;
|
||||||
|
|
||||||
float projVelDirSquared = projSpeed * projSpeed - velPerp * velPerp;
|
float projVelDirSquared = projSpeed * projSpeed - velPerp * velPerp;
|
||||||
|
|
||||||
osg::Vec3f vTargetMoveDirNormalized = vTargetMoveDir;
|
|
||||||
vTargetMoveDirNormalized.normalize();
|
|
||||||
|
|
||||||
float projDistDiff = vDirToTarget * vTargetMoveDirNormalized; // dot product
|
|
||||||
projDistDiff = std::sqrt(distToTarget * distToTarget - projDistDiff * projDistDiff);
|
|
||||||
|
|
||||||
if (projVelDirSquared > 0)
|
if (projVelDirSquared > 0)
|
||||||
|
{
|
||||||
|
osg::Vec3f vTargetMoveDirNormalized = vTargetMoveDir;
|
||||||
|
vTargetMoveDirNormalized.normalize();
|
||||||
|
|
||||||
|
float projDistDiff = vDirToTarget * vTargetMoveDirNormalized; // dot product
|
||||||
|
projDistDiff = std::sqrt(distToTarget * distToTarget - projDistDiff * projDistDiff);
|
||||||
|
|
||||||
t_collision = projDistDiff / (std::sqrt(projVelDirSquared) - velDir);
|
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;
|
return vDirToTarget + vTargetMoveDir * t_collision;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user